how can ı send data more than 32byte through nrfl2401

Hi everyone, I am beginner in arduino and I’ve been working on telemetry system which has bme-280, gyroscope and neo-gps module. When I try to recieve one sensor data, nrf24l01 works properly. Here’s a part of the my code (one sensor).

struct package
{
  float temperature ;
  float pressure;
  float altitude ;
  float humidity ;
};
typedef struct package Package;
Package databme;

   databme.temperature= bme.readTemperature();
   databme.humidity=bme.readHumidity();
   databme.pressure= (bme.readPressure() /100.0F);
   databme.altitude= bme.readAltitude(SEALEVELPRESSURE_HPA);
   radio.write(&databme, sizeof(databme ));

But if i try this with 2 sensor, both data recieved is very wrong. (sensors work properly) Here’s sample code:

struct package
{
  float temperature ;
  float pressure;
  float altitude ;
  float humidity ;
};
typedef struct package Package;
Package databme;

struct package1
{
  float AcX ;
  float AcY;
  float AcZ;
  float GyX;
  float GyY;
  float GyZ;
};
typedef struct package1 Package1;
Package1 datagyro;

   databme.temperature= bme.readTemperature();
   databme.humidity=bme.readHumidity();
   databme.pressure= (bme.readPressure() /100.0F);
   databme.altitude= bme.readAltitude(SEALEVELPRESSURE_HPA);
   radio.write(&databme, sizeof(databme ));
   delay (200);

  AcX=Wire.read()<<8|Wire.read();    // read accelerometer x axis
  AcY=Wire.read()<<8|Wire.read();      // read accelerometer y axis
  AcZ=Wire.read()<<8|Wire.read();  // read accelerometer z axis
  GyX=Wire.read()<<8|Wire.read(); // read Gyroscope x axis
  GyY=Wire.read()<<8|Wire.read();  //read Gyroscope y axis
  GyZ=Wire.read()<<8|Wire.read();  // read Gyroscope z axis
  datagyro.AcX=AcX;
  datagyro.AcY=AcY;
  datagyro.AcZ=AcZ;
  datagyro.GyX=GyX;
  datagyro.GyY=GyY;
  datagyro.GyZ=GyZ;
  radio.write(&datagyro, sizeof(datagyro ));  // send data

How can i manage this?
Thanks :slight_smile:

You can determine how many unnecessary high order zeros are being sent and how many unnecessary digits beyond the float decimal point are being sent. If they are the reason for too much data, convert the floats to integers and send them instead. A float is 4 bytes long, and integer is 2 bytes long.

Paul

I thought neo-gps was serial, not I2C. Regardless, this code:

AcX=Wire.read()<<8|Wire.read(); // read accelerometer x axis
AcY=Wire.read()<<8|Wire.read(); // read accelerometer y axis
AcZ=Wire.read()<<8|Wire.read(); // read accelerometer z axis
GyX=Wire.read()<<8|Wire.read(); // read Gyroscope x axis
GyY=Wire.read()<<8|Wire.read(); //read Gyroscope y axis
GyZ=Wire.read()<<8|Wire.read(); // read Gyroscope z axis

Is not going to result in a float because you’re only reading 16 bits, not 32. I have no idea if what you’re doing to read the neo-gps is even remotely correct but I do know It is impossible to create a proper float with what your limited code shows.

The usual way to send more than 32 bytes is to break the data into two separate messages.

Be sure to include some sort of marker in each message so that the receiver knows whether it is part1 or part2 - just in case one part gets lost in transmission.

...R