I am using an ESP8266 12E with a waterproof ds18b20 sensor to monitor a fish tank. When the widget initially displays it appears to show Celsius values (24.6 for example) although it is set for Fahrenheit (and displays “Fahrenheit” at the bottom of the widget. I refresh the dashboard and the display refreshes and shows the “correct” temperature. A few seconds latter the display “automagically” changes back to displaying Celsius values while still showing “Fahrenheit” for the label. I have attached a link to a youtube vid showing the issue: - YouTube . The same widget on my phone shows the correct values all of the time. This would just be an annoyance except I have a trigger set to email me if the temperature falls below 60 degrees Fahrenheit. When the displayed values go to “Celsius (24.6 for example)” it triggers the alert and emails me.
Here is the code I’m running:
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct board and BAUD rate before compiling.
//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#include <CayenneMQTTESP8266.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
// Data wire is conntec to the Arduino digital pin 4
#define ONE_WIRE_BUS 4
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature DS18B20(&oneWire);
// WiFi network info.
char ssid = “XXXXXX”;
char wifiPassword = “XXXXXXXXX”;
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “XXXXXXXXXX”;
char password = “XXXXXXXXXX”;
char clientID = “XXXXXXXXXX”;
unsigned long lastMillis = 0;
void SetupDS18B20(){
DS18B20.begin();
}
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}
void loop() {
Cayenne.loop();
}
// Default function for sending sensor data at intervals to Cayenne.
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here.
DS18B20.requestTemperatures();
//Read temperature from DS18b20
float tempC = DS18B20.getTempCByIndex(0);
Cayenne.celsiusWrite(1, tempC);
//Switch wifi and wait
//WiFi.disconnect();
//WiFi.forceSleepBegin();
delay(6000);
//Switch wifi on again
//WiFi.mode(WIFI_STA);
//WiFi.begin(ssid, wifiPassword);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(200);
}
}
// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
//CAYENNE_LOG(“Channel %u, value %s”, request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);
}
Any idea why the widget changes for no apparent reason? Also, when the device sends the next packet/message the display remains displaying Celsius values until I manually refresh the dashboard.