Remote IoT-Does not reflect actual state of the OUTPUTS

To get me familiar with the OPLA Kit. I am using the Smart Garden project. I find that the Remote IoT app works well in turning ON/OFF all the Outputs. However, if the app is not used for a while or I start it after a few minutes. The Remote IoT app does not reflect the actual Output Status. Any feedback?

That is controlled by your code. It is in the lines below??? OOPS I cannot see it. Post your code following forum guidelines and also post a Schematic of how you have it wired.

THIS IS THE CODE:
This is a smaller version of the Smart Garden Code provided in the OPLA website. I just chopped what I did not need. I'm planning (or are in the process) to add additional code. But I stopped because sometime the Dashboard does not reflect the real Pump State. It always controls it but some times fails to reflect its stage.
I hop you can help me. Thank thank !

// LIBRARIES
#include "thingProperties.h"
#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;

//DEFENITIONS
int water_level_Pin = A5; //The Capasitive water sensor is connected to Analo Input 5
int raw_water_level;      // This is the variable to hold the raw number from the Analog Input 5.  0 to 1023
bool start_monitor;        // This is a ON/OFF selector switch from the Dashboard to start monitoring the Tray Filling
// and to start the timer to keep track of the time it takes for the tray to get full.
String waterPumpState;    // This variable checkS whether the Ralay2 is CLOSED or OPEN, so it can be displayed on the dashboard


uint32_t lightsOn = carrier.leds.Color(82, 118, 115); // This set the color of the LEDs when ON
uint32_t lightsOff = carrier.leds.Color(0, 0, 0);     // This set the colod of the LEDs when OFF


// COMMUNICATION INITIALIZATION

void setup()

{
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // 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);
  }

  delay(500);
  CARRIER_CASE = true;
  carrier.begin();
  carrier.display.setRotation(2);
  delay(1500);
}

// MAIN LOOP
void loop()

{
  //Update the Cloud
  ArduinoCloud.update();

  //read raw_water_level value
  int raw_water_level = analogRead(water_level_Pin);
  int waterlevel;

  //map raw_water_level to a scale of 0 - 100
  water_Level = map(raw_water_level, 0, 1023, 100, 0);

  delay(100);

}


void onWaterpumpChange() {
  if (water_Pump == true) {
    carrier.Relay2.open();
    waterPumpState = "PUMP: ON";
  }
  else
  {
    carrier.Relay2.close();
    waterPumpState = "PUMP: OFF";
  }
  updateScreen();
}

//Update displayed Info
void updateScreen()
{
  carrier.display.fillScreen(ST77XX_RED);
  carrier.display.setTextColor(ST77XX_WHITE);
  carrier.display.setTextSize(3);
  carrier.display.setCursor(40, 50);
  carrier.display.print(waterPumpState);

}

/*
  Since WaterPump is READ_WRITE variable, onWaterPumpChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onWaterPumpChange()  {
  // Add your code here to act upon WaterPump change
}

=========================================

THIS THE CODE PRODUCED BY THE ARDUINO IoT CLOUD

// 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_PASS;    // Network password (use for WPA, or use as key for WEP)

void onWaterPumpChange();

int water_Level;
bool water_Pump;

void initProperties(){

 
  ArduinoCloud.addProperty(water_Pump, READWRITE, ON_CHANGE, onWaterPumpChange);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Further more......
More indication that this Arduino IoT Cloud is not reliable AT ALL!
In the Dashboard I have two switches , on of them is Bool/water_Pump. This selector switch was not touched a single time during the evening. Look how the stage of the switch changes randomly during the night all by itself!

time value
2022-10-05T00:05:56.48Z TRUE
2022-10-05T00:06:51.077Z FALSE
2022-10-05T00:06:53.463Z FALSE
2022-10-05T00:14:23.111Z TRUE
2022-10-05T00:16:06.27Z TRUE
2022-10-05T00:18:00.957Z TRUE
2022-10-05T00:21:39.109Z TRUE
2022-10-05T00:23:11.462Z FALSE
2022-10-05T00:23:13.645Z FALSE
2022-10-05T00:23:48.185Z TRUE
2022-10-05T00:23:49.299Z FALSE
2022-10-05T00:23:51.307Z FALSE
2022-10-05T00:58:46.682Z TRUE
2022-10-05T00:58:49.664Z TRUE
2022-10-05T00:58:52.553Z FALSE
2022-10-05T00:58:55.11Z FALSE
2022-10-05T00:59:07.639Z TRUE
2022-10-05T00:59:09.846Z TRUE
2022-10-05T01:13:43.867Z FALSE
2022-10-05T01:16:01.774Z FALSE
2022-10-05T01:17:29.984Z FALSE
2022-10-05T01:19:23.235Z TRUE
2022-10-05T01:19:25.937Z TRUE
2022-10-05T01:24:37.808Z FALSE
2022-10-05T01:24:39.783Z FALSE
2022-10-05T01:24:54.362Z FALSE
2022-10-05T01:26:33.676Z FALSE
2022-10-05T01:44:15.869Z FALSE
2022-10-05T01:44:59.704Z TRUE
2022-10-05T01:45:03.255Z TRUE
2022-10-05T01:45:03.833Z FALSE
2022-10-05T01:45:05.954Z FALSE
2022-10-05T02:17:55.043Z TRUE
2022-10-05T02:17:56.191Z FALSE
2022-10-05T02:19:39.35Z TRUE
2022-10-05T02:45:46.225Z FALSE
2022-10-05T02:45:46.684Z FALSE
2022-10-05T02:45:56.19Z TRUE
2022-10-05T02:45:58.357Z TRUE
2022-10-05T03:09:19.835Z TRUE
2022-10-05T03:09:30.753Z FALSE
2022-10-05T03:09:32.852Z FALSE
2022-10-05T03:12:55.862Z TRUE
2022-10-05T03:12:57.805Z TRUE
2022-10-05T12:32:51.302Z FALSE
2022-10-05T12:32:53.083Z TRUE
2022-10-05T12:32:53.45Z FALSE
2022-10-05T12:32:55.043Z TRUE
2022-10-05T13:06:16.719Z TRUE

This is crazy!
Any feedback???

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.