4.4
Example 4: Use MQTT
Introduction:
MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was
designed as an extremely lightweight publish/subscribe messaging transport. It is useful for
connections with remote locations where a small code footprint is required and/or network
bandwidth is at a premium. For example, it has been used in sensors communicating to a broker
via satellite link, over occasional dial-up connections with healthcare providers, and in a range of
home automation and small device scenarios. It is also ideal for mobile applications because of
its small size, low power usage, minimised data packets, and efficient distribution of information
to one or many receivers.
This example shows how to use Yun Shield with SSL MQTT protocol.
Install required packages
Install below packages for MQTT:
root@Arduino:~# opkg update
root@Arduino:~# opkg install libcares
root@Arduino:~# opkg install libopenssl
root@Arduino:~# opkg install libmosquitto
root@Arduino:~# opkg install mosquitto-client
Test with public MQTT test server:
test.mosquitto.org is a hosts a publicly available Mosquitto MQTT server/broker. User can post
and subscribe to this MQTT server for testing. To test this server with SSL connection, user has to
download the certificate authority file
to verify the server connection.
Open two SSH windows. In the first window, we subscribe to a topic with below command:
mosquitto_sub -h test.mosquitto.org -p 8883 --cafile mosquitto.org.crt -t dragino/device0/temperature
This command will listen to this topic and display any change on the server.
And in the other window, we publish the change by another command:
mosquitto_pub -h test.mosquitto.org -p 8883 --cafile mosquitto.org.crt -t dragino/device0/temperature -m 31
Once the publish command is issued, we can see the result will display in the subscribe
command.
w w w . e k t
2
. c o m
Electronics
Katrangi
Trading
Содержание PAB2
Страница 1: ...Yun Shield User Manual VERSION 1 1 w w w e k t 2 c o m Electronics Katrangi Trading...
Страница 20: ...Screen Shot Xively Dashboard w w w e k t 2 c o m Electronics Katrangi Trading...
Страница 28: ...Yun Shield Quick Start Guide VERSION 1 0 w w w e k t 2 c o m Electronics Katrangi Trading...
Страница 39: ...Screen Shot Xively Dashboard w w w e k t 2 c o m Electronics Katrangi Trading...