I have been working on a tool that is reading certain inputs and is transferring data from Arduino to Android phone over BLE (Bluetooth). For some reason only 6 values are fitting into one line, then 7th value is always coming separately on the next line. Why so? Is there some limitation in terms of string length over BLE? Should I send this in some other format and then how?
#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
static const int RXPin = 2, TXPin = 3;
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(115200);
sensors.begin();
ss.begin(115200);
}
void loop()
{
int value0 = analogRead(A0);
int value1 = analogRead(A1);
int value2 = analogRead(A2);
int value3 = analogRead(A3);
int value4 = analogRead(A4);
int value5 = analogRead(A5);
int value6 = round(gps.speed.kmph());
Serial.print(value0);
Serial.print(",");
Serial.print(value1);
Serial.print(",");
Serial.print(value2);
Serial.print(",");
Serial.print(value3);
Serial.print(",");
Serial.print(value4);
Serial.print(",");
Serial.print(value5);
Serial.print(",");
Serial.print(value6);
}
Last value always comes on a separate line after previous 6.
I am getting as an output in my Android device while debugging following string "530,983,62,128,0,26,"
As you can see there is a comma, but no 7th value even tho it is there if I check from my PC Arduino Serial Monitor
Apparently so, I found the same information on Stack Exchange. You could fit the binary integer values into a packet (two bytes each) as long as your Android program knows how to deal with them. Or you need to figure out how to process two packets on the Android.
Any code example how to send data in two packets with identifiers? I was just happy to get the connection working successfully, I am not that advanced yet. I have tried to search on google some example, but could not find anything suitable so far.
I just have wired HM-19 and it seems to be working with >20 bytes. However it is operating on 9600 baud rate and it seems like it is not possible to change it. I would prefer as fast data transfer as possible. What would you say, is it better to use old Bluetooth 4.0 with 115200 and sending data in portions as you suggested or use HM-19 on 9600 with data >20 bytes in one "string"?