9 years, 2 months ago.

How to printf a float data to serial on nrf51822?

I just find %f and %lf does not work on printf or Serial.printf, but the same code works fine on stm32 nucleo board.

Is there any difference in C libs?

Question relating to:

Nordic stack and drivers for the mbed BLE API

Does anyone know that?

posted by Ma Yunfei 04 Oct 2015

2 Answers

9 years, 2 months ago.

It should be the same. So if you run this code (entering the correct pins for tx and rx) you get the Hello but not the number?

Serial pc(tx,rx);
main (){
  float x = 10.2;
  pc.printf("Hello\r\n");
  pc.printf("x= %.1f\r\n",x);
}

The same code works on my stm32 nucleo board, but does not work on this one

posted by Ma Yunfei 09 Sep 2015
9 years, 2 months ago.

That is a simple , If you got 10.11, you can send it as 1011 , then when you received, just do 1011/10 then you get what you need

Thanks YuFei, I agree it is a solution, but does not solve my problem

posted by Ma Yunfei 09 Sep 2015