Sending requests from Browser to Arduino has high latency

118 views Asked by At

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

1

There are 1 answers

3
Damodharan_C On

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