{"id":116,"date":"2023-06-03T13:36:12","date_gmt":"2023-06-03T17:36:12","guid":{"rendered":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/?post_type=chapter&#038;p=116"},"modified":"2023-09-02T13:08:01","modified_gmt":"2023-09-02T17:08:01","slug":"chapter-4","status":"publish","type":"chapter","link":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/chapter\/chapter-4\/","title":{"raw":"End-to-End IoT Solution","rendered":"End-to-End IoT Solution"},"content":{"raw":"&nbsp;\r\n<p style=\"text-align: justify\">Implementing an end-to-end IoT solution involves deploying sensors and processors and selecting the appropriate communication technology to transmit the telemetry data to the platform. This data is then visualized and analyzed to gain insights and trigger actions based on those insights. Additionally, in the final phase of the solution, it may be necessary to develop dashboards or applications for mobile phones, tablets, and personal computers. As mentioned earlier, the TB platform offers useful widgets for easy visualization of telemetry data. This chapter aims to provide a step-by-step guide for setting up a simple IoT project, which includes hardware configuration and data publishing to the TB platform over MQTT. Once the data is received by TB, we can utilize built-in widgets such as analog gauges and time series graphs to create a dashboard and visualize the telemetry data.<\/p>\r\n\r\n<h1><strong><span style=\"color: #3366ff\">4.1 Hardware Selection<\/span><\/strong><\/h1>\r\nIn general, IoT projects can be accomplished using different hardware options such as Arduino, ESP8266 (NodeMCU), and Raspberry Pi. Let's explore each of these options:\r\n<ul>\r\n \t<li>Arduino:<\/li>\r\n<\/ul>\r\n<p style=\"text-align: justify\">Arduino is an electronic board on the ATmega328P microcontroller. It offers several general-purpose input\/output (GPIO) pins that enable the development of various IoT projects. Arduino is an open-source platform, providing access to libraries and codes freely available on the internet. To work on an Arduino board, you need to use the C\/C++ programming language.<\/p>\r\n\r\n<ul>\r\n \t<li>ESP8266:<\/li>\r\n<\/ul>\r\n<p style=\"text-align: justify\">One limitation of the Arduino board is its lack of built-in Wi-Fi and Bluetooth connectivity. To address this, the ESP8266 and its extension, the ESP32, were introduced for developing low-cost IoT projects. Both ESP8266 and ESP32 boards utilize the Xtensa processing core and the FreeRTOS real-time operating system. They fall between the Arduino and Raspberry Pi boards in terms of energy consumption and real-time processing capabilities. Similar to the Arduino board, the ESP8266 supports programming in C\/C++.<\/p>\r\n\r\n<ul>\r\n \t<li>Raspberry Pi:<\/li>\r\n<\/ul>\r\n<p style=\"text-align: justify\">Raspberry Pi (RPI) is a low-cost mini-computer that offers full functionality and can be directly connected to a monitor, keyboard, or mouse. It runs on a custom Linux-based operating system called Raspberry Pi OS, previously known as Raspbian, which is based on Debian. Raspberry Pi is available in 32-bit and 64-bit versions, and it also supports other operating systems such as Windows, Ubuntu, and Mac. Due to limited internal memory, it is necessary to connect a micro SD card to store the OS and source codes. Raspberry Pi supports Bluetooth, Wi-Fi, and an Ethernet port for network file transfer. Several generations of Raspberry Pi have been released, including Raspberry Pi Pico, Zero, 3, and 4. Each generation has different specifications in terms of core technology, CPU frequency, RAM size, Wi-Fi data rate, power consumption, dimensions, and cost. Among these, Raspberry Pi 4 (RPI4) is highly recommended for developing professional IoT projects. For detailed information about each Raspberry Pi model, you can refer to the documentation provided by the Raspberry Pi Foundation. Python programming is well-suited for developing IoT projects on the RPI, and Raspberry Pi 4 is particularly suitable.<\/p>\r\n<p style=\"text-align: justify\">Table 3 provides an overview of the features of different boards that are suitable for IoT projects. Ultimately, Raspberry Pi 4 is a powerful choice for developing IoT projects, especially when using Python for programming.<\/p>\r\n<em><span style=\"color: #3366ff\">Table 3. Comparison between Arduino, ESP32 and RPI<\/span><\/em>\r\n\r\n<img class=\"alignnone size-full wp-image-152\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/05\/\u0633\u06cc\u0645-\u06a9\u0627\u0648\u0647-\u062a\u06a9.jpg\" alt=\"\" width=\"755\" height=\"209\" \/>\r\n<h1><strong><span style=\"color: #3366ff\">4.2 Booting the Raspberry Pi<\/span><\/strong><\/h1>\r\nThis section briefly describes setting up and running the RPI.\r\n<p style=\"text-align: justify\">1- In order to get the suitable OS version for your Raspberry PI go to: <a href=\"https:\/\/www.raspberrypi.com\/software\/\">https:\/\/www.raspberrypi.com\/software\/<\/a> and download Raspberry PI Imager on a computer with microSD card reader. Follow the instructions on the website to install the Debian OS on a previously formatted microSD card using the Imager.<\/p>\r\n\r\n\r\n[caption id=\"attachment_265\" align=\"aligncenter\" width=\"685\"]<img class=\"size-full wp-image-265\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/77ui_2_2156-15.jpg\" alt=\"\" width=\"685\" height=\"367\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 17. Raspberry PI Imager<\/span><\/em>[\/caption]\r\n<p style=\"text-align: justify\">2- Insert the microSD card into the RPI board\u2019s memory slot. Connect the power cable as well as the peripheral devices such as the monitor, mouse and keyboard to the RPI. You may need to use an HDMI to micro-HDMI converter to connect the screen to the RPI board.<\/p>\r\n<p style=\"text-align: justify\">3- Turn on the RPI board and follow the instructions to install the OS. Once the installation is complete, you can log in and see the OS desktop.<\/p>\r\n\r\n\r\n[caption id=\"attachment_267\" align=\"aligncenter\" width=\"938\"]<img class=\"size-full wp-image-267\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u067e\u0627\u0631\u0633-\u0641\u0627\u0646\u0627\u0644-1.jpg\" alt=\"\" width=\"938\" height=\"479\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 18. RPI OS Desktop<\/span><\/em>[\/caption]\r\n<p style=\"text-align: justify\">4-\u00a0 Connect your RPI to an available Wi-Fi network. If you are connected to the same Wi-Fi network as your PC, you will be able to control your RPI remotely through your PC using \u201cRemote Desktop Connection\u201d. To connect the RPI to the Wi-Fi, on the top left corner of the OS desktop, open the terminal and type either of the following commands to get the IP address of your RPI: \u201chostname-I\u201d or \u201cifconfig\u201d.<\/p>\r\n\r\n\r\n[caption id=\"attachment_269\" align=\"aligncenter\" width=\"1161\"]<img class=\"size-full wp-image-269\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1.jpg\" alt=\"\" width=\"1161\" height=\"222\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 19. Obtaining the IP address of the RPI<\/span><\/em>[\/caption]\r\n<p style=\"text-align: justify\">5- On your PC, open \u201cRemote Desktop Connection\u201d and enter the IP address of your RPI to remotely connect to your RPI.<\/p>\r\n\r\n\r\n[caption id=\"attachment_272\" align=\"aligncenter\" width=\"759\"]<img class=\"size-full wp-image-272\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/432mi2_1818-1.gif\" alt=\"\" width=\"759\" height=\"444\" \/> <span style=\"color: #3366ff\"><em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 20. Remote Desktop Connection<\/em><\/span>[\/caption]\r\n<h1><strong><span style=\"color: #3366ff\">4.3 Connecting the RPI to TB<\/span><\/strong><\/h1>\r\n<p style=\"text-align: justify\">Once the RPI is booted, you will need to follow these instructions to get connected to the TB:<\/p>\r\n<p style=\"text-align: justify\">6- Before coding, you need to install the necessary Python packages on your RPI OS. For this purpose, click on the Command-line Terminal icon in the top menu bar (or choose Menu &gt; Accessories &gt; Terminal).<\/p>\r\n\r\n\r\n[caption id=\"attachment_278\" align=\"aligncenter\" width=\"872\"]<img class=\"size-full wp-image-278\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-21.-Command-line-Terminal.jpg\" alt=\"\" width=\"872\" height=\"498\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 21. Command-line Terminal<\/span><\/em>[\/caption]\r\n<p style=\"text-align: justify\">This will open a window where you can enter the following commands:<\/p>\r\n\r\n<ul>\r\n \t<li style=\"text-align: justify\">Update and upgrade the OS: $ sudo apt update &amp;&amp; sudo apt upgrade -y<\/li>\r\n<\/ul>\r\n[caption id=\"attachment_291\" align=\"aligncenter\" width=\"644\"]<img class=\"size-full wp-image-291\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-22.-Updating-the-RPI-OS.jpg\" alt=\"\" width=\"644\" height=\"433\" \/> <span style=\"color: #3366ff\"><em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 22. Updating the RPI OS<\/em><\/span>[\/caption]\r\n<ul>\r\n \t<li>Install the \u201cpip\u201d package installer for Python: $ sudo apt install python3-pip<\/li>\r\n<\/ul>\r\n[caption id=\"attachment_290\" align=\"aligncenter\" width=\"1163\"]<img class=\"size-full wp-image-290\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python.jpg\" alt=\"\" width=\"1163\" height=\"324\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 23. Installing the pip package installer for Python<\/span><\/em>[\/caption]\r\n<ul>\r\n \t<li>Check the pip version to make sure it is installed correctly: $ pip --version<\/li>\r\n<\/ul>\r\n[caption id=\"attachment_294\" align=\"aligncenter\" width=\"1198\"]<img class=\"size-full wp-image-294\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version.jpg\" alt=\"\" width=\"1198\" height=\"224\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 24. Checking the python3-pip version<\/span><\/em>[\/caption]\r\n<ul>\r\n \t<li>Now, you can install the MQTT library to link the RPI board to the platform over MQTT protocol: $ pip install paho-mqtt<\/li>\r\n<\/ul>\r\n[caption id=\"attachment_295\" align=\"aligncenter\" width=\"1203\"]<img class=\"size-full wp-image-295\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package.jpg\" alt=\"\" width=\"1203\" height=\"306\" \/> <span style=\"color: #3366ff\"><em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 25. Installing MQTT package<\/em><\/span>[\/caption]\r\n<p style=\"text-align: justify\">7- Open Thonny Python IDE to start coding.<\/p>\r\n<p style=\"text-align: justify\"><img class=\"alignnone wp-image-274\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Med-2-1.jpg\" alt=\"\" width=\"35\" height=\"48\" \/>\u00a0 \u00a0 \u00a0\u2192 Programmimg \u2192Thonny Python IDE<\/p>\r\n<p style=\"text-align: justify\">8- Copy and run the code which was described in the previous chapters to publish the sample temperature and humidity telemetry data to TB. Note that in this example, since our focus is on connecting the RPI board to the TB platform, we are just sending constant telemetry data. You may connect an environmental sensor such as DHT22 to your RPI board and transmit the real parameters captured by the senosr to the TB platform.<\/p>\r\n\r\n\r\n[caption id=\"attachment_289\" align=\"aligncenter\" width=\"1053\"]<img class=\"size-full wp-image-289\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud.jpg\" alt=\"\" width=\"1053\" height=\"517\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 26. Running sample code on RPI to send telemetry data to TB cloud<\/span><\/em>[\/caption]\r\n<p style=\"text-align: justify\">9- Go to TB and click on the device you created earlier to see the published telemetry data sent by RPI.<\/p>\r\n\r\n\r\n[caption id=\"attachment_285\" align=\"aligncenter\" width=\"905\"]<img class=\"size-full wp-image-285\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-27.-Latest-telemetry-of-data-published-by-RPI.gif\" alt=\"\" width=\"905\" height=\"476\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 27. Latest telemetry of data published by RPI<\/span><\/em>[\/caption]\r\n<p style=\"text-align: justify\">10- Now, you can create a dashboard using the pre-built widgets on TB. As it was explained earlier, you can add the thermometer gauge widget to exhibit the temperature value and the radial gauge widget to display the humidity.<\/p>\r\n\r\n\r\n[caption id=\"attachment_283\" align=\"aligncenter\" width=\"693\"]<img class=\"size-full wp-image-283\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart.jpg\" alt=\"\" width=\"693\" height=\"462\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 28. Adding thermometer gauge (right) and radial gauge (left)<\/span><\/em>[\/caption]\r\n<p style=\"text-align: justify\">11- Once you add the widgets, you will see the dashboard as illustrated below.<\/p>\r\n\r\n\r\n[caption id=\"attachment_297\" align=\"aligncenter\" width=\"970\"]<img class=\"size-full wp-image-297\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-29.-TB-dashboard-gauges.jpg\" alt=\"\" width=\"970\" height=\"457\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 29. TB dashboard gauges<\/span><\/em>[\/caption]\r\n<p style=\"text-align: justify\">12- The above gauges show the instantaneous telemetry data. In order to show the historical values, you can use the \u201cTimeseries Line Chart\u201d widget which give you the opportunity to represent several variables from different devices over the time.<\/p>\r\n\r\n\r\n[caption id=\"attachment_283\" align=\"aligncenter\" width=\"693\"]<img class=\"size-full wp-image-283\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart.jpg\" alt=\"\" width=\"693\" height=\"462\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 30. Timeseries line chart<\/span><\/em>[\/caption]\r\n\r\n[caption id=\"attachment_280\" align=\"aligncenter\" width=\"981\"]<img class=\"size-full wp-image-280\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-31.-Final-TB-dashboard-showing-latest-and-historical-telemetry-data.jpg\" alt=\"\" width=\"981\" height=\"386\" \/> <em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 31. Final TB dashboard showing latest and historical telemetry data<\/span><\/em>[\/caption]\r\n\r\n&nbsp;","rendered":"<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Implementing an end-to-end IoT solution involves deploying sensors and processors and selecting the appropriate communication technology to transmit the telemetry data to the platform. This data is then visualized and analyzed to gain insights and trigger actions based on those insights. Additionally, in the final phase of the solution, it may be necessary to develop dashboards or applications for mobile phones, tablets, and personal computers. As mentioned earlier, the TB platform offers useful widgets for easy visualization of telemetry data. This chapter aims to provide a step-by-step guide for setting up a simple IoT project, which includes hardware configuration and data publishing to the TB platform over MQTT. Once the data is received by TB, we can utilize built-in widgets such as analog gauges and time series graphs to create a dashboard and visualize the telemetry data.<\/p>\n<h1><strong><span style=\"color: #3366ff\">4.1 Hardware Selection<\/span><\/strong><\/h1>\n<p>In general, IoT projects can be accomplished using different hardware options such as Arduino, ESP8266 (NodeMCU), and Raspberry Pi. Let&#8217;s explore each of these options:<\/p>\n<ul>\n<li>Arduino:<\/li>\n<\/ul>\n<p style=\"text-align: justify\">Arduino is an electronic board on the ATmega328P microcontroller. It offers several general-purpose input\/output (GPIO) pins that enable the development of various IoT projects. Arduino is an open-source platform, providing access to libraries and codes freely available on the internet. To work on an Arduino board, you need to use the C\/C++ programming language.<\/p>\n<ul>\n<li>ESP8266:<\/li>\n<\/ul>\n<p style=\"text-align: justify\">One limitation of the Arduino board is its lack of built-in Wi-Fi and Bluetooth connectivity. To address this, the ESP8266 and its extension, the ESP32, were introduced for developing low-cost IoT projects. Both ESP8266 and ESP32 boards utilize the Xtensa processing core and the FreeRTOS real-time operating system. They fall between the Arduino and Raspberry Pi boards in terms of energy consumption and real-time processing capabilities. Similar to the Arduino board, the ESP8266 supports programming in C\/C++.<\/p>\n<ul>\n<li>Raspberry Pi:<\/li>\n<\/ul>\n<p style=\"text-align: justify\">Raspberry Pi (RPI) is a low-cost mini-computer that offers full functionality and can be directly connected to a monitor, keyboard, or mouse. It runs on a custom Linux-based operating system called Raspberry Pi OS, previously known as Raspbian, which is based on Debian. Raspberry Pi is available in 32-bit and 64-bit versions, and it also supports other operating systems such as Windows, Ubuntu, and Mac. Due to limited internal memory, it is necessary to connect a micro SD card to store the OS and source codes. Raspberry Pi supports Bluetooth, Wi-Fi, and an Ethernet port for network file transfer. Several generations of Raspberry Pi have been released, including Raspberry Pi Pico, Zero, 3, and 4. Each generation has different specifications in terms of core technology, CPU frequency, RAM size, Wi-Fi data rate, power consumption, dimensions, and cost. Among these, Raspberry Pi 4 (RPI4) is highly recommended for developing professional IoT projects. For detailed information about each Raspberry Pi model, you can refer to the documentation provided by the Raspberry Pi Foundation. Python programming is well-suited for developing IoT projects on the RPI, and Raspberry Pi 4 is particularly suitable.<\/p>\n<p style=\"text-align: justify\">Table 3 provides an overview of the features of different boards that are suitable for IoT projects. Ultimately, Raspberry Pi 4 is a powerful choice for developing IoT projects, especially when using Python for programming.<\/p>\n<p><em><span style=\"color: #3366ff\">Table 3. Comparison between Arduino, ESP32 and RPI<\/span><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-152\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/05\/\u0633\u06cc\u0645-\u06a9\u0627\u0648\u0647-\u062a\u06a9.jpg\" alt=\"\" width=\"755\" height=\"209\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/05\/\u0633\u06cc\u0645-\u06a9\u0627\u0648\u0647-\u062a\u06a9.jpg 755w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/05\/\u0633\u06cc\u0645-\u06a9\u0627\u0648\u0647-\u062a\u06a9-300x83.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/05\/\u0633\u06cc\u0645-\u06a9\u0627\u0648\u0647-\u062a\u06a9-65x18.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/05\/\u0633\u06cc\u0645-\u06a9\u0627\u0648\u0647-\u062a\u06a9-225x62.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/05\/\u0633\u06cc\u0645-\u06a9\u0627\u0648\u0647-\u062a\u06a9-350x97.jpg 350w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><\/p>\n<h1><strong><span style=\"color: #3366ff\">4.2 Booting the Raspberry Pi<\/span><\/strong><\/h1>\n<p>This section briefly describes setting up and running the RPI.<\/p>\n<p style=\"text-align: justify\">1- In order to get the suitable OS version for your Raspberry PI go to: <a href=\"https:\/\/www.raspberrypi.com\/software\/\">https:\/\/www.raspberrypi.com\/software\/<\/a> and download Raspberry PI Imager on a computer with microSD card reader. Follow the instructions on the website to install the Debian OS on a previously formatted microSD card using the Imager.<\/p>\n<figure id=\"attachment_265\" aria-describedby=\"caption-attachment-265\" style=\"width: 685px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-265\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/77ui_2_2156-15.jpg\" alt=\"\" width=\"685\" height=\"367\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/77ui_2_2156-15.jpg 685w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/77ui_2_2156-15-300x161.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/77ui_2_2156-15-65x35.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/77ui_2_2156-15-225x121.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/77ui_2_2156-15-350x188.jpg 350w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><figcaption id=\"caption-attachment-265\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 17. Raspberry PI Imager<\/span><\/em><\/figcaption><\/figure>\n<p style=\"text-align: justify\">2- Insert the microSD card into the RPI board\u2019s memory slot. Connect the power cable as well as the peripheral devices such as the monitor, mouse and keyboard to the RPI. You may need to use an HDMI to micro-HDMI converter to connect the screen to the RPI board.<\/p>\n<p style=\"text-align: justify\">3- Turn on the RPI board and follow the instructions to install the OS. Once the installation is complete, you can log in and see the OS desktop.<\/p>\n<figure id=\"attachment_267\" aria-describedby=\"caption-attachment-267\" style=\"width: 938px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-267\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u067e\u0627\u0631\u0633-\u0641\u0627\u0646\u0627\u0644-1.jpg\" alt=\"\" width=\"938\" height=\"479\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u067e\u0627\u0631\u0633-\u0641\u0627\u0646\u0627\u0644-1.jpg 938w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u067e\u0627\u0631\u0633-\u0641\u0627\u0646\u0627\u0644-1-300x153.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u067e\u0627\u0631\u0633-\u0641\u0627\u0646\u0627\u0644-1-768x392.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u067e\u0627\u0631\u0633-\u0641\u0627\u0646\u0627\u0644-1-65x33.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u067e\u0627\u0631\u0633-\u0641\u0627\u0646\u0627\u0644-1-225x115.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u067e\u0627\u0631\u0633-\u0641\u0627\u0646\u0627\u0644-1-350x179.jpg 350w\" sizes=\"auto, (max-width: 938px) 100vw, 938px\" \/><figcaption id=\"caption-attachment-267\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 18. RPI OS Desktop<\/span><\/em><\/figcaption><\/figure>\n<p style=\"text-align: justify\">4-\u00a0 Connect your RPI to an available Wi-Fi network. If you are connected to the same Wi-Fi network as your PC, you will be able to control your RPI remotely through your PC using \u201cRemote Desktop Connection\u201d. To connect the RPI to the Wi-Fi, on the top left corner of the OS desktop, open the terminal and type either of the following commands to get the IP address of your RPI: \u201chostname-I\u201d or \u201cifconfig\u201d.<\/p>\n<figure id=\"attachment_269\" aria-describedby=\"caption-attachment-269\" style=\"width: 1161px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-269\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1.jpg\" alt=\"\" width=\"1161\" height=\"222\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1.jpg 1161w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1-300x57.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1-1024x196.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1-768x147.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1-65x12.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1-225x43.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/\u0627\u062e\u0648\u0627\u0646-\u0627\u0644\u06a9\u062a\u0631\u06cc\u06a9-1-350x67.jpg 350w\" sizes=\"auto, (max-width: 1161px) 100vw, 1161px\" \/><figcaption id=\"caption-attachment-269\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 19. Obtaining the IP address of the RPI<\/span><\/em><\/figcaption><\/figure>\n<p style=\"text-align: justify\">5- On your PC, open \u201cRemote Desktop Connection\u201d and enter the IP address of your RPI to remotely connect to your RPI.<\/p>\n<figure id=\"attachment_272\" aria-describedby=\"caption-attachment-272\" style=\"width: 759px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-272\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/432mi2_1818-1.gif\" alt=\"\" width=\"759\" height=\"444\" \/><figcaption id=\"caption-attachment-272\" class=\"wp-caption-text\"><span style=\"color: #3366ff\"><em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 20. Remote Desktop Connection<\/em><\/span><\/figcaption><\/figure>\n<h1><strong><span style=\"color: #3366ff\">4.3 Connecting the RPI to TB<\/span><\/strong><\/h1>\n<p style=\"text-align: justify\">Once the RPI is booted, you will need to follow these instructions to get connected to the TB:<\/p>\n<p style=\"text-align: justify\">6- Before coding, you need to install the necessary Python packages on your RPI OS. For this purpose, click on the Command-line Terminal icon in the top menu bar (or choose Menu &gt; Accessories &gt; Terminal).<\/p>\n<figure id=\"attachment_278\" aria-describedby=\"caption-attachment-278\" style=\"width: 872px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-278\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-21.-Command-line-Terminal.jpg\" alt=\"\" width=\"872\" height=\"498\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-21.-Command-line-Terminal.jpg 872w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-21.-Command-line-Terminal-300x171.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-21.-Command-line-Terminal-768x439.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-21.-Command-line-Terminal-65x37.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-21.-Command-line-Terminal-225x128.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-21.-Command-line-Terminal-350x200.jpg 350w\" sizes=\"auto, (max-width: 872px) 100vw, 872px\" \/><figcaption id=\"caption-attachment-278\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 21. Command-line Terminal<\/span><\/em><\/figcaption><\/figure>\n<p style=\"text-align: justify\">This will open a window where you can enter the following commands:<\/p>\n<ul>\n<li style=\"text-align: justify\">Update and upgrade the OS: $ sudo apt update &amp;&amp; sudo apt upgrade -y<\/li>\n<\/ul>\n<figure id=\"attachment_291\" aria-describedby=\"caption-attachment-291\" style=\"width: 644px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-291\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-22.-Updating-the-RPI-OS.jpg\" alt=\"\" width=\"644\" height=\"433\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-22.-Updating-the-RPI-OS.jpg 644w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-22.-Updating-the-RPI-OS-300x202.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-22.-Updating-the-RPI-OS-65x44.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-22.-Updating-the-RPI-OS-225x151.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-22.-Updating-the-RPI-OS-350x235.jpg 350w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><figcaption id=\"caption-attachment-291\" class=\"wp-caption-text\"><span style=\"color: #3366ff\"><em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 22. Updating the RPI OS<\/em><\/span><\/figcaption><\/figure>\n<ul>\n<li>Install the \u201cpip\u201d package installer for Python: $ sudo apt install python3-pip<\/li>\n<\/ul>\n<figure id=\"attachment_290\" aria-describedby=\"caption-attachment-290\" style=\"width: 1163px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-290\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python.jpg\" alt=\"\" width=\"1163\" height=\"324\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python.jpg 1163w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python-300x84.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python-1024x285.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python-768x214.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python-65x18.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python-225x63.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-23.-Installing-the-pip-package-installer-for-Python-350x98.jpg 350w\" sizes=\"auto, (max-width: 1163px) 100vw, 1163px\" \/><figcaption id=\"caption-attachment-290\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 23. Installing the pip package installer for Python<\/span><\/em><\/figcaption><\/figure>\n<ul>\n<li>Check the pip version to make sure it is installed correctly: $ pip &#8211;version<\/li>\n<\/ul>\n<figure id=\"attachment_294\" aria-describedby=\"caption-attachment-294\" style=\"width: 1198px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-294\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version.jpg\" alt=\"\" width=\"1198\" height=\"224\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version.jpg 1198w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version-300x56.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version-1024x191.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version-768x144.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version-65x12.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version-225x42.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-24.-Checking-the-python3-pip-version-350x65.jpg 350w\" sizes=\"auto, (max-width: 1198px) 100vw, 1198px\" \/><figcaption id=\"caption-attachment-294\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 24. Checking the python3-pip version<\/span><\/em><\/figcaption><\/figure>\n<ul>\n<li>Now, you can install the MQTT library to link the RPI board to the platform over MQTT protocol: $ pip install paho-mqtt<\/li>\n<\/ul>\n<figure id=\"attachment_295\" aria-describedby=\"caption-attachment-295\" style=\"width: 1203px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-295\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package.jpg\" alt=\"\" width=\"1203\" height=\"306\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package.jpg 1203w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package-300x76.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package-1024x260.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package-768x195.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package-65x17.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package-225x57.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-25.-Installing-MQTT-package-350x89.jpg 350w\" sizes=\"auto, (max-width: 1203px) 100vw, 1203px\" \/><figcaption id=\"caption-attachment-295\" class=\"wp-caption-text\"><span style=\"color: #3366ff\"><em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 25. Installing MQTT package<\/em><\/span><\/figcaption><\/figure>\n<p style=\"text-align: justify\">7- Open Thonny Python IDE to start coding.<\/p>\n<p style=\"text-align: justify\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-274\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Med-2-1.jpg\" alt=\"\" width=\"35\" height=\"48\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Med-2-1.jpg 80w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Med-2-1-65x89.jpg 65w\" sizes=\"auto, (max-width: 35px) 100vw, 35px\" \/>\u00a0 \u00a0 \u00a0\u2192 Programmimg \u2192Thonny Python IDE<\/p>\n<p style=\"text-align: justify\">8- Copy and run the code which was described in the previous chapters to publish the sample temperature and humidity telemetry data to TB. Note that in this example, since our focus is on connecting the RPI board to the TB platform, we are just sending constant telemetry data. You may connect an environmental sensor such as DHT22 to your RPI board and transmit the real parameters captured by the senosr to the TB platform.<\/p>\n<figure id=\"attachment_289\" aria-describedby=\"caption-attachment-289\" style=\"width: 1053px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-289\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud.jpg\" alt=\"\" width=\"1053\" height=\"517\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud.jpg 1053w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud-300x147.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud-1024x503.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud-768x377.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud-65x32.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud-225x110.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-26.-Running-sample-code-on-RPI-to-send-telemetry-data-to-TB-cloud-350x172.jpg 350w\" sizes=\"auto, (max-width: 1053px) 100vw, 1053px\" \/><figcaption id=\"caption-attachment-289\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 26. Running sample code on RPI to send telemetry data to TB cloud<\/span><\/em><\/figcaption><\/figure>\n<p style=\"text-align: justify\">9- Go to TB and click on the device you created earlier to see the published telemetry data sent by RPI.<\/p>\n<figure id=\"attachment_285\" aria-describedby=\"caption-attachment-285\" style=\"width: 905px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-285\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-27.-Latest-telemetry-of-data-published-by-RPI.gif\" alt=\"\" width=\"905\" height=\"476\" \/><figcaption id=\"caption-attachment-285\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 27. Latest telemetry of data published by RPI<\/span><\/em><\/figcaption><\/figure>\n<p style=\"text-align: justify\">10- Now, you can create a dashboard using the pre-built widgets on TB. As it was explained earlier, you can add the thermometer gauge widget to exhibit the temperature value and the radial gauge widget to display the humidity.<\/p>\n<figure id=\"attachment_283\" aria-describedby=\"caption-attachment-283\" style=\"width: 693px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-283\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart.jpg\" alt=\"\" width=\"693\" height=\"462\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart.jpg 693w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart-300x200.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart-65x43.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart-225x150.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart-350x233.jpg 350w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><figcaption id=\"caption-attachment-283\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Figure 28. Adding thermometer gauge (right) and radial gauge (left)<\/span><\/em><\/figcaption><\/figure>\n<p style=\"text-align: justify\">11- Once you add the widgets, you will see the dashboard as illustrated below.<\/p>\n<figure id=\"attachment_297\" aria-describedby=\"caption-attachment-297\" style=\"width: 970px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-297\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-29.-TB-dashboard-gauges.jpg\" alt=\"\" width=\"970\" height=\"457\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-29.-TB-dashboard-gauges.jpg 970w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-29.-TB-dashboard-gauges-300x141.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-29.-TB-dashboard-gauges-768x362.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-29.-TB-dashboard-gauges-65x31.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-29.-TB-dashboard-gauges-225x106.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-29.-TB-dashboard-gauges-350x165.jpg 350w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><figcaption id=\"caption-attachment-297\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 29. TB dashboard gauges<\/span><\/em><\/figcaption><\/figure>\n<p style=\"text-align: justify\">12- The above gauges show the instantaneous telemetry data. In order to show the historical values, you can use the \u201cTimeseries Line Chart\u201d widget which give you the opportunity to represent several variables from different devices over the time.<\/p>\n<figure id=\"attachment_283\" aria-describedby=\"caption-attachment-283\" style=\"width: 693px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-283\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart.jpg\" alt=\"\" width=\"693\" height=\"462\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart.jpg 693w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart-300x200.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart-65x43.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart-225x150.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-30.-Timeseries-line-chart-350x233.jpg 350w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><figcaption id=\"caption-attachment-283\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 30. Timeseries line chart<\/span><\/em><\/figcaption><\/figure>\n<figure id=\"attachment_280\" aria-describedby=\"caption-attachment-280\" style=\"width: 981px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-280\" src=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-31.-Final-TB-dashboard-showing-latest-and-historical-telemetry-data.jpg\" alt=\"\" width=\"981\" height=\"386\" srcset=\"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-31.-Final-TB-dashboard-showing-latest-and-historical-telemetry-data.jpg 981w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-31.-Final-TB-dashboard-showing-latest-and-historical-telemetry-data-300x118.jpg 300w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-31.-Final-TB-dashboard-showing-latest-and-historical-telemetry-data-768x302.jpg 768w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-31.-Final-TB-dashboard-showing-latest-and-historical-telemetry-data-65x26.jpg 65w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-31.-Final-TB-dashboard-showing-latest-and-historical-telemetry-data-225x89.jpg 225w, https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-content\/uploads\/sites\/1962\/2023\/06\/Figure-31.-Final-TB-dashboard-showing-latest-and-historical-telemetry-data-350x138.jpg 350w\" sizes=\"auto, (max-width: 981px) 100vw, 981px\" \/><figcaption id=\"caption-attachment-280\" class=\"wp-caption-text\"><em><span style=\"color: #3366ff\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Figure 31. Final TB dashboard showing latest and historical telemetry data<\/span><\/em><\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n","protected":false},"author":1053,"menu_order":4,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-116","chapter","type-chapter","status-publish","hentry"],"part":3,"_links":{"self":[{"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/pressbooks\/v2\/chapters\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/wp\/v2\/users\/1053"}],"version-history":[{"count":25,"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/pressbooks\/v2\/chapters\/116\/revisions"}],"predecessor-version":[{"id":512,"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/pressbooks\/v2\/chapters\/116\/revisions\/512"}],"part":[{"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/pressbooks\/v2\/chapters\/116\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/pressbooks\/v2\/chapter-type?post=116"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/wp\/v2\/contributor?post=116"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/iotplatform\/wp-json\/wp\/v2\/license?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}