Hallo!
I have a problem with my Electron. If I want to use Particle.publish() my Electron goes into the SOS Mode. Can everybody help me with this Problem?
Here is my Code:
sprintf(
publishString,
"{\"bat\": %f, \"latitude\": %f, \"longitude\": %f}",
batteryPercent, latitude, longitude
);
Serial.write(publishString);
Particle.publish("boat_data", publishString, 60, PRIVATE);
Thanks!
How is the variable publishString declared? Also batteryPercent, latitude and longitude.
1 Like
Yes!
Here are my declaration:
char publishString[64];
float latitude;
float longitude;
float batteryPercent;
Yup, 64 seems too small, for three floats without limited precission.
Try "%.2f"
instead.
2 Likes
Ok! Tanks, but do you mean I should use â%.2fâ instead of 64?
I have tried this now:
float latitude = 0;
float longitude = 0;
float batteryPercent = 100;
sprintf(
publishString,
"{\"bat\": %.2f, \"lat\": %.2f, \"lon\": %.2f}",
batteryPercent, latitude, longitude
);
Serial.write(publishString);
Particle.publish("boat_data", "publishString");
It is also the same problem.
And where has your definition of publishString
gone?
BTW is your device breathing cyan when this happens?