Good morning,
I'm doing a project with arduino mkr wifi 1010 and mkr iot carrier. The project is a smart garden where I monitor also the temperature, the air humidity and light. However I have a problem with the dashboard. Indeed, until some days ago everything seemed work properly: the dashboard comunicated well with the variables of my project. However now the variables linked seemed are not linked anymore, because the dashboard is stuck to the same values.
I have tried to create a new dashboard and a saw this message on widgets: "No data received yet".
I don't know if there is a problem in my code, anyway I attach the full code here:
#include "thingProperties.h"
#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;
int moistPin = A5;
int dry = 1023;
int wet = 0;
int timer = 3000;
String lightState;
String waterPumpState;
uint32_t lightsOn = carrier.leds.Color(82, 118, 115);
uint32_t lightsOff = carrier.leds.Color(0, 0, 0);
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
//enable only if you work with the pc
while (!Serial);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
//Get Cloud Info/errors , 0 (only errors) up to 4
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
//Wait to get cloud connection to init the carrier
while (ArduinoCloud.connected() != 1) {
ArduinoCloud.update();
delay(500);
}
CARRIER_CASE = true;
carrier.begin();
carrier.display.setRotation(0);
delay(1500);
}
void loop() {
ArduinoCloud.update();
//read temperature and humidity
temperature = carrier.Env.readTemperature();
humidity = carrier.Env.readHumidity();
Serial.print("T: ");
Serial.println(temperature);
//Update touch buttons
carrier.Buttons.update();
//function to print out values
if (carrier.Buttons.onTouchDown(TOUCH0)) {
printInfo();
}
if (carrier.Buttons.onTouchDown(TOUCH1)) {
printInfoRelays();
}
//read raw moisture value
int raw_moisture = analogRead(moistPin);
//map raw moisture to a scale of 0 - 100
moisture = map(raw_moisture, wet, dry, 100, 0);
//read ambient light
while (!carrier.Light.colorAvailable()) {
delay(5);
}
int none;
carrier.Light.readColor(none, none, none, light);
delay(100);
}
void onWaterpumpChange() {
int t=0;
while (waterpump == true && t <= timer){
carrier.Relay2.open();
waterPumpState = "PUMP: ON";
updateScreen();
//set timer [ms] to turn OFF the pump
delay(1000);
t=t+1000;
}
waterpump = false;
carrier.Relay2.close();
waterPumpState = "PUMP: OFF";
updateScreen();
}
void onArtificialLightChange() {
if (artificial_light == true) {
carrier.leds.fill(lightsOn, 0, 5);
carrier.leds.show();
lightState = "LIGHTS: ON";
} else {
carrier.leds.fill(lightsOff, 0, 5);
carrier.leds.show();
lightState = "LIGHTS: OFF";
}
updateScreen();
}
//Update displayed Info
void printInfo(){
carrier.display.fillScreen(ST77XX_BLACK);
carrier.display.setTextColor(ST77XX_WHITE);
carrier.display.setTextSize(2);
carrier.display.setCursor(40, 60);
carrier.display.print("Water: ");
carrier.display.print(moisture);
carrier.display.println("%");
carrier.display.setCursor(40, 80);
carrier.display.print("T: ");
carrier.display.print(temperature);
carrier.display.println("C");
carrier.display.setCursor(40, 100);
carrier.display.print("Hum: ");
carrier.display.print(humidity);
carrier.display.println("%");
}
void printInfoRelays(){
carrier.display.fillScreen(ST77XX_BLACK);
carrier.display.setTextColor(ST77XX_WHITE);
carrier.display.setTextSize(3);
carrier.display.setCursor(40, 50);
carrier.display.print(waterPumpState);
carrier.display.setCursor(40, 90);
carrier.display.print(lightState);
}
//Update carrier screen
void updateScreen(){
printInfoRelays();
}
Thanks in advance for who can help me!
Lorenzo!