简体   繁体   English

将请求从浏览器发送到Arduino具有高延迟

[英]Sending requests from Browser to Arduino has high latency

I have an Arduino Yun connected via the ESP8266 wifi with my laptop. 我的笔记本电脑通过ESP8266 wifi连接了Arduino Yun。 Allowed cross origin data stream to get data from the Arduino using http requests. 允许跨源数据流使用http请求从Arduino获取数据。

The problem with http requests is that it depends on the speed in which the ESP8266 chip can process the request. http请求的问题在于它取决于ESP8266芯片处理请求的速度。 It's about 750ms. 大约750ms。

But what I'm trying to achieve is lightning fast wiresless response between the Arduino and my browser. 但是我想要实现的是Arduino和我的浏览器之间闪电般的快速无线响应。 Is there an alternative? 还有其他选择吗?

My javascript code to send data is: 我发送数据的javascript代码是:

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. 简而言之:我有6个引脚声明为输入,有6个引脚声明为输出。 I want the data to fill my javascript variable as real time as possible. 我希望数据尽可能实时地填充我的JavaScript变量。 (low ms) (低毫秒)

Thanks 谢谢

Try using MQTT protocol - lightweight messaging protocol with high latency 尝试使用MQTT协议-具有高延迟的轻量级消息传递协议

There are many free mqtt brokers you can use. 您可以使用许多免费的mqtt经纪人。 Check the below link 检查以下链接

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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