This is my first time to use Lot Cloud. I tried blinker, but when I click the switch, it takes more than 2 seconds to respond. It is the same when it is turned off or on.
from China.
need help.
thanks very much!
2 seconds over the internet is not that bad of a response time.
But, in my country, some similar platforms responded quickly.
Then why not use those brokers that respond quicker?
If you want fast MQTT Broker thingies use your own Broker. Me, I use My own MQTT Broker that is doing up to 800 payloads a second. A public Broker has 1000's of clients that is being serviced. Your payload requests with a public broker, get put into a queue and it becomes a FIFO kind of thing.
thanks! At first, I thought it might be that Arduino didn't set up a server in China (it would be good if I could confirm it, but I couldn't find the address with Ping. The address was protected). I tried again, and it was a little faster than the morning. Maybe it was the queue problem you said. Thanks again!
Could you please give us more detailed information about your setup?
- Board
- Connectivity method and configuration
- Sketch
I just tried according to the example of arduinod. At the same time, I also used similar platforms in China. The difference in reaction speed is obvious.
I have a very important discovery. Please see the comment of delay() in the code.
ESP32 Dev Module
#include "thingProperties.h"
int LED = 2;
void setup() {
pinMode(LED, OUTPUT);
// 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
random_value = random(0, 500);
onLedSwitchChange();
//delay(500);
/*look here!!! look here! At first, I didn't pay attention to this delay function. Just now I tested it
again. The speed is much faster, but it is still not as fast as the Chinese platform.
I Ping Arduino's website, and its response time is 240ms, more than four times that of similar platforms in China. There is also the switch button of the meter, which can not be pressed
continuously and quickly (with animation delay), which is different from China. Which results
in the lamp not being switched on and off quickly.
*/
}
void onLedSwitchChange() {
// Do something
if (led_switch) {
digitalWrite(LED, HIGH);
}
else {
digitalWrite(LED, LOW);
}
}
Please look at the post #12.
you are not supposed to invoke onLedSwitchChange();
in the loop
.
This is an automated callback issued when the state of an online property/variable changes.
You only need to invoke ArduinoCloud.update();
(as you do) at the beginning of the loop
.
As you have guessed, any delay(X)
will cause the loop
to stop at that point, introducing further lag.
Arduino IoT Cloud is designed to be running freely in the loop via a set of state machines which govern its inner workings
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.