No ACL setup yet! Denying access to everyone.
en:edu:zmitac:macro:iot:lab
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:edu:zmitac:macro:iot:lab [2023/04/21 16:32] – [Network services] administrator | en:edu:zmitac:macro:iot:lab [2024/04/21 16:17] (current) – [Laboratory scenarios] pczekalski | ||
|---|---|---|---|
| Line 33: | Line 33: | ||
| ==== VSCode, PlatformIO, and project configuration ==== | ==== VSCode, PlatformIO, and project configuration ==== | ||
| - | In any case, creating a new project under PlatformIO should follow this general setting, regarding Board and Framework (see figure {{ref> | + | In any case, creating a new project under PlatformIO should follow this general setting regarding Board and Framework (see figure {{ref> |
| <figure platformionewproject> | <figure platformionewproject> | ||
| {{: | {{: | ||
| Line 68: | Line 68: | ||
| ==== Networking ==== | ==== Networking ==== | ||
| - | There is a WiFi 2.4GHz, IPv4 network available to the students. This is a PRIVATE network. This network is separated from the Internet, but all connected devices can talk to one another. There is a DHCP server with networking addressing scope 192.168.90.10-192.168.90.254. | + | There is a WiFi 2.4GHz IPv4 network available to the students. This is a PRIVATE network. This network is separated from the Internet, but all connected devices can talk to one another. There is a DHCP server with networking addressing scope 192.168.90.10-192.168.90.254. |
| - | <note warning> | + | <note warning> |
| To connect to the wireless network, use the following credentials: | To connect to the wireless network, use the following credentials: | ||
| Line 114: | Line 114: | ||
| </ | </ | ||
| Both functions accept a wide range of argument types without needing to convert to string explicitly. | Both functions accept a wide range of argument types without needing to convert to string explicitly. | ||
| - | <note tip>Note, there is a limit on the character set that is ASCII only. We suggest avoiding " | + | <note tip>Note: there is a limit on the character set that is ASCII only. We suggest avoiding " |
| ==== Laboratory scenarios ==== | ==== Laboratory scenarios ==== | ||
| - | All teams share the same scenario yet; please note that MQTT messages exchanged between devices shall be coordinated among team members not to overlay one another. | + | All teams share the same scenario yet; please note that MQTT messages exchanged between devices shall be coordinated among team members |
| <note tip>Mind keeping your code between meetings. It is regular that at every next laboratory meeting, you will extend your code by something extra.</ | <note tip>Mind keeping your code between meetings. It is regular that at every next laboratory meeting, you will extend your code by something extra.</ | ||
| < | < | ||
| Line 129: | Line 129: | ||
| - Sends a message via serial port to the serial port monitor: '' | - Sends a message via serial port to the serial port monitor: '' | ||
| - | <note tip>The GPIO the built-in LED is connected to is number 14. Physically it is located almost in the middle of the mainboard, under the display, and its color is blue.</ | + | <note tip>The GPIO the built-in LED is connected to is number 14. Physically, it is located almost in the middle of the mainboard, under the display, and its colour |
| <code c> | <code c> | ||
| #define LED_BUILTIN 14 | #define LED_BUILTIN 14 | ||
| </ | </ | ||
| - | Note, to use tracing with the '' | + | Note, to use tracing with the '' |
| < | < | ||
| ... | ... | ||
| Line 140: | Line 140: | ||
| ... | ... | ||
| </ | </ | ||
| + | Obligatory: | ||
| + | * Provide a solution using '' | ||
| Advanced: | Advanced: | ||
| * Use a timer/ | * Use a timer/ | ||
| + | * | ||
| Report: | Report: | ||
| * Describe your approach and include source code in the report | * Describe your approach and include source code in the report | ||
| Line 153: | Line 156: | ||
| In this scenario, you will write an application that reports on the LCD Display.\\ | In this scenario, you will write an application that reports on the LCD Display.\\ | ||
| Your code shall implement a message '' | Your code shall implement a message '' | ||
| - | Additionally, | + | Additionally, |
| == The LCD Display == | == The LCD Display == | ||
| Line 187: | Line 190: | ||
| Note there is an assumption that you press only one button at a time. If no button is pressed, Vcc goes to the AD0, and you get maximum reading (see schematics on figure {{ref> | Note there is an assumption that you press only one button at a time. If no button is pressed, Vcc goes to the AD0, and you get maximum reading (see schematics on figure {{ref> | ||
| - | <note warning> | + | <note warning> |
| Reading an AD0 is as simple as: | Reading an AD0 is as simple as: | ||
| Line 208: | Line 211: | ||
| ** Presenting temperature and humidity on the local LCD screen **\\ | ** Presenting temperature and humidity on the local LCD screen **\\ | ||
| In this scenario, you will measure temperature and relative humidity using the attached DHT 11 and present it on the screen. | In this scenario, you will measure temperature and relative humidity using the attached DHT 11 and present it on the screen. | ||
| - | In the first row, there should appear | + | In the first row, a label should appear |
| == Temperature and humidity sensor == | == Temperature and humidity sensor == | ||
| Line 237: | Line 240: | ||
| </ | </ | ||
| - | The sensor class returns data (among others) in a float containing temperature (in C) and relative humidity (in percent): | + | The sensor class returns data (among others) in a float containing temperature (in C) and relative humidity (in per cent): |
| <code c> | <code c> | ||
| ... | ... | ||
| Line 255: | Line 258: | ||
| Report: | Report: | ||
| - | * When using ESP in STA mode, observe | + | * When using ESP in STA mode, observe |
| * Include source code. | * Include source code. | ||
| < | < | ||
| Line 261: | Line 264: | ||
| === Scenario Lab5 === | === Scenario Lab5 === | ||
| **Sending data to the network**\\ | **Sending data to the network**\\ | ||
| - | In this scenario, you will implement a fully functional IoT end-node, sending | + | In this scenario, you will implement a fully functional IoT end-node |
| Use your solution from the last step of Lab4 and also Lab3. Measure temperature and humidity, present them on the screen as in the case of the Lab3 scenario, and parallel, publish them as MQTT messages to the Broker. | Use your solution from the last step of Lab4 and also Lab3. Measure temperature and humidity, present them on the screen as in the case of the Lab3 scenario, and parallel, publish them as MQTT messages to the Broker. | ||
| <note important> | <note important> | ||
| - | Using any software-based MQTT client, subscribe to the messages using a PRIVATE or PUBLIC network and observe results. You can use a PC computer you're developing your solution for this task. | + | Using any software-based MQTT client, subscribe to the messages using a PRIVATE or PUBLIC network and observe results. You can use a PC to develop a solution for this task. |
| The simplest starting point is to use the pub-sub MQTT client library: | The simplest starting point is to use the pub-sub MQTT client library: | ||
| Line 296: | Line 299: | ||
| </ | </ | ||
| - | Then connect your MQTT pub-sub client to the server. You can define a separate function in case you need to repeat this process when the connection is down (for any reason) to simplify reconnect procedure: | + | Somewhere in the '' |
| + | <code c> | ||
| + | ... | ||
| + | client.setServer(< | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Then, connect your MQTT pub-sub client to the server. You can define a separate function in case you need to repeat this process when the connection is down (for any reason) to simplify reconnect procedure: | ||
| <code c> | <code c> | ||
| Line 316: | Line 326: | ||
| </ | </ | ||
| - | Advanced: | + | To publish a single message, use: |
| - | * Implement a "last will" informing that device has lost connection (suddenly, not via disconnect)—present the last available measurements as persistent. Present the device state by changing a persistent message on connect/ | + | <code c> |
| + | ... | ||
| + | client.publish(< | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Note that receiving messages requires periodical execution of the '' | ||
| + | |||
| + | **Advanced**: | ||
| + | * Implement a "last will" informing that the device has lost connection (suddenly, not via disconnect)—present the last available measurements as persistent. Present the device state by changing a persistent message on connect/ | ||
| To publish a last-will message, you may use an extended version of the P'' | To publish a last-will message, you may use an extended version of the P'' | ||
| Line 325: | Line 344: | ||
| ... | ... | ||
| </ | </ | ||
| - | And once connected, you may notify the dashboard (if any) that you're back online: | + | Once connected, you may notify the dashboard (if any) that you're back online: |
| <code c> | <code c> | ||
| ... | ... | ||
| Line 333: | Line 352: | ||
| - | Report: | + | **Report**: |
| * Provide your MQTT message Topics and Payload formats (semantics). | * Provide your MQTT message Topics and Payload formats (semantics). | ||
| * Include source code. | * Include source code. | ||
| < | < | ||
en/edu/zmitac/macro/iot/lab.1682087552.txt.gz · Last modified: by administrator
