Sending multiple floats over BLE


I'm trying to make a sketch that sends three floats over BLE to an Android device. The three floats are converted into an array which holds every single bytes of the three floats. The problem is that on my Android device the hexadecimal values aren't enteriley correctley. The values visible in the app are: (0x) C3-F5-48-40-52-B8-16-41-00-00-00-00.
This is my code:

#include <ArduinoBLE.h>

float value1 = 3.14;
float value2 = 6.28;
float value3 = 9.42;

byte packetArray[12] = {

BLEService dataService("180C"); 

BLECharacteristic newDataCharacteristic("2A56", BLERead | BLENotify, sizeof(packetArray), true);

void setup() {

  if (!BLE.begin()) {
    Serial.println("starting BLE failed!");
    while (1);

  newDataCharacteristic.setValue(packetArray, sizeof(packetArray));

void loop() {
  BLEDevice device = BLE.central();
  while (device.connected()){
    // Do nothing

C3-F5-48-40 does indeed represent value1. However, 52-B8-16-41 doesn't represent value2, but value3 and value2 somehow disappeared. Does anyone know why this is happening, what I am doing wrong or is what I'm tryting to do even impossible with BLE?

The indexes should just stay between 0 and 3

byte packetArray[12] = {

As you get access to the bytes from each float in memory.

Having the 3 floats in a structure and sending the structure would make it easier…

It works now. I confused the indexes with the size of the array. Thanks!

Great. Have fun

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.