简体   繁体   中英

Sending requests from Browser to Arduino has high latency

I have an Arduino Yun connected via the ESP8266 wifi with my laptop. Allowed cross origin data stream to get data from the Arduino using http requests.

The problem with http requests is that it depends on the speed in which the ESP8266 chip can process the request. It's about 750ms.

But what I'm trying to achieve is lightning fast wiresless response between the Arduino and my browser. Is there an alternative?

My javascript code to send data is:

sendToArduin(pin,val){
  // send value to pin
}

And to retrieve data:

requestFromArduino(){
  // returns json string filled with pin>val
}

In a nutshell: I have 6 pins declared as input and 6 pins declared as output. I want the data to fill my javascript variable as real time as possible. (low ms)

Thanks

Try using MQTT protocol - lightweight messaging protocol with high latency

There are many free mqtt brokers you can use. Check the below link

http://www.hivemq.com/blog/how-to-get-started-with-mqtt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM