Hello, I'm trying to establish communication between my MKRWAN 1300 and the Arduino IoT, but I can only communicate in one direction (Arduino to IoT).
When I use the dashboard and change the value of a variable with the MKR, I have to refresh the page (F5) to see the new value on the dashboard.
And if I change the value of a variable with the dashboard, I never receive it with the MKR.
I'm using the Free plan (on Arduino IoT Cloud).
My card is not a clone, and this is not a hardware problem (I've already done the test).
Here is my code :
main.ino :
#include "thingProperties.h"
unsigned long previousMillis = 0;
unsigned long previousWait1 = 0;
unsigned long previousWait2 = 0;
const long interval = 60000; //60 second interval
const int wait = 500; // wait 500 ms
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, false);
/*
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();
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
previousMillis = currentMillis;
test += 1;
}
}
/*
Since Weather is READ_WRITE variable, onWeatherChange() is
executed every time a new value is received from IoT Cloud.
*/
void onWeatherChange()
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
unsigned long currentMillis = millis();
if (currentMillis - previousWait1 >= wait)
{
previousWait1 = currentMillis;
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
}
}
/*
Since Lux is READ_WRITE variable, onLuxChange() is
executed every time a new value is received from IoT Cloud.
*/
void onLuxChange()
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
unsigned long currentMillis = millis();
if (currentMillis - previousWait2 >= wait)
{
previousWait2 = currentMillis;
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
}
}
thingProperties.h :
// Code generated by Arduino IoT Cloud, DO NOT EDIT.
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
#include "App.h"
const char THING_ID[] = "ca62b1cb-5603-47c5-ba88-1d59a7994562";
const char APPEUI[] = SECRET_APP_EUI;
const char APPKEY[] = SECRET_APP_KEY;
void onWeatherChange();
void onLuxChange();
String weather;
int lux;
int test;
void initProperties(){
ArduinoCloud.setThingId(THING_ID);
ArduinoCloud.addProperty(weather, 2, READWRITE, ON_CHANGE, onWeatherChange);
ArduinoCloud.addProperty(lux, 3, READWRITE, ON_CHANGE, onLuxChange);
ArduinoCloud.addProperty(test, 1, READ, ON_CHANGE, NULL);
}
LoRaConnectionHandler ArduinoIoTPreferredConnection(APPEUI, APPKEY, _lora_band::EU868);
App.h contains just my App_EUI and my App_KEY
and my dashboard : (my variables are well linked )
Thank you for taking the time to read my problem.