This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:remotelab:ume:smartme:m1 [2019/10/26 10:40] – pczekalski | en:iot-open:remotelab:ume:smartme:m1 [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== IM1: MQTT to publish a message with a topic ====== | + | ==== IM1: MQTT to publish a message with a topic ==== |
| MQTT is one of the most commonly used protocols in IoT projects. It stands for Message Queuing Telemetry Transport. In addition, it is designed as a lightweight messaging protocol that provides publish/ | MQTT is one of the most commonly used protocols in IoT projects. It stands for Message Queuing Telemetry Transport. In addition, it is designed as a lightweight messaging protocol that provides publish/ | ||
| - | ===== Target group ===== | + | === Target group === |
| This hands-on lab guide is intended for master students. Other target groups may benefit from it only if they follow it after having dealt with all the exercises proposed which belong to lower levels of difficulty. | This hands-on lab guide is intended for master students. Other target groups may benefit from it only if they follow it after having dealt with all the exercises proposed which belong to lower levels of difficulty. | ||
| - | ===== Prerequisites | + | === Prerequisites === |
| - | ==== Liquid Crystal | + | == Liquid Crystal == |
| - | For this library, you may refer to the [[en: | + | For this library, you may refer to the [[en: |
| - | ==== DHT ==== | + | == DHT == |
| - | For this library, you may refer to the [[en: | + | For this library, you may refer to the [[en: |
| - | ==== Understand what Arduino Ethernet Shield is and how it works ==== | + | == Understand what Arduino Ethernet Shield is, and how it works === |
| The Arduino Ethernet Shield V1 allows an Arduino board to connect to the internet. It is based on the Wiznet W5100 [1] ethernet chip (datasheet [2]). The Wiznet W5100 provides a network (IP) stack capable of both TCP and UDP-based communication. It supports up to four simultaneous socket connections. Use the Ethernet library [3] to write sketches that connect to the Internet using the shield. The ethernet shield connects to an Arduino board using long wire-wrap headers which extend through the shield. This keeps the pin layout intact and allows another shield to be stacked on top. | The Arduino Ethernet Shield V1 allows an Arduino board to connect to the internet. It is based on the Wiznet W5100 [1] ethernet chip (datasheet [2]). The Wiznet W5100 provides a network (IP) stack capable of both TCP and UDP-based communication. It supports up to four simultaneous socket connections. Use the Ethernet library [3] to write sketches that connect to the Internet using the shield. The ethernet shield connects to an Arduino board using long wire-wrap headers which extend through the shield. This keeps the pin layout intact and allows another shield to be stacked on top. | ||
| Line 22: | Line 22: | ||
| [3] https:// | [3] https:// | ||
| - | ==== Understand what MQTT is and how it works. | + | == Understand what MQTT is and how it works.== |
| MQTT (Message Queue Telemetry Transport) is a standard (SO/IEC PRF 20922) machine-to-machine (M2M) communication protocol for the Internet of Things smart objects and devices. MQTT is a simple messaging protocol, designed for constrained devices with low-bandwidth. So, it’s the perfect solution for Internet of Things applications. | MQTT (Message Queue Telemetry Transport) is a standard (SO/IEC PRF 20922) machine-to-machine (M2M) communication protocol for the Internet of Things smart objects and devices. MQTT is a simple messaging protocol, designed for constrained devices with low-bandwidth. So, it’s the perfect solution for Internet of Things applications. | ||
| This publish/ | This publish/ | ||
| Line 35: | Line 35: | ||
| [4] https:// | [4] https:// | ||
| - | ===== Scenario | + | === Scenario === |
| This node, which acts as a publisher, takes care of sampling the temperature value and sending it to other nodes, which serve as subscribers and were initialized as in exercise M2. | This node, which acts as a publisher, takes care of sampling the temperature value and sending it to other nodes, which serve as subscribers and were initialized as in exercise M2. | ||
| - | ===== Result | + | === Result === |
| It will be possible to display the value of the temperature, | It will be possible to display the value of the temperature, | ||
| Start | Start | ||
| - | This exercise is to be considered as closely related to the M2 exercise. This means that if you want to reproduce a complete experiment, you have to book at least two nodes of the lab, and then you have to run both M1 and M2 sketches, one per node. | + | This exercise is to be considered as closely related to the M2 exercise. This means that if you want to reproduce a complete experiment, you have to book at least two nodes of the lab, and then you have to run both IM1 and IM2 sketches, one per node. |
| - | ===== Steps ===== | + | === Steps === |
| - | ==== Step 1 ==== | + | == Step 1 == |
| Include the following libraries: LCD driver, DHT, MQTT, and Ethernet. | Include the following libraries: LCD driver, DHT, MQTT, and Ethernet. | ||
| <code c> | <code c> | ||
| Line 56: | Line 56: | ||
| - | ==== Step 2 ==== | + | == Step 2 == |
| Instantiate the software controller component for the LCD display. | Instantiate the software controller component for the LCD display. | ||
| Line 81: | Line 81: | ||
| </ | </ | ||
| - | ==== Step 3 ==== | + | == Step 3 == |
| Initialize the display and the Ethernet connection with IP and MAC address. | Initialize the display and the Ethernet connection with IP and MAC address. | ||
| Then launch the connection() function and initialize the MQTT client with the shift.io broker. | Then launch the connection() function and initialize the MQTT client with the shift.io broker. | ||
| Line 104: | Line 104: | ||
| </ | </ | ||
| - | ==== Step 4 ==== | + | == Step 4 == |
| Implement the loop() function to detect the value of temperature from the DHT sensor and publish it as a message with the topic “iotopenume” every 1 second, as follows: | Implement the loop() function to detect the value of temperature from the DHT sensor and publish it as a message with the topic “iotopenume” every 1 second, as follows: | ||
| Line 127: | Line 127: | ||
| </ | </ | ||
| - | ===== Result validation | + | === Result validation === |
| It will be possible to display the value, sampled by the temperature sensor attached to this node, on the LCD display attached to the node you will use as a subscriber, as soon as you start the M2 sketch on the latter. | It will be possible to display the value, sampled by the temperature sensor attached to this node, on the LCD display attached to the node you will use as a subscriber, as soon as you start the M2 sketch on the latter. | ||
| - | ===== Platformio.ini | + | === Platformio.ini === |
| < | < | ||
| Line 152: | Line 152: | ||
| - | ===== M1_pub.cpp ===== | + | === IM1_pub.cpp === |
| <code c> | <code c> | ||
| #include < | #include < | ||
| Line 207: | Line 207: | ||
| } | } | ||
| </ | </ | ||
| - | |||
| - | |||
| - | |||