I have recently started playing around with the Mkr series Lora module together with the Arduino cloud features.
No issues with connection, and sending data from the device to a dashboard on the cloud works well.
However, if I try to set up an onChange variable it only seems to execute the onChange function on the first start up run.
Simplified Code:
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/e22d0a2e-d860-4385-afbe-eba73037fce2
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
bool testSetting;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
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);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
Serial.println(testSetting);
delay(500);
}
/*
Since TestSetting is READ_WRITE variable, onTestSettingChange() is
executed every time a new value is received from IoT Cloud.
*/
void onTestSettingChange() {
// Add your code here to act upon TestSetting change
Serial.println("Test Setting changed");
}
If I change the variable: testSetting in my dashboard, while the code is running, nothing happens (as in the loop runs, but the onChange function is not called). If I then restart the board the function is called once, reading the new testSetting value. So basically, the onChange function is only called on startup, not on Change as it should.
The exact same code runs flawlessly on a GSM module. And yes, the Wan has a confirmed connection to the LoRa network in the above scenario.
Seems to be a bug with the arduino.update function for the Wan 1310 setup.