What's the best way to send float
, double
, and int16
over serial on Arduino?
The Serial.print()
only sends values as ASCII encoded. But I want to send the values as bytes. Serial.write()
accepts byte and bytearrays, but what's the best way to convert the values to bytes?
I tried to cast an int16
to an byte*
, without luck. I also used memcpy, but that uses to many CPU cycles. Arduino uses plain C/C++. It's an ATmega328 microcontroller.
hm. How about this: