Hi everyone! I have an ADC that send sensors data to Arduino (let say that those data are rapresented as int from 2500 to 5000). I need to send these data to a Raspberry trough bluetooth serial connection.
Data sent from the Arduino have this layout;
data1,data2,data3,…data7
data1,data2,data3,…data7
…
for example
2536,4263,4235,4898,2636,4632,3223
3464,3524,4542,3645,3456,3454,4599
…
right now I’m using this way to transmit data:
for (int i = 0; i<7; i++) {
bt.print(val_average[i], DEC); // il valore
if (i<6){
bt.print(",");
}
}
bt.println();
delay(100);
from the Raspberry side I’m using
line=serial.readline()
file.write(line)
It works, but if I get it right, every digit sent in this way is rapresented as a char, so 8 bit.
2536 → 48=32 bit
so each line is 327+ 6*8 byte (commas) + EOL char
How can I reduce the amount of byte used?
I was thinking, since the layout is allways the same, to get rid of the commas and send 2byte for each sensor value and then translate everything from raspberry side.
for example
sensoreValue= 3467 → 110110001011 -->00001101 and 10001011
so that
//arduno side
Serial.print(3467); //old one
//should became something like
Serial.write(0b00001101);
Serial.write(0b10001011);
I don’t know if it is possible or if there is something already implemented. Please, give me your advice.
thanks for your time, hope to hear you soon,
Dario