Newbie question but how can I handle a scenario where i have a sensor going bad and producing a 0 output that then gives me a divide by zero error. I don’t want it to cause my publish to break, but i do want to know that its gone bad and isn’t reading anymore.
VRL = ads.readADC_SingleEnded(0)*(5/1666.0); //convert bits to volts
Rs = ((5*RL)/VRL)-RL; //Use formula to get Rs value (from datasheet)
this then breaks my publish to ubidots.
char data[80];
snprintf(data, sizeof(data)
, "{ \"H\" : %.1f, \"T\" : %.1f, \"C\" : %.1f, \"P\" : %.1f, \"L\" : %.1f }"
, humidity
, temp1
, co2avg
, ppm
, luxvalue
);
//PUBLISH TO CLOUD
Particle.publish("Ubidots", data, PRIVATE);
this is what my string looks like coming into the event console:
{ "H" : 61.1, "T" : 73.0, "C" : 1082.0, "P" : nan, "L" : 24.0 }