Hi.
I am doing my first steps with a LoRa device with the IoT cloud. By now, I can receive values from the board and show them on the dashboard.
Now I have created a variable to send down to the board. The variable ist an int with readwrite permission / update on change.
I have added the variable to the dashboard, as slider (and also tried the value selector). When I change the value, I see the changed value in the dashboard, but as soon as I reload it, the value is set back to 0. However, the read-only value (simple alive counter) updates correctly on the dashboard.
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/d88b0041-f295-4d49-834d-a4252390cbf8
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int downstream;
int rssi;
int test;
int upstream;
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"
//#include "LoRa.h"
unsigned long previousMillis = 0;
unsigned long previousMillisBlink = 0;
const long interval = 180000; //180 second interval (3 minutes)
const long intervalBlink = 1000; //180 second interval (3 minutes)
//const int ledPin = LED_BUILTIN; // the number of the LED pin
const int ledPin = 6; // the number of the LED pin
int ledState = LOW; // ledState used to set the LED
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(4);
ArduinoCloud.printDebugInfo();
pinMode(ledPin, OUTPUT);
}
void loop() {
ArduinoCloud.update();
// Your code here
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
test +=1;
Serial.print("counter value: ");
Serial.println(test);
// rssi = LoRa.packetRssi();
}
if (currentMillis - previousMillisBlink >= intervalBlink) {
previousMillisBlink = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
Serial.println("HIGH");
} else {
ledState = LOW;
Serial.println("LOW");
}
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
upstream = downstream;
//delay(1000);
}
Still looking through the code, but I remember that one time my read/write vars were always at zero. I think Arduino Cloud automatically sets vars to zero.
Create a new thing and new dashboard without assigning a device -> I can change readwrite variables in the dashboard
assigning my device to the thing (MKR WAN 1310, LoRa) -> I cannot change readwrite variables anymore
Detach the device from the thing -> I can change them again.
I don't have any other devices, but just tried to create a (non-existent) WiFi device and assign it to a dummy thing -> can change the values as well.
So is there any specific setting necessary for LoRaWan?