Thank you for taking the time to submit your bug/issue! Please use the points below as a guide when submitting.
-
Device & model you are using (Ex: Pi 2 Model B or Arduino Uno with W5100 ethernet shield)
ESP32-DevKitC -
What dashboard are you using? (Web, iOS, Android)
Web -
Please describe the bug / issue as detailed as possible. Attaching the code and any relevant screenshots would be very helpful!
When I check the data plots from “details and chart”, data other than the last one is not displayed.
Data that was previously displayed will not always be displayed when the latest data is added.
In another topic, it was commented that this symptom can be avoided by using a “custom button” and specifying the display date and time.
However, I tried that and it did not improve the problem.
When I checked the values in “Data”, I could see the data for the period not shown in the plot.
I am running two sensors with the same configuration, and they both have the same symptoms.
I am very troubled because the main purpose of using this product was to check the data in the plot.
I don’t want to lose access to past data, so if possible, please let me know what to do other than resetting.
<Arduino sketch>
/*
This example sketch shows how a value can be sent from the Arduino to the Cayenne Dashboard at specified intervals.
The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
Steps:
1. Set the Cayenne authentication info to match the authentication info from the Dashboard.
2. Compile and upload the sketch.
3. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
NOTE:
For this example you'll need SimpleTimer library:
https://github.com/jfturcot/SimpleTimer
Visit this page for more information:
http://playground.arduino.cc/Code/SimpleTimer
*/
//OTA設定
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
//Cayenne設定
#define CAYENNE_DEBUG
#include <CayenneMQTTESP32.h>
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <SimpleTimer.h>
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "*****";
char MQTTpassword[] = "*****";
char clientID[] = "*****";
boolean onlineStatus = false; //オンラインステータス
//Cayenne オンラインステータス
CAYENNE_CONNECTED() {
onlineStatus = true;
}
CAYENNE_DISCONNECTED() {
onlineStatus = false;
}
// simple timerで割り込ませる操作(データ送信)
SimpleTimer timer;
//wifi設定
const char* ssid = "*****";
const char* Password = "*****";
//AE-TSL2572設定
#include "AE_TSL2572.h"
AE_TSL2572 TSL2572;
float lx = 0; // 照度格納
//ゲイン 0~ 5 (x0.167 , x1.0 , x1.33 , x8 , x16 , x120)
byte gain_step = 1;
//積分時間のカウンタ(0xFFから減るごとに+2.73ms)
//0xFF: 1サイクル(約 2.73ms)
//0xDB: 37サイクル(約 101ms)
//0xC0: 64サイクル(約 175ms)
//0x00:256サイクル(約 699ms)
byte atime_cnt = 0xC0;
//SHT20測定設定
#include <Wire.h>
#include "DFRobot_SHT20.h"
DFRobot_SHT20 sht20;
unsigned long previousMillis = 0;
float humd = 0; // 湿度格納
float temp = 0; // 温度格納
//SHT20測定間隔
unsigned long interval = 5000L;
//OLED 設定
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//WiFiCheck 設定
int lpcnt=0 ; // WiFi 再接続回数カウント
unsigned long previousMillis2 = 0;
unsigned long interval2 = 60000UL; // WiFi 再接続間隔
//センサーデータ取得と表示
void measCH()
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
humd = sht20.readHumidity(); // Read Humidity
temp = sht20.readTemperature(); // Read Temperature
lx = TSL2572.GetLux16(); // Read lx
TSL2572.SetGainAuto(); //TSL2572自動ゲイン調整
Serial.print("Time:");
Serial.print(millis());
Serial.print(" Temperature:");
Serial.print(temp, 1);
Serial.print("C");
Serial.print(" Humidity:");
Serial.print(humd, 1);
Serial.print("%");
Serial.print(lx, DEC);
Serial.println("Lx");
//OLED表示
display.clearDisplay();
display.setCursor(0,0);
display.println("Temperature:");
display.print(temp, 1);
display.print(" ");
display.cp437(true);
display.write(167);
display.println("C");
display.println("Humidity:");
display.print(humd, 1);
display.println(" %");
display.println("Lux:");
display.print(lx, 1);
display.println(" Lx");
display.print("Wifi: ");
if (WiFi.status() == WL_CONNECTED) {
display.println("Online");
}
else {
display.println("Offline");
}
display.print("Iot: ");
if ( onlineStatus == true) {
display.println("Online");
}
else {
display.println("Offline");
}
display.display();
}
}
//WiFi接続確認と本体リセット
void WiFiCheck()
{
unsigned long currentMillis2 = millis();
// if WiFi is down, try reconnecting
if ((WiFi.status() != WL_CONNECTED) && (currentMillis2 - previousMillis2 >=interval2)) {
previousMillis2 = currentMillis2;
WiFi.disconnect(); //
WiFi.begin(ssid, Password); //
if (WiFi.waitForConnectResult() == WL_CONNECTED) {
lpcnt = 0 ; // 接続できれば再接続の回数をリセット
} else {
lpcnt += 1 ; // 接続出来なければ再接続の回数をカウント
} //
if (lpcnt > 5) { // 5回 接続できなければ、
ESP.restart() ; // ソフトウェアリセット
} //
}
}
void UpData()
{
// Send values using the virtualWrite function. Cayenne currently accepts int and float values.
// Please don't send more that 10 values per second.]
Cayenne.virtualWrite(0, millis() / 1000);
Cayenne.virtualWrite(1, temp, "temp", "c ");
Cayenne.virtualWrite(2, humd, "rel_hum", "p ");
Cayenne.virtualWrite(3, TSL2572.GetLux16(), "lum", "lux ");
}
void setup()
{
// 以下OTA set up
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, Password);
// Port defaults to 3232
// ArduinoOTA.setPort(3232);
// Hostname defaults to esp3232-[MAC]
// ArduinoOTA.setHostname("myesp32");
// No authentication by default
// ArduinoOTA.setPassword("admin");
// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
ArduinoOTA
.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = "sketch";
else // U_SPIFFS
type = "filesystem";
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
//以下OLEDセットアップ
pinMode(21, INPUT_PULLUP); //デファルトのSDAピン21 のプルアップの指定
pinMode(22, INPUT_PULLUP); //デファルトのSDAピン22 のプルアップの指定
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Clear the buffer and setting
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(WHITE);
// 以下Cayenne set up
Cayenne.begin(username, MQTTpassword, clientID, ssid, Password);
// Cayenneへのデータアップロード間隔を設定
timer.setInterval(600000UL, UpData);
//以下AE-TSL2572 set up
Wire.begin();
if (TSL2572.CheckID()) {
//ゲインを設定
TSL2572.SetGain(gain_step);
//積分時間を設定
TSL2572.SetIntegralTime(atime_cnt);
//計測開始
TSL2572.Reset();
delay(100);
}
else {
Serial.println("Failed. Check connection!!");
while (1) {}
}
//以下SHT20 set up
Serial.println("SHT20 Example!");
sht20.initSHT20(); // Init SHT20 Sensor
delay(100);
sht20.checkSHT20(); // Check SHT20 Sensor
}
void loop()
{
//OTAアップデートの実行を処理
ArduinoOTA.handle();
//Cayenneのメインループ
Cayenne.loop(); // Runs main loop
WiFiCheck();
measCH();
timer.run(); // Initiates SimpleTimer
}