I have an Arduino UNO R4 WiFi connected to the cloud.
I have created a variable for CO2 concentration in the “ThingProperties.h” tab, when I Serial.print the variable to the monitor, the resulting value is displayed exactly on the monitor.
However, in the Arduino Cloud dashboard, the value of Value keeps updating with 0.
Why does it keep showing up as 0?
The Sketch code is below.
①~~.ino
#include "thingProperties.h"
#include <Wire.h>
#include "SparkFun_ENS160.h"
SparkFun_ENS160 myENS;
int ensStatus;
void setup() {
// シリアル通信開始
Serial.begin(9600);
delay(1500);
// thingProperties.h で定義されたプロパティを初期化
initProperties();
// Arduino IoT Cloud に接続
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
// デバッグ情報
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
// ENS160 センサーの初期化
Wire.begin();
if( !myENS.begin() ) {
Serial.println("Could not communicate with the ENS160, check wiring.");
while(1);
}
// センサーのリセット
if( myENS.setOperatingMode(SFE_ENS160_RESET) )
Serial.println("Ready.");
delay(100);
// 標準動作モードに設定
myENS.setOperatingMode(SFE_ENS160_STANDARD);
}
void loop() {
// Arduino IoT Cloud の更新
ArduinoCloud.update();
// ENS160 のデータ取得
if( myENS.checkDataStatus() ) {
Serial.println((float)myENS.getECO2(), 2); // float型の数値のみ表示 (小数点以下2桁)
}
delay(1000);
}
②thingProperties.h
// Code generated by Arduino IoT Cloud, DO NOT EDIT.
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_OPTIONAL_PASS; // Network password (use for WPA, or use as key for WEP)
float co2censor02;
void initProperties(){
ArduinoCloud.addProperty(co2censor02, READ, 1 * SECONDS, NULL);
}
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
Does anyone have any ideas on this?
Best regards.
NOBU