bug fix arduino code
Budget: €8 – €30 EUR
Arduino reads text data from a web site. It all worked fine till a recent change in the layout of the data.
OLD:
A value was represented as a 3 digit number (interpreted as integer)
077|20:25
086|20:30
948|20:35
NEW
..... a number with decimals or a number without decimals:
77,6329598612474|20:25
86,6329598612474|20:30
948|20:35
<sample of made up data, see logging for full data>
The integer values '77' , "86" and "948" are needed plus the time
The Arduino code gets the number by reading the value taking the 3 positions left from the delimiter, however that doesn't work anymore as the values have different lengths now.
Hardware in use:
- ESP8266 to grab data from web site and pass through via serial to Arduino Mega
- Arduino mega which receives the raw data; interprets it and steers stepper motors
- Seven 28BYJ-48 Stepper Motors each with own ULN2003 driver.
My assumption is that the crux of the issue is in this part of the Arduino_code:
String currentLine = newData.substring(newData.indexOf("|") - 3 + linesCount * 10 , newData.indexOf(":") + 3 + linesCount * 10);
if (currentLine.length() == 9 && currentLine.indexOf("|") == 3)
{
old_rain_value[linesCount] = rain_value[linesCount];
rain_value[linesCount] = currentLine.substring(0, currentLine.indexOf("|")).toInt();
time1_values[linesCount] = currentLine.substring(currentLine.indexOf("|") + 1);
linesCount++;
}
Requested:
Update the code so the stepper motor update is again working as before the change of the web data.
See files uploaded for more info on loggings and source codes.
Time line: no fixed date, no rush.
OLD:
A value was represented as a 3 digit number (interpreted as integer)
077|20:25
086|20:30
948|20:35
NEW
..... a number with decimals or a number without decimals:
77,6329598612474|20:25
86,6329598612474|20:30
948|20:35
<sample of made up data, see logging for full data>
The integer values '77' , "86" and "948" are needed plus the time
The Arduino code gets the number by reading the value taking the 3 positions left from the delimiter, however that doesn't work anymore as the values have different lengths now.
Hardware in use:
- ESP8266 to grab data from web site and pass through via serial to Arduino Mega
- Arduino mega which receives the raw data; interprets it and steers stepper motors
- Seven 28BYJ-48 Stepper Motors each with own ULN2003 driver.
My assumption is that the crux of the issue is in this part of the Arduino_code:
String currentLine = newData.substring(newData.indexOf("|") - 3 + linesCount * 10 , newData.indexOf(":") + 3 + linesCount * 10);
if (currentLine.length() == 9 && currentLine.indexOf("|") == 3)
{
old_rain_value[linesCount] = rain_value[linesCount];
rain_value[linesCount] = currentLine.substring(0, currentLine.indexOf("|")).toInt();
time1_values[linesCount] = currentLine.substring(currentLine.indexOf("|") + 1);
linesCount++;
}
Requested:
Update the code so the stepper motor update is again working as before the change of the web data.
See files uploaded for more info on loggings and source codes.
Time line: no fixed date, no rush.