Hello everyone,
I’m encountering an issue where the Arduino Opta suddenly reboots (non-watchdog reboots) under certain conditions. Specifically, the reboots occur when:
• A relay is turned on/off via the API or a dashboard widget (there is a need to turn it on/off min. 1-3 times, sometimes more).
• All of the following code elements are present:
- Setting a property under the resource Input.
- Reading and/or setting a property within the loop() function.
- The watchdog timer is enabled.
If any of these elements is omitted, the reboots do not occur.
Here’s the code to reproduce the issue:
#define THINGER_SERIAL_DEBUG
#define THINGER_SERVER "acme.aws.thinger.io"
#include <ThingerMbedEth.h>
#include <ThingerPortentaOTA.h>
#include "arduino_secrets.h"
// Define the watchdog timeout
#define WATCHDOG_TIME_MS 10000
// Get the instance of the Watchdog
mbed::Watchdog& watchdog = mbed::Watchdog::get_instance(); // Required element 3
ThingerMbedEth thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
ThingerPortentaOTA ota(thing);
int propertyValue2 = 1;
bool isThingerAuthenticated = false; // Status if connected to Thinger.io
void setup() {
Serial.begin(115200);
// configure leds for output
pinMode(LED_D0, OUTPUT);
pinMode(LED_D1, OUTPUT);
pinMode(LED_D2, OUTPUT);
pinMode(LED_D3, OUTPUT);
pinMode(LEDR, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
// configure relays for output
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(D3, OUTPUT);
// Set state listener to update authentication status
thing.set_state_listener([](ThingerClient::THINGER_STATE state) {
isThingerAuthenticated = (state == ThingerClient::THINGER_AUTHENTICATED);
});
thing["relay_1"] << [](pson& in) {
if (in.is_empty()) {
in = (bool)digitalRead(D0);
} else {
digitalWrite(D0, in ? HIGH : LOW);
digitalWrite(LED_D0, in ? HIGH : LOW);
// Required element 1 start
pson set_prop;
set_prop["variable"] = false;
thing.set_property("varStatus", set_prop, true);
// Required element 1 end
}
};
// start thinger on its own task
thing.start();
// Start the watchdog timer
watchdog.start(WATCHDOG_TIME_MS); // Required element 3
}
void loop() {
watchdog.kick(); // Required element 3
if (isThingerAuthenticated) {
// Required element 2 start
pson send_data;
send_data["propertyValue1"] = 1;
thing.set_property("property_data", send_data, true);
pson read_data;
thing.get_property("property_data2", read_data);
propertyValue2 = read_data["propertyValue2"];
// Required element 2 end
}
delay(2000);
}
Has anyone experienced a similar problem or can offer insights into why this might be happening? Any assistance would be greatly appreciated.
Thank you!