首页 > 解决方案 > Python使用websocket API将dht22传感器数据发送到网页

问题描述

我正在使用与读取温度和湿度的 dht22 传感器连接的 raspberry Pi3 设备,python 代码将传感器数据发送到 thingSpeak 存储服务器上的 myChannel 并在 twitter 上发布信息,直到我的项目正常工作。

但我还想使用 websocket 在 webPage 上发送传感信息。我已经为此搜索了很多,但我没有找到好的答案,是否可以将 Websocket 与 thingSpaek 连接并直接或从 Pi 设备获取数据?

谢谢,

标签: pythonwebsocketraspberry-pi3iotsensors

解决方案


ThingSpeak 允许 MQTT 客户端订阅其遥测数据。我相信也应该支持基于 Web Sockets 的 MQTT(无法确认)。

https://www.mathworks.com/help/thingspeak/subscribetoachannelfeed.html

一种或另一种方式,您可以使用 javascript MQTT 客户端(例如 paho)在您的网页上订阅 ThingSpeak 主题

https://www.eclipse.org/paho/clients/js/


推荐阅读