Dear forum users,
As mentioned in the subject i am using nrf24l01 modules to send data to a raspbery pi using Arduino Nano.
The data needs to be transmitted as a single char array with 4 values separated by";". The first three values are acceleration measured with MPU6050 and the third one is the time between them in milliseconds (ideal value ~100). I've spent a lot of time trying to figure it out. That's the best I've managed to do:
bool send(int ax, int ay, int az, unsigned long czas){
char sep[1] = {';'};
bool ack = 0;
float gax, gay, gaz;
char mess[21];
char outax[5+1];
char outay[5+1];
char outaz[5+1];
char czasout [4];
gax = (aax/16.384/1000);
gay = (aay/16.384/1000);
gaz = (aaz/16.384/1000);
dtostrf(gax, 5, 2, outax);
dtostrf(gay, 5, 2, outay);
dtostrf(gaz, 5, 2, outaz);
ultoa(czas,czasout, 10);
strcpy(wiad, outax);
strcat(wiad, sep);
strcat(wiad, outay);
strcat(wiad, sep);
strcat(wiad, outaz);
strcat(wiad, sep);
strcat(wiad, czasout);
ack = radio.write(mess, sizeof(wiad));
return ack;
}
Still, what is received on the other side is:
[32, 48, 46, 48, 48, 59, 100, 45, 48, 46, 48, 50, 59, 100, 32, 49, 46, 48, 49, 59, 100]
, which translates to
0.00;d-0.02;d 1.01;d
and similar with different letters.
The values look ok, apart from the fact that the last one is missing. I tried printing the message before sending and it looks like this:
-0.00;d-0.02;d 1.00;d100
Sometimes a weird square character appears, between values.
NRF library: GitHub - nRF24/RF24: OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
Could anyone please help me with the char array conversion?
Greetings from Poland,
Artur P
PS.
Pardon my english, I'm not a native speaker.