Gsm800 mqtt库

时间:2016-06-14 15:52:08

标签: mqtt gsm arduino-uno

我有sim800模块,我想控制来自网络服务器的中继,所以我需要mqtt库和arduino uno的示例代码请帮助我,什么是AT命令用于发布和订阅标签sim800使用arduino uno

3 个答案:

答案 0 :(得分:2)

我认为您的SIM800模块不太可能具有MQTT的AT命令。

Arduino有几个MQTT库:

这两个库都可以与任何库一起使用,而不是实现Client接口。因此,应该可以创建一个与GSM模块通信的TCP客户端。

如果SIM800支持GSM库,则实现Client接口: https://www.arduino.cc/en/Reference/GSM

如果您使用的是Arduino中的硬件串口,那么使用Leonardo可能比使用Uno更好,因为您可以使用USB对Arduino进行编程,并使用硬件串口与GSM模块进行通信。

答案 1 :(得分:0)

您可以尝试使用Paho Arduino客户端库。它具有完整的MQTT库,支持MQTT 3.1,MQTT 3.1.1& SSL / TLS。

答案 2 :(得分:0)

适用于SIM800 GSM调制解调器的MQTT库位于ElementzTechBlogElementzGithubRepositoryElementzOnlineCart

<强>功能

自动连接

   Automatically connect to TCP and to MQTT server.

连接功能

   This function can be used to connect your client to MQTT broker.
   Use only if you do not use Auto connect functionality.
   Optionally  you can use username, password, WILL topic and WILL Message.

OnConnect回拨函数

   This call back function is called when MQTT connection is established.
   You can call subscription and publish functions inside it (according to your need).

发布功能

   This function can be used to publish messages to different topics.
   You can select  QoS levels and RETAIN flag according to your need.

订阅功能

   This function can be used to subscribe messages from different topics.

OnMessage回调函数

   This callback function is called when messages are received from  subscribed topics
   Topic, TopicLength, Message, MessageLength are the arguments of  OnMessage callback function.
   Inside this, you can write your custom code.

取消订阅功能

   This function can be used to unsubscribe from a previously subscribed topic.

断开功能

   This function can be used to disconnect your client from MQTT broker.

保持活力

   You can specify your KeepAlive duration while initializing.
   Ping requests are sent and received automatically.