Dashboard requiring screen refresh to show updated values

I am working with a class using the IoT Rev 2 kits. Unfortunately, due to my school's network restrictions, students are using my phone's hotspot to connect their MKR-Wifi 1010 devices. However they are using the school network to connect to the cloud with their laptops.

This all works perfectly well except that the variables being displayed on the dashboard do not update unless they refresh the page. They also cannot use switches on their dashboard to interact with the device.

I presume that the reason for this is because the laptop and device are on different networks. When I connect the laptop to my hotspot as well, everything works as expected.

If this is the cause of the issue, I am not clear on why since both the laptop and Arduino device are accessing variables in the Cloud. Is it possible that there may be another browser or network setting that is causing this issue?

Any assistance you can provide would be much appreciated. Below is some code I am using to test:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "TK Counter"
  https://create.arduino.cc/cloud/things/afdab4ab-8b32-4669-be3f-c812bcdf8a54 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  int count;

  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 <Arduino_MKRIoTCarrier.h>

MKRIoTCarrier carrier;

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();
  carrier.noCase();
  carrier.begin();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  carrier.Buttons.update();

// Verify your thresholds
if (carrier.Buttons.getTouch(TOUCH0)) {
  Serial.println("touching 0");
  count++;                              //Increment the button0 variable in the cloud when the button is touched.
  delay(500);
}
  Serial.println(count);
  delay(500);
  
}

/*
  Since Count is READ_WRITE variable, onCountChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onCountChange()  {
  // Add your code here to act upon Count change
  
}

Here is my thingProperties.h:

// Code generated by Arduino IoT Cloud, DO NOT EDIT.

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

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_OPTIONAL_PASS;    // Network password (use for WPA, or use as key for WEP)

void onCountChange();

int count;

void initProperties(){

  ArduinoCloud.addProperty(count, READWRITE, ON_CHANGE, onCountChange);



}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Hi @kempti,

It seems to be a network problem.
You cannot see data on the dashboard because the device is offline or because your laptop doesn't have access to the Internet.

When you refresh the page, you see the last data sent by the device to the Cloud, but they are not live data; it is a bit strange because if you cannot access to the Internet, you shouldn't see any data, but probably the connection is flaky and so you see the data stored in the browser cache in a moment which the laptop was able to access to Internet.

There are no constraints on the network to use for Arduino devices and Cloud, they don't need to be connected to the same network, so probably the problem is on the laptop network.

Let me know if you need other investigations.

Thanks,

Stefano

Thanks for your reply Stefano

The device is definitely connected to the network because I can see that the cloud variable is being updated.
The laptop is also connected to the network with no issues. I also have a good strong network connection on the laptop. The updated data is displayed as soon as I refresh the screen.

TK

Does the sketch work on a NORMAL network outside the school? If it doesn't, it's coded incorrectly.

Hi @kempti,

The problem could be the network to which the laptop is connected.
Could you check if port 8443 is blocked in the network settings?
This is the port used by the Arduino dashboards to get live data.

Let me know, thanks.

Stefano

1 Like

Thanks Stefano! Port 8443 was blocked. Our network administrators unblocked it and it works perfectly.

regards
Tim

1 Like