Hello,
Please format your code:
https://discourse.processing.org/faq#format-your-code
I used simulated data here and only had to remove 1 character which was the line feed ( ‘\n’).
I may be going off topic here.
Start another one if you want to continue this.
Please provide a small snippet of the Arduino code and please format properly for the forum.
Some test code without the Arduino sending:
Test Code
String s;
void setup()
{
//s = "v1m1v1m2v1m3v1m4/n";
char LF = '\n'; // 1 character
//Serial.println(“v1m123”);
s = "v1m123" + LF; // 6 characters + 1 character for LF (line feed)
testData(s);
}
void testData (String s)
{
String delim = "v1m";
int l1;
//String deviceData = trim(s);
String deviceData = s;
if(deviceData.indexOf(delim) == 0)
{
l1 = deviceData.length();
String Adata = deviceData.substring(3, l1-1); //-1 for LF
//Extract only the numerical values, I do not know why I
//have to subtract 2 characters from the length instead of just 1 in order to get int() to work?????
println(Adata);
int sensorValue = int(Adata);
println(sensorValue);
}
else
{
String debugMsg = deviceData;
print(debugMsg);
}
}
Here is another topic that may be of interest:
Serial plotter over bluetooth - #11 by glv
Arduino can send data that is comma delimited (or other delimiter) and terminated with a line feed (or other terminator) and Processing can receive and split it.
:)