I have a weird one. I have a Photon with with a ds18b20 temp sensor. It was working fine and every 30 seconds would publish the temp (F) to the particle cloud. It would also publish the correct temp each time. I do not know what changed but for some reason it is publishing the correct temp, then 32F, correct temp, then 32F. So every other time it publishes, the temp is 32F. Back and forth… I tried changing the delay in the code increasing and decreasing but that didn’t change anything except how often it publishes to the cloud. Regardless, it is always… 76, 32, 76, 32, 76, 32, 76, 32. I have tried replacing the resistor I have in the circuit and the sensor but still doing the same thing. It was working just fine in the beginning. Months later it started doing this. It also sends the data to Cayenne (mydecives.com). I commented that stuff all out to rule it out and made no difference.
Here is my code…
#define CAYENNE_PRINT Serial
#include "cayenne-particle.h"
#include "DS18.h"
int tempval = 0;
DS18 sensor(D0);
char auth[] = "[auth-key]";
void setup()
{
Particle.variable("temp", tempval);
Serial.begin(9600);
delay(5000); // Allow board to settle
Blynk.begin(auth);
Blynk.run();
}
void loop() // The loop is running the code that sends the sensor data to Cayenne. http://mydevices.com
{
// Blynk.run();
(sensor.read());
Serial.printf("Temperature %.2f C %.2f F ", sensor.celsius(), sensor.fahrenheit());
Particle.publish("Temperature", String(sensor.fahrenheit()));
Blynk.virtualWrite(V2, sensor.fahrenheit());
tempval = sensor.fahrenheit();
delay(10000);
}