Hi,
I have been trying to recieve a 24 characters long string from BluetoothLE 4.0 and arduino nano on the app screen. The string's format is as follows: 10.5;11.3;14.5;20.4;12.3. The app screen only shows first 20 characters. These are actually five pressure values printed on the arduino nano's serial monitor. I know that I can't change the MTU of Bluetooth 4.0. I can only do it by sending the data in packets. Please guide me how to send and receive data in packets? Thanks a lot.
My app blocks, arduino code and reference images are attached.
Ahmed
while (1) {
// While in this loop, keep Writing the pressure value in the app
Serial.print("A:");
Serial.println(SensorA(p1A,p2A,p3A,p4A,p5A,p6A,q1A,q2A),1); // Write pressureA value to app
Serial.print("B:");
Serial.println(SensorB(p1B,p2B,p3B,p4B,p5B,p6B,q1B,q2B),1); // Write pressureB value to app
Serial.print("C:");
Serial.println(SensorC(p1C,p2C,p3C,p4C,p5C,p6C,q1C,q2C,q3C),1); // Write pressureC value to app
Serial.print("D:");
Serial.println(SensorD(p1D,p2D,p3D,p4D,p5D,q1D,q2D),1); // Write pressureD value to app
Serial.print("mean:");
Serial.println(average(),1);
delay(800);
Serial.print((String(SensorA(p1A,p2A,p3A,p4A,p5A,p6A,q1A,q2A),1)).toFloat()* 10); // Write pressureA value to app
Serial.print("|");
Serial.print((String(SensorB(p1B,p2B,p3B,p4B,p5B,p6B,q1B,q2B),1)).toFloat()* 10); // Write pressureB value to app
Serial.print("|");
Serial.print((String(SensorC(p1C,p2C,p3C,p4C,p5C,p6C,q1C,q2C,q3C),1)).toFloat()* 10); // Write pressureC value to app
Serial.print("|");
Serial.print((String(SensorD(p1D,p2D,p3D,p4D,p5D,q1D,q2D),1)).toFloat()* 10); // Write pressureD value to app
Serial.print("|");
Serial.println((String(average(),1)).toFloat()* 10);
delay(800);
Thanks a lot Patryk_F. I have tried what you advised. It works, hurrah. I am also trying ABGs approach. This time I don't see any thing on the app screen. Please find attached files. Testproject_230906.aia (3.0 MB)
Serial.println("A:" + String(SensorA(p1A,p2A,p3A,p4A,p5A,p6A,q1A,q2A),1)); // Write pressureA value to app
Serial.println("B:" + String(SensorB(p1B,p2B,p3B,p4B,p5B,p6B,q1B,q2B),1)); // Write pressureB value to app
Serial.println("C:" + String(SensorC(p1C,p2C,p3C,p4C,p5C,p6C,q1C,q2C,q3C),1)); // Write pressureC value to app
Serial.println("D:" + String(SensorD(p1D,p2D,p3D,p4D,p5D,q1D,q2D),1)); // Write pressureD value to app
Serial.println("mean:" + String(average(),1));
Thank you, the screen shots of the log were very informative and surprising.
Notice how each time stamped entry in the log can contain anywhere from 0 to several readings (B:06) separated by line feeds.
The code I supplied wrongly assumed the line feeds would be filtered out and would contribute to breaking items in the stringValues list properly.
Instead, the line feeds were treated no differently than | or comma delimiters (ignored.)
Furthermore, I see item breaks in the middle of numbers and in the middle of readings.
From what I see, this requires a different approach to dealing with the input stream, introducing a global string variable fed at its end from incoming stringValues items by concatenation, and depleted in front by splitting at application delimiters (line feeds.)
I think the line feed (empty line) is due to the delay or processing time in Arduino nano to start printing the sensor values on the serial monitor. I am also trying to somehow reduce this delay.