Arduino/C++ Sandbox

Trunet's Place - Portfolio
Jump to: navigation, search

Float(32-bits) to Bytes(8-bits)

uint8_t payload[20] = {};
uint8_t payloadPointer = 0;
void addToPayload(float f) {
  byte * b = (byte *) &f;
  payload[payloadPointer++] = b[0];
  payload[payloadPointer++] = b[1];
  payload[payloadPointer++] = b[2];
  payload[payloadPointer++] = b[3];
}