IoT dashboard - not able to change variables

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.

Are there any hints what I did wrong?

Does your code set the read/write values to anything?
I might be able to help if you post your code.

I can post my code, but doubt that this is relevant. It even does not work if I switch off the device and the connection is lost.

thingsProperties.h

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>


const char THING_ID[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

const char APPEUI[]   = SECRET_APP_EUI;
const char APPKEY[]   = SECRET_APP_KEY;

void onDownstreamChange();

int downstream;
int rssi;
int test;
int upstream;

void initProperties(){
  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(downstream, 2, READWRITE, ON_CHANGE, onDownstreamChange);
  ArduinoCloud.addProperty(rssi, 4, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(test, 1, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(upstream, 3, READ, ON_CHANGE, NULL);

}

LoRaConnectionHandler ArduinoIoTPreferredConnection(APPEUI, APPKEY, _lora_band::EU868);

sketch:

/* 
  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.

Now I found out some "pattern":

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?

Hello @asminator we found a regression and it is now fixed. Can you please try again and report if it is working for you?

Thanks,

Mattia

Wow, this was quick. Yes, now I can move the slider and the value stays when reloading the dashboard

Great, thanks for the feedback!

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