<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6802523224595585339</atom:id><lastBuildDate>Wed, 25 Mar 2026 10:50:54 +0000</lastBuildDate><category>Microchip</category><category>IOT</category><category>Arduino</category><category>Others</category><category>Python</category><category>ARM</category><category>Cortex-M3</category><category>MATLAB</category><category>Raspberry Pi</category><category>ESP32</category><category>LABVIEW</category><category>PIC18f4550</category><category>DHT11</category><category>Humdity</category><category>Nodemcu</category><category>PIC</category><category>Serial Communication</category><category>Temperature</category><category>Bluetooth</category><category>Distance</category><category>HID</category><category>LED</category><category>ThingSpeak</category><category>USB</category><category>Wireless</category><category>ADC</category><category>Color Sensing</category><category>DS1307</category><category>ESP8266</category><category>Extended-NEC</category><category>FFMPEG</category><category>HC-05</category><category>Led Matrix</category><category>Matrix Keypad</category><category>PCF8523</category><category>PIC16F877A</category><category>RTC</category><category>Relay</category><category>Sharp Sensor</category><category>Timer</category><category>UltraSonic Sensor</category><category>Voltmeter</category><category>WiFi</category><category>XC8</category><title>Embedded Laboratory</title><description></description><link>http://embeddedlaboratory.blogspot.com/</link><managingEditor>noreply@blogger.com (Embedded Laboratory)</managingEditor><generator>Blogger</generator><openSearch:totalResults>94</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-7757696539047330562</guid><pubDate>Sun, 10 Mar 2024 07:57:00 +0000</pubDate><atom:updated>2024-03-10T07:06:47.366-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">IOT</category><category domain="http://www.blogger.com/atom/ns#">Raspberry Pi</category><title>Install Mosquitto MQTT Broker on Raspberry Pi 5</title><description>&lt;p&gt;Hello Everyone, In this post I will show you guys how to install, test, and configure the Moqsuitto MQTT for MQTT communication on the newly launched &lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi 5&lt;/a&gt; board.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgChjTdM1Jm1pivPd_OB17DVCc9KweyUvaP2QWg0nH5D3zYAe1QlxlgvPH96y72FANIQlnRPW-DBCF44Q11h7iLAbsYTF5dsBCAlsibQ6qIZ693HEs68p8UHC0guBlhV7x6eQwOu8TxAGyoRoLEJJ_NVSztaiUi4P255doYpZWFeNWSJRF5152LvJlLq3o&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;909&quot; data-original-width=&quot;1644&quot; height=&quot;221&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgChjTdM1Jm1pivPd_OB17DVCc9KweyUvaP2QWg0nH5D3zYAe1QlxlgvPH96y72FANIQlnRPW-DBCF44Q11h7iLAbsYTF5dsBCAlsibQ6qIZ693HEs68p8UHC0guBlhV7x6eQwOu8TxAGyoRoLEJJ_NVSztaiUi4P255doYpZWFeNWSJRF5152LvJlLq3o=w400-h221&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This post will be the foundation for my upcoming Home Automation projects based on ESP32, &lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;, InfluxDB, and Grafana.&lt;p&gt;&lt;/p&gt;&lt;p&gt;In this post the Mosquitto broker will run on the &lt;a href=&quot;https://amzn.to/43iwHhp&quot;&gt;Raspberry Pi 5&lt;/a&gt;, which means that the devices connected on the same network can publish and subscribe, if you are looking for a Mosquitto broker that can be accessed globally over the internet then you need to look for options such as Cloud MQTT, Hive MQTT, Digital Ocean and others.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/FxqTSruDSV0&quot; width=&quot;320&quot; youtube-src-id=&quot;FxqTSruDSV0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.pcbway.com/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;div style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.pcbway.com/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;79&quot; data-original-width=&quot;640&quot; height=&quot;80&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEja55GlkLXVgJuK6dwvfx8hA_J7lTRSagRfKibGjhcdCB3R9sAIuMUywpiq2D2IBGMuSbUWSFLLklA3oR3k5jYz8usZW3G3enjdMOfCdEYa_s7XeurkICZ7t53u_3JhCwA4F1hDAR7Ffc0HwEkgL6_bnWQgI4pPb9KZOfp8IUKWZcIcSVW1PuXxFUitadQ=w640-h80&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;This post is sponsored by PCBWay, with more than a decade in the field of PCB prototype and fabrication, PCBWay is committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness, and any other demanding requests.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;As one of the most experienced PCB manufacturers in the World, PCBWay prides itself on being your best business partner as well as a good friend in every aspect of your PCB needs.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;MQTT Basic Concepts&lt;/h2&gt;&lt;p&gt;MQTT stands for&amp;nbsp;&lt;b&gt;Message Queuing Telemetry Transport&lt;/b&gt;. MQTT is a simple messaging&amp;nbsp;protocol, designed for constrained devices with low bandwidth. So, it is the perfect solution to exchange data between multiple IoT devices.&lt;br /&gt;MQTT communication works as a publish and subscribe system. Devices publish messages on a specific topic. All devices that are subscribed to that topic, will receive the message.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;In MQTT there are a few basic concepts that we need to understand, and they are as below.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Publish/Subscribe&lt;/li&gt;&lt;li&gt;Messages&lt;/li&gt;&lt;li&gt;Topics&lt;/li&gt;&lt;li&gt;Broker&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;MQTT Publish/Subscribe&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;In a publish and subscribe system, a device can publish a message on a topic, or it can be subscribed to a particular topic to receive messages.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi8ttZVnBXabDe0OfxKJgvjRVD__x_Z8J_l13hiyKgdOTL6gpU9jfaRP2pQ7bvxExPUIxFvL2SKCg6s_bCKQFLKLhJqUmRVcGGxb5g3ykxDKlIqqLtfl8wmUN0FuoxHOnm8_Nog-a73s7A3hybZl4o6PImwauJd6pjwc2gftxoE6E-tPenNWbFtbGsmV9s&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;170&quot; data-original-width=&quot;616&quot; height=&quot;110&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi8ttZVnBXabDe0OfxKJgvjRVD__x_Z8J_l13hiyKgdOTL6gpU9jfaRP2pQ7bvxExPUIxFvL2SKCg6s_bCKQFLKLhJqUmRVcGGxb5g3ykxDKlIqqLtfl8wmUN0FuoxHOnm8_Nog-a73s7A3hybZl4o6PImwauJd6pjwc2gftxoE6E-tPenNWbFtbGsmV9s=w400-h110&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;The above picture illustrates the simple publish and subscribe, here &quot;Device-1&quot; publishes on a topic, while &quot;Device-2&quot; is subscribed to the same topic that &quot;Device-1&quot; is publishing in, so &quot;Device-2&quot; will receive the message.&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;MQTT Messages&lt;/h3&gt;&lt;div&gt;Messages are the information that we want to exchange between the devices, it can be a message like a command, to turn on or off a relay, or data like sensor readings.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;MQTT Topics&lt;/h3&gt;&lt;div&gt;Topics are the way we register interest in incoming messages or how we specify where we want to publish the messages. Topics are represented with strings, and topics can be nested also with the forward slash.&lt;/div&gt;&lt;div&gt;For example &quot;MainTopic/SubTopic-1&quot;.&lt;/div&gt;&lt;div&gt;Please keep in mind that the topics are case-sensitive.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;MQTT Broker&lt;/h3&gt;&lt;div&gt;&lt;p&gt;The MQTT broker is responsible for receiving all messages, filtering them, deciding which device is interested in them, and publishing the message to all subscribed clients. There are several brokers available in the market, but we will be using the Mosquitto MQTT broker.&lt;/p&gt;&lt;p&gt;The Mosquitto MQTT broker can be installed on any PC with all major operating systems, but Raspberry Pi 5 is a very convenient choice, as normally we can&#39;t keep our PC on always but this is not the problem with the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;, make sure to observe the temperature of the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;&amp;nbsp;to avoid any damage, I will prepare an upcoming tutorial on this, and update links here once it is ready.&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Prerequisites&lt;/h2&gt;&lt;div&gt;Before continuing with this tutorial, you should be familiar with the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;&amp;nbsp;board and its operating system, and you need the following hardware.&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;&amp;nbsp;Board&lt;/li&gt;&lt;li&gt;Micro SD Card&lt;/li&gt;&lt;li&gt;Raspberry Pi Power Supply&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Installing Mosquitto Broker on Raspberry Pi OS&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Installing Mosquitto Broker is very simple, but before installing the Mosquitto first make sure that your Linux distribution is updated with the latest available version, and this can be done using the following commands.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;sudo apt update&lt;/div&gt;&lt;div&gt;sudo apt upgrade&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;These commands will update the Linux to the latest available version, and could take some time, but don&#39;t worry about this time.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Now use the following command to install the Mosquitto Broker and Clients.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;sudo apt install -y mosquitto mosquitto-clients&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Once the installation is completed, to make the Mosquitto auto starts when the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;&amp;nbsp;boots, you need to run the following command.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;sudo systemctl enable mosquitto.service&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Now type the following command to start the Mosquitto broker.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;mosquitto -v&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjPH-U84KoNGpsWHHfEqNLy3nkb2JTQW9LjEfjyDq32On_TsejdPpNsGvXC0KbgVOwKTYbPNo-JiWn26FVdG86Kf6TDiZytkg6DMORnZOecnJlevyfLMdlZl3sq63ajH9MgrpD6pRnMgrp8bfzwYFsID7k28IAwkgfuuiJBCxOWc-mYowSrZ1P2MWhB2AA&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;549&quot; data-original-width=&quot;1015&quot; height=&quot;216&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjPH-U84KoNGpsWHHfEqNLy3nkb2JTQW9LjEfjyDq32On_TsejdPpNsGvXC0KbgVOwKTYbPNo-JiWn26FVdG86Kf6TDiZytkg6DMORnZOecnJlevyfLMdlZl3sq63ajH9MgrpD6pRnMgrp8bfzwYFsID7k28IAwkgfuuiJBCxOWc-mYowSrZ1P2MWhB2AA=w400-h216&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Mosquitto Broker Running&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;This command will start the Mosquitto broker, and now we are good to proceed ahead with testing the &quot;Publish&quot; and &quot;Subscription&quot; of topics.&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;The above command also returns the version of the Mosquitto broker and will also prompt the message &lt;i&gt;&quot;Starting in local mode. Connections will only be possible from clients running on this machine. Create a configuration file that defines a listener to allow remote access&quot;&lt;/i&gt;.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;This is normal, this means that by default we can&#39;t communicate with the Mosquitto broker from other devices, this means that if you want an external device, for example, ESP32 to publish some message to the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;, then it is not possible with the default configuration, we need to update the configuration to allow this, and we will see this in the upcoming section. But before proceeding further let&#39;s check the &quot;Publish&quot; and &quot;Subscription&quot; of the messages.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;The following is the command to subscribe to the topics.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;mosquitto_sub -h &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;localhost&quot;&lt;/span&gt; -p &lt;span style=&quot;color: #b5cea8;&quot;&gt;1883&lt;/span&gt; -t &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;topic&quot;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Here, I am using the hostname &quot;localhost&quot; and port number 1883, which is the default port for Mosquitto MQTT, and the topic that I am subscribing to is the name &quot;topic&quot;, so whenever someone publishes some message with the topic name as &quot;topic&quot;, we see the message.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Similarly the following is the command to publish the message.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;mosquitto_pub -h &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;localhost&quot;&lt;/span&gt; -p &lt;span style=&quot;color: #b5cea8;&quot;&gt;1883&lt;/span&gt; -t &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;topic&quot;&lt;/span&gt; -m &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Hello World from Raspberry Pi 5&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;mosquitto_pub -h &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;localhost&quot;&lt;/span&gt; -p &lt;span style=&quot;color: #b5cea8;&quot;&gt;1883&lt;/span&gt; -t &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;topic&quot;&lt;/span&gt; -m &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Once Again, Hello World from Raspberry Pi 5&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;Here I am publishing the two messages, the following screenshot illustrates this whole transaction.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiNcGbxRzzvKz7wpTRX-fYEdhPST5m8saAa28I6_Mhv1NAPI6rGp8Uvg-OH1nnuMQ3LpYzn_xsKFmNXW4SqAydp8_uC7kvro85-NrKoBupGNWag3h-lUgQqy6rWMgxGoqjAfYxW32wmi_HxRbk_ddj5BPvarD7wAm32VkDF3nVn22O8Jhukw_J2L0NZi8U&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;884&quot; data-original-width=&quot;1045&quot; height=&quot;338&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiNcGbxRzzvKz7wpTRX-fYEdhPST5m8saAa28I6_Mhv1NAPI6rGp8Uvg-OH1nnuMQ3LpYzn_xsKFmNXW4SqAydp8_uC7kvro85-NrKoBupGNWag3h-lUgQqy6rWMgxGoqjAfYxW32wmi_HxRbk_ddj5BPvarD7wAm32VkDF3nVn22O8Jhukw_J2L0NZi8U=w400-h338&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Publish and Subscription&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Enabling Remote Access&lt;/h2&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;As mentioned above also, with the above setup other devices can&#39;t publish to the broker running on the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;&amp;nbsp;unless we update the &quot;MQTT Configuration&quot; file. In this tutorial, we will cover only the &quot;No Authentication&quot; configuration, in the future I will either update or create a new tutorial with &quot;User Based Authentication&quot; which is a more practical scenario.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;So as mentioned above we need to update the Mosquitto Broker &quot;MQTT Configuration&quot; file, which is usually present under the following path.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;/etc/mosquitto/mosquitto.conf&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;To open this file we will use the &quot;nano&quot; in-build text editor, and the command will look as follows.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;sudo nano /etc/mosquitto/mosquitto.conf&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;After opening the file, the content looks like this.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgKuJrpRDLNgm5NvRI9UdVxhLIi8eNmHegleNP5rkNZBDUW0_phrNj0OV5cviCz-FKFuYn7E2CTZaPp2ZGj_QPNalhHfcR72JBbjbePqWVhKHQ-Nxk_7ky7VAe4pb5xw6MS7lrLEQE25eRm9caZ53rh-uOeV3ZTsF5NCv_cX7h9Y2lAjyKS6pfpu3caWBY&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;457&quot; data-original-width=&quot;1029&quot; height=&quot;178&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgKuJrpRDLNgm5NvRI9UdVxhLIi8eNmHegleNP5rkNZBDUW0_phrNj0OV5cviCz-FKFuYn7E2CTZaPp2ZGj_QPNalhHfcR72JBbjbePqWVhKHQ-Nxk_7ky7VAe4pb5xw6MS7lrLEQE25eRm9caZ53rh-uOeV3ZTsF5NCv_cX7h9Y2lAjyKS6pfpu3caWBY=w400-h178&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;MQTT Global Configuration File&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;As you can see in this file, it is advised to create a local configuration file in the folder &quot;conf.d&quot;, so I will close this file by using &quot;Ctrl+X&quot; and then create a new MQTT configuration file using the following command.&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;sudo nano /etc/mosquitto/conf.d/mosquitto.conf&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;And this command will create a new file with the name &quot;mosquitto.conf&quot; inside the folder &quot;conf.d&quot;, inside this file we will specify the MQTT port number as 1883, and we will set the &quot;allow_anonymous&quot; setting to true, and after setting this, all devices shall be able to publish and subscribe to Mosquitto broker running on the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;listener &lt;span style=&quot;color: #b5cea8;&quot;&gt;1883&lt;/span&gt;&lt;/div&gt;&lt;div&gt;allow_anonymous true&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhUVVXnIAsIxbXMCaCQpDkgurdwamHHjq1P5MEwgJz9Wguy891rUdpa_ecP3rtt7SutHIyouOmrE5wvOMeURGe2xHac4ne5VamEZ7xc5hQ4LgNuTVuWnh4WknHL_yor2a-7S184QiLdBGsPFDW2wUevyjxBIpGHixEmdmr1fjXrmwsq-Bclpgs5z9ttKFg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;516&quot; data-original-width=&quot;618&quot; height=&quot;334&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhUVVXnIAsIxbXMCaCQpDkgurdwamHHjq1P5MEwgJz9Wguy891rUdpa_ecP3rtt7SutHIyouOmrE5wvOMeURGe2xHac4ne5VamEZ7xc5hQ4LgNuTVuWnh4WknHL_yor2a-7S184QiLdBGsPFDW2wUevyjxBIpGHixEmdmr1fjXrmwsq-Bclpgs5z9ttKFg=w400-h334&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Creating Mosquitto Configuration File&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiImEskkFw2p1R6tX8Buxj9_KrvNYri9BZuZ2fFrRttPeGrtHpM5zwZSL7eWp3GF3F32_FdVfd-_z2WGd4brr9VSALyqAbe_XywFkwyoJVZHtblLhJp43Qd6-fVCrIS2K1JEc6abmL6SvYL5PiLCU2iB2iDt_KmzSMv0G9QO_RNyWly-pkr5w5XLt5ClOQ&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;416&quot; data-original-width=&quot;1304&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiImEskkFw2p1R6tX8Buxj9_KrvNYri9BZuZ2fFrRttPeGrtHpM5zwZSL7eWp3GF3F32_FdVfd-_z2WGd4brr9VSALyqAbe_XywFkwyoJVZHtblLhJp43Qd6-fVCrIS2K1JEc6abmL6SvYL5PiLCU2iB2iDt_KmzSMv0G9QO_RNyWly-pkr5w5XLt5ClOQ=w640-h203&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Mosquitto Configuration File Creation Completed&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Once this file is created, we need to restart the &quot;Mosquitto&quot; so that it takes the latest configuration settings available from this newly created configuration file, and this can be done using the following command.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;sudo systemctl restart mosquitto.service&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Ideally, this command should work out of the box, but for me, it doesn&#39;t work, as you can see in the following image.&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhXk40_LbE4wmAoIJ6yweit4q7U4dao1XmLUIKt1q0Osv9LpEoxZTNgEFgcUWJXgOTJx9G7B3z8DpsKuR4rd7UqqhUsskfC_JfTOc9C5ptDa2cGepFj_buR0oOlQwGH9Jr3oR8K8SqidCfH4eMZLoixTODHLHmYAJOm8oDNiQT5H2Gbu4cu9IJfOCcWVYw&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;447&quot; data-original-width=&quot;1005&quot; height=&quot;178&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhXk40_LbE4wmAoIJ6yweit4q7U4dao1XmLUIKt1q0Osv9LpEoxZTNgEFgcUWJXgOTJx9G7B3z8DpsKuR4rd7UqqhUsskfC_JfTOc9C5ptDa2cGepFj_buR0oOlQwGH9Jr3oR8K8SqidCfH4eMZLoixTODHLHmYAJOm8oDNiQT5H2Gbu4cu9IJfOCcWVYw=w400-h178&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Error while Restarting Mosquitto Service&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To fix this problem there are multiple ways, the first is to restart the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;, after booting up it should work automatically, but sometimes it is not a good choice to restart the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;, in that case, I did is to first stop the service, and then disable the service, and then enable the service and then started the Mosquitto again, and for this, I have to use the following commands back to back.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;sudo systemctl stop mosquitto.service&lt;/div&gt;&lt;div&gt;sudo systemctl disable mosquitto.service&lt;/div&gt;&lt;div&gt;sudo systemctl enable mosquitto.service&lt;/div&gt;&lt;div&gt;mosquitto -v&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiHyPzrelIrA7fBJUyGbDebakLhllNE-3beUOrRBQkGdyjAAAxHOb4Sa43yh3ljCFSnljl4kAlDQFUKZqgVUjwqZ6gTJ_hLsp-lfFiOxU_RSclleNFpnpnbsZ31IDyfkhDQljAqHeJC7tdonStNc9j5NdPCgk8bDTkNzFnfosYGZWi2wh_jIF3EUPY6Tlc&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;453&quot; data-original-width=&quot;1004&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiHyPzrelIrA7fBJUyGbDebakLhllNE-3beUOrRBQkGdyjAAAxHOb4Sa43yh3ljCFSnljl4kAlDQFUKZqgVUjwqZ6gTJ_hLsp-lfFiOxU_RSclleNFpnpnbsZ31IDyfkhDQljAqHeJC7tdonStNc9j5NdPCgk8bDTkNzFnfosYGZWi2wh_jIF3EUPY6Tlc=w400-h180&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Stopping and Starting Mosquitto&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Once this is done the Mosquitto will start again, as shown below.&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi9ZJDEYhiiTw5TjL-zrsqf1ttKoF7lELAHxLQ_JcL-Kp90Diwm2pxjuTbc1AbEftjnaiyxxuTwB2KR2IF-skC6Wee98EU1Q4p_5bLDurgspo3E187rFajGDn94pnLAdSBOKf8Rj17uVvTA7rwEQ7BSzmlN7KnWM5NrSYc4AQD5adENV5nGhKSrzA3y33U&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;461&quot; data-original-width=&quot;1011&quot; height=&quot;183&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi9ZJDEYhiiTw5TjL-zrsqf1ttKoF7lELAHxLQ_JcL-Kp90Diwm2pxjuTbc1AbEftjnaiyxxuTwB2KR2IF-skC6Wee98EU1Q4p_5bLDurgspo3E187rFajGDn94pnLAdSBOKf8Rj17uVvTA7rwEQ7BSzmlN7KnWM5NrSYc4AQD5adENV5nGhKSrzA3y33U=w400-h183&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Mosquitto Running Again&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;And now it is possible to access the Mosquitto Broker running on&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;, from other devices on the same network, but if this is still not working, then I would suggest you guys restart the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;. In my case, this also doesn&#39;t work, but after restarting the Raspberry Pi 5, it started working.&lt;/div&gt;&lt;div&gt;Now to test, I will test using my Windows 11 laptop, which also has Mosquitto installed and running, I will use my Windows 11 command prompt to send a message over a topic named &quot;topic&quot;, to see if this is working.&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiv81jYFtQYNn37SPLlwjAu3nmXTMLWcO76TuTmzdJr9ZTRTp0i3QbP_1fx91ZvtV88qrevuO0LWm9y0PB4M8LgjZK6SIlocSamLQOwgXtlPvu8BK9a4fzO8h_jCaD8mR7nQR2o0iqYD5MhJlgr0Ho9bRT257iEOScioh5jyu_I-dFW61v1SfSOUNifUTI&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;911&quot; data-original-width=&quot;1183&quot; height=&quot;308&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiv81jYFtQYNn37SPLlwjAu3nmXTMLWcO76TuTmzdJr9ZTRTp0i3QbP_1fx91ZvtV88qrevuO0LWm9y0PB4M8LgjZK6SIlocSamLQOwgXtlPvu8BK9a4fzO8h_jCaD8mR7nQR2o0iqYD5MhJlgr0Ho9bRT257iEOScioh5jyu_I-dFW61v1SfSOUNifUTI=w400-h308&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Publishing Using Windows 11 to Raspberry Pi 5&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I used the same Publish and Subscribe commands, but instead of using the &quot;localhost&quot; name I used the IP address assigned to the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;, to find the IP address assigned you can check your router setting or type &quot;hostname -I&quot; to find this out. As you can see both publish and subscription works fine.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Conclusion&lt;/h2&gt;&lt;div&gt;We learned how to install the Mosquitto broker on the&amp;nbsp;&lt;a href=&quot;https://amzn.to/43iwHhp&quot; target=&quot;_blank&quot;&gt;Raspberry Pi&lt;/a&gt;&amp;nbsp;and also learned how to Publish and Subscribe topics on the local host and also from external devices such as Windows.&lt;/div&gt;&lt;div&gt;We will use this knowledge to build home automation projects for our needs in the future.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2024/03/install-mosquitto-mqtt-broker-on.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgChjTdM1Jm1pivPd_OB17DVCc9KweyUvaP2QWg0nH5D3zYAe1QlxlgvPH96y72FANIQlnRPW-DBCF44Q11h7iLAbsYTF5dsBCAlsibQ6qIZ693HEs68p8UHC0guBlhV7x6eQwOu8TxAGyoRoLEJJ_NVSztaiUi4P255doYpZWFeNWSJRF5152LvJlLq3o=s72-w400-h221-c" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-4591646623492840911</guid><pubDate>Tue, 27 Feb 2024 06:37:00 +0000</pubDate><atom:updated>2024-02-27T11:42:46.466-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ESP32</category><category domain="http://www.blogger.com/atom/ns#">IOT</category><title>Get Sensor Data and Controlling Devices Using ESP32 and Android Application over MQTT</title><description>&lt;div&gt;Hello everyone,&amp;nbsp;In this post I will explain the working of my project based on the ESP32 microcontroller. In this project, I will show you, how to control the devices and get sensor data using ESP32 microcontroller and MQTT. &lt;br /&gt;The following is a demo animation of this project.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiMfk631Laxo-2Ypo6CvGAJpWr7z13yhbyLBQ9HPwvkX5YF_V2pxkWh1kYyMQpkMoykFSt2mmvVmTKiW1Oy7A69llnEipH7sAXs2J2fBhqfv4gJ7ltGRy0VRQm_2ytnnvaxQE6iutLLhBYJcxCDxCqxohk_HMDKQ5QNFCCdxAZ11Z3W9hFxUarGsi2mNc/s620/96-ESP32MQTTApplicationControlGIF.gif&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;348&quot; data-original-width=&quot;620&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiMfk631Laxo-2Ypo6CvGAJpWr7z13yhbyLBQ9HPwvkX5YF_V2pxkWh1kYyMQpkMoykFSt2mmvVmTKiW1Oy7A69llnEipH7sAXs2J2fBhqfv4gJ7ltGRy0VRQm_2ytnnvaxQE6iutLLhBYJcxCDxCqxohk_HMDKQ5QNFCCdxAZ11Z3W9hFxUarGsi2mNc/w400-h225/96-ESP32MQTTApplicationControlGIF.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Project Demo&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;As you can see in the above animated image the ESP32 is connected with the DHT11 sensor to sense the temperature and humidity data and it is also connected with the TFT display, which is used to display the temperature and humidity values.&lt;/div&gt;&lt;div&gt;You can see on the display there are 2 LEDs, one is a normal Red LED and one is a RGB LED. I didn’t use the physical LEDs instead I am simulating the LEDs using the LVGL graphics library. There is a switch, which is used to control the single-color LED state.&lt;/div&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.pcbway.com/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;79&quot; data-original-width=&quot;640&quot; height=&quot;80&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEja55GlkLXVgJuK6dwvfx8hA_J7lTRSagRfKibGjhcdCB3R9sAIuMUywpiq2D2IBGMuSbUWSFLLklA3oR3k5jYz8usZW3G3enjdMOfCdEYa_s7XeurkICZ7t53u_3JhCwA4F1hDAR7Ffc0HwEkgL6_bnWQgI4pPb9KZOfp8IUKWZcIcSVW1PuXxFUitadQ=w640-h80&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;This post is sponsored by PCBWay, with more than a decade in the field of PCB prototype and fabrication, PCBWay is committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness, and any other demanding requests.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;As one of the most experienced PCB manufacturers in the World, PCBWay prides itself on being your best business partner as well as a good friend in every aspect of your PCB needs.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;I will use this block diagram to explain what is happening inside the system, as the first step the ESP32 will connect to the Wi-Fi router, and after the connection is successful, it will connect with the MQTT broker, once the connection is successful, it will start publishing the Sensor data to the broker.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5jw_iVsUdfhh5UCHeOxz3fYUis8F7eDPY5mSTv7bZoS9GiW76GTQQqb9NjKaLU8zF7dli9AbtXVh5om-_l4eCzZ48VMrNX6z4CkNz_gAPIiG0nbIjjS_lyyDX-jfio82RUqzfcZm5Dehfzu4TDYYYe-LZ_5wt4WOC72ypWoankuGeBF1BkWUM3Za88Pg/s4000/ESP32_MQTT_DeviceControl.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2250&quot; data-original-width=&quot;4000&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5jw_iVsUdfhh5UCHeOxz3fYUis8F7eDPY5mSTv7bZoS9GiW76GTQQqb9NjKaLU8zF7dli9AbtXVh5om-_l4eCzZ48VMrNX6z4CkNz_gAPIiG0nbIjjS_lyyDX-jfio82RUqzfcZm5Dehfzu4TDYYYe-LZ_5wt4WOC72ypWoankuGeBF1BkWUM3Za88Pg/w640-h360/ESP32_MQTT_DeviceControl.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Block Diagram&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;On the other hand, the application developed using the QT framework, will subscribe to this data, and display this on its application, similarly, we can control the LEDs from the application, using a normal switch which is used to control the red LED and also by using the sliders, with sliders we can generate a color, and the same color will be displayed on the ESP32 TFT screen.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9QfGc2IFe-I1Ds_NRJ9rUxJXwniBf9ilu0IWPp8R0A7ba8PuEmDKfOFL4HSiKVGxjdacJHrMXNTsRazoKNXeKBbJpSajgVol_PG-47LQsF7vMtreAeclB3-5z86jRl-0RcKBd0hZmgRanw77jlJrCUrlBAMZoLt-1XZTAy2YNb9LVMeB4aPV2g5sXwqU/s640/AndroidApp.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;640&quot; data-original-width=&quot;320&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9QfGc2IFe-I1Ds_NRJ9rUxJXwniBf9ilu0IWPp8R0A7ba8PuEmDKfOFL4HSiKVGxjdacJHrMXNTsRazoKNXeKBbJpSajgVol_PG-47LQsF7vMtreAeclB3-5z86jRl-0RcKBd0hZmgRanw77jlJrCUrlBAMZoLt-1XZTAy2YNb9LVMeB4aPV2g5sXwqU/s320/AndroidApp.png&quot; width=&quot;160&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;QT Android Application&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;The above image illustrates the user interface of the application is developed, this application is intentionally developed using the QT framework, so that it can run on all major operating systems like Windows, Android, Linux, and others, without any modifications, as QT is cross-platform.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;COMPONENTS NEEDED:&lt;/h3&gt;&lt;a href=&quot;https://amzn.to/3OLR3cM&quot;&gt;&lt;/a&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://amzn.to/3OLR3cM&quot;&gt;&lt;/a&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3OLR3cM&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://amzn.to/3OLR3cM&quot;&gt;ESP32 Development Board&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3uIs0k0&quot;&gt;ILI9341 TFT Display&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Breadboard and Jumper Wires&lt;/li&gt;&lt;li&gt;WiFi Router with which &lt;a href=&quot;https://amzn.to/3OLR3cM&quot;&gt;ESP32 &lt;/a&gt;can connect&lt;/li&gt;&lt;/ul&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKF_-fNiEruOkIqsi7RDKBetXslFmjaq-OsMxaN_phbTfW_1EEqQe4BI5YQ87LMC5AZqWLPamLo_u35q1TGmBnxClRn9TRP2v3T4AkA33hUChSke4wf0prJ6nQRzqmUEnqKh-AVWLeao4038bJKCOAy3D6VQ97J-XgawfCJvg-xbcB7ArAh8kIugfAqA/s800/DHT11_ILI9341_SPI_ESP32_Schematic.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;503&quot; data-original-width=&quot;800&quot; height=&quot;201&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKF_-fNiEruOkIqsi7RDKBetXslFmjaq-OsMxaN_phbTfW_1EEqQe4BI5YQ87LMC5AZqWLPamLo_u35q1TGmBnxClRn9TRP2v3T4AkA33hUChSke4wf0prJ6nQRzqmUEnqKh-AVWLeao4038bJKCOAy3D6VQ97J-XgawfCJvg-xbcB7ArAh8kIugfAqA/s320/DHT11_ILI9341_SPI_ESP32_Schematic.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Connection Diagram&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;From the above picture, the pinout is not visible properly, so you use the below-mentioned table for the connections.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn9db8dOBZDuaauIGv95_H3cDTtJK7tDucgiUPRWNfa6hokAVeY-o7UZZdG06jTStpT7mW0grwET1pu8f9T6bNiDywEwzoJUIppXdvGLQQ7BZdQTR5D-dsjvmS2nCG0bR-RxfZm480Xt-4GyRNWjcAbwzgdASHHowl7DONiV6HMAb44JuLqXUs7YcjwA/s594/ESP32_ILI9341_Touch_SPI_PinOut.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;411&quot; data-original-width=&quot;594&quot; height=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn9db8dOBZDuaauIGv95_H3cDTtJK7tDucgiUPRWNfa6hokAVeY-o7UZZdG06jTStpT7mW0grwET1pu8f9T6bNiDywEwzoJUIppXdvGLQQ7BZdQTR5D-dsjvmS2nCG0bR-RxfZm480Xt-4GyRNWjcAbwzgdASHHowl7DONiV6HMAb44JuLqXUs7YcjwA/w400-h276/ESP32_ILI9341_Touch_SPI_PinOut.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ILI9341 Connection with ESP32&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;SOFTWARE REQUIREMENTS:&lt;/h3&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;ESP-IDF (Espressif IoT Development Framework)&lt;/li&gt;&lt;li&gt;Time synchronization component from ESP-IDF&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3uIs0k0&quot;&gt;ILI9341 &lt;/a&gt;Display Driver (&lt;a href=&quot;https://www.youtube.com/watch?v=hiunemNTnbE&quot;&gt;Click Here&lt;/a&gt;)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;What is MQTT&lt;/h3&gt;MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for small-footprint devices with limited resources, such as sensors, microcontrollers, and mobile devices, to communicate over networks with varying levels of reliability.&lt;br /&gt;Here are some key features of MQTT:&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Lightweight: MQTT is designed to be lightweight and efficient, making it ideal for use in resource-constrained environments. The protocol uses a publish/subscribe messaging pattern that minimizes network bandwidth and device processing requirements.&lt;/li&gt;&lt;li&gt;Publish/Subscribe Model: MQTT follows a publish/subscribe messaging model, where devices (publishers) publish messages to topics, and other devices (subscribers) subscribe to topics to receive messages. This decoupling of publishers and subscribers enables flexible and scalable communication patterns.&lt;/li&gt;&lt;li&gt;Quality of Service (QoS): MQTT supports three levels of Quality of Service (QoS) to ensure message delivery reliability:&amp;nbsp;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;QoS 0 (At most once): The message is delivered at most once, without any acknowledgment or guarantee of delivery.&lt;/li&gt;&lt;li&gt;QoS 1 (At least once): The message is guaranteed to be delivered at least once, but duplicates may occur.&lt;/li&gt;&lt;li&gt;QoS 2 (Exactly once): The message is guaranteed to be delivered exactly once by using a two-step handshake mechanism.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Retained Messages: MQTT supports retained messages, which are special messages that are stored on the broker and delivered to new subscribers when they subscribe to a topic. Retained messages are useful for transmitting the most recent state or configuration information to new subscribers.&lt;/li&gt;&lt;li&gt;Last Will and Testament (LWT): MQTT allows clients to specify a Last Will and Testament message, which is published by the broker if a client unexpectedly disconnects. LWT messages are useful for detecting and handling client failures or disconnections.&lt;/li&gt;&lt;li&gt;Session Persistence: MQTT brokers can optionally support session persistence, which allows clients to resume their previous sessions and receive missed messages when they reconnect. Session persistence ensures reliable message delivery even in the presence of network interruptions or client disconnects.&lt;/li&gt;&lt;li&gt;Security: MQTT supports various security mechanisms, including username/password authentication, SSL/TLS encryption, and client certificates, to ensure secure communication between clients and brokers.&lt;/li&gt;&lt;/ul&gt;MQTT is widely used in Internet of Things (IoT) applications, home automation systems, industrial monitoring and control systems, and other distributed systems where lightweight and reliable messaging is required. Its simplicity, efficiency, and flexibility make it a popular choice for IoT communication protocols.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Project Explanation&lt;/h3&gt;&lt;div&gt;The following video demonstrates the complete working of the project.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/xyCAHg4jrOE&quot; width=&quot;320&quot; youtube-src-id=&quot;xyCAHg4jrOE&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;At power-up ESP32 will connect to the WiFi router and then it will connect with the MQTT broker, here I am using the free MQTT broker, for hobby based project the free MQTT broker such as &quot;test.mosquitto.org&quot; is sufficient, but keep in mind to not send any sensitive data.&lt;/li&gt;&lt;li&gt;Clicking on the &quot;connect&quot; button will connect the application to the MQTT broker and clicking on the &quot;disconnect&quot; button will disconnect it from the MQTT broker.&lt;/li&gt;&lt;li&gt;Moving the switch button to the &quot;On&quot; position in the application or on the TFT screen will turn on the LED on the ESP32, and moving the switch button to the &quot;Off&quot; position in the application or on the TFT position will turn it off.&lt;/li&gt;&lt;li&gt;The switch button in the application is synchronized with the switch button on the TFT display, which means if we change the state of the switch button on the TFT display, the state is adjusted in the application also.&lt;/li&gt;&lt;li&gt;Now coming to the sliders, there are three sliders to control the Red, Green, and Blue colors of the LED, as we change the slider, the colors are changed, and the same colors are displayed on the TFT screen, this feature can be used to control the RGB LED bulbs, a Home Automation project.&lt;/li&gt;&lt;li&gt;Moving the sliders to 0, 0, 0 position means LED off, which is represented as black color, similarly setting the value 255, 255, 255 will represent the full white color.&lt;/li&gt;&lt;li&gt;Sometimes you might feel that the color generated on the application does not exactly match the color on display, but this is due to the camera recording, with naked eyes this looks exactly similar.&lt;/li&gt;&lt;li&gt;Since we are using the QT framework the same application works the same on Windows, Android, and Linux platforms, I have tested this on Windows and Android, but I am very sure that it will work on other platforms also without any modification.&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Conclusion&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;This is a small project made by using ESP32, DHT11, and ILI9341 display controllers, the project can be extended to make a full home automation project, where sensor data from several devices can be published and displayed on the applications, in future my plan is to visualize this whole data on Grafana as a dashboard, similar to this project.&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://youtu.be/LatI7kNxGmc?si=5Xq6ZD8In4cV4KIN&quot; target=&quot;_blank&quot;&gt;Weather Monitoring System Using ESP32 and InfluxDB&lt;/a&gt;&lt;/div&gt;&lt;div&gt;The code for this project can be downloaded from the following links.&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/xpress-embedo/ESP32/tree/master/ESP-IDF/ESP32_MQTT&quot; target=&quot;_blank&quot;&gt;ESP32 ESP-IDF Project Code&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/xpress-embedo/Qt/tree/master/Projects/MQTT_DeviceControl&quot; target=&quot;_blank&quot;&gt;QT Project Code&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2024/02/get-sensor-data-and-controlling-devices.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiMfk631Laxo-2Ypo6CvGAJpWr7z13yhbyLBQ9HPwvkX5YF_V2pxkWh1kYyMQpkMoykFSt2mmvVmTKiW1Oy7A69llnEipH7sAXs2J2fBhqfv4gJ7ltGRy0VRQm_2ytnnvaxQE6iutLLhBYJcxCDxCqxohk_HMDKQ5QNFCCdxAZ11Z3W9hFxUarGsi2mNc/s72-w400-h225-c/96-ESP32MQTTApplicationControlGIF.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-5038649030553204303</guid><pubDate>Fri, 16 Feb 2024 21:28:00 +0000</pubDate><atom:updated>2024-02-17T03:28:15.212-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ESP32</category><category domain="http://www.blogger.com/atom/ns#">IOT</category><title>Analog Clock Using ESP32 with SNTP Time Synchronization</title><description>&lt;p&gt;Analog clocks have a timeless appeal, and adding internet-based time synchronization can make them even more fascinating.&amp;nbsp;&lt;/p&gt;&lt;p&gt;In this tutorial, we&#39;ll utilize the ESP-IDF framework and an &lt;a href=&quot;https://amzn.to/3uIs0k0&quot; target=&quot;_blank&quot;&gt;ILI9341 &lt;/a&gt;display controller to create a simple analog clock synchronized with accurate time obtained via SNTP, for this post I am using India&#39;s time zone, but this can be easily changed to any other time zone. I am using the LVGL graphics library, some image assets for the background, and some images for displaying the hours, minutes, and seconds dials.&lt;/p&gt;&lt;p&gt;The following image illustrates the demo of this small project, as you can see the &lt;a href=&quot;https://amzn.to/3OLR3cM&quot; target=&quot;_blank&quot;&gt;ESP32 &lt;/a&gt;automatically synchronizes the time in India using the NTP servers.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdOu3VoRnuOSkIZFWLVyPkIVR8MJIvtvKH-KQCxkP-PZKZ7Ex-m9QXvIn-afBr8Dgu9oRIg56SmSIs3nxKyrF-a-VjBNY7U72OZgY6etgeF3pDScZyTKruSZeEWHJXRwyl3-4JEkYpi4-tW49WzO4NBNGjTbSO6eL3lekiUYamnyaYgCRs_edM7Tbq_OU/s480/AnalogClockUsingESP32.gif&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;270&quot; data-original-width=&quot;480&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdOu3VoRnuOSkIZFWLVyPkIVR8MJIvtvKH-KQCxkP-PZKZ7Ex-m9QXvIn-afBr8Dgu9oRIg56SmSIs3nxKyrF-a-VjBNY7U72OZgY6etgeF3pDScZyTKruSZeEWHJXRwyl3-4JEkYpi4-tW49WzO4NBNGjTbSO6eL3lekiUYamnyaYgCRs_edM7Tbq_OU/s320/AnalogClockUsingESP32.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Demo Application&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&quot;text-align: right;&quot;&gt;&lt;a href=&quot;https://www.pcbway.com/&quot; style=&quot;font-weight: 700; text-align: center;&quot; target=&quot;_blank&quot;&gt;&lt;img data-original-height=&quot;90&quot; data-original-width=&quot;728&quot; height=&quot;79&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEja55GlkLXVgJuK6dwvfx8hA_J7lTRSagRfKibGjhcdCB3R9sAIuMUywpiq2D2IBGMuSbUWSFLLklA3oR3k5jYz8usZW3G3enjdMOfCdEYa_s7XeurkICZ7t53u_3JhCwA4F1hDAR7Ffc0HwEkgL6_bnWQgI4pPb9KZOfp8IUKWZcIcSVW1PuXxFUitadQ=w640-h79&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;i&gt;This post is sponsored by PCBWay, with more than a decade in the field of PCB prototype and fabrication, PCBWay is committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness, and any other demanding requests.&lt;br /&gt;As one of the most experienced PCB manufacturers in the World, PCBWay prides itself on being your best business partner as well as a good friend in every aspect of your PCB needs.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;The following is the video of this project on YouTube.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/RO30kXc-ogI&quot; width=&quot;320&quot; youtube-src-id=&quot;RO30kXc-ogI&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Understanding SNTP and NTP Servers:&lt;/h2&gt;&lt;div&gt;NTP (Network Time Protocol) and SNTP (Simple Network Time Protocol) are protocols used for synchronizing clocks over a computer network. They allow devices to obtain accurate time information from designated time servers.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;NTP Servers:&lt;/h3&gt;&lt;div&gt;NTP servers are computers equipped with highly precise atomic clocks or GPS receivers. These servers are responsible for maintaining accurate time and distributing it to clients over a network. NTP servers form a hierarchical structure, with higher-stratum servers synchronizing with lower-stratum servers to ensure accuracy and reliability.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Stratum Levels&lt;/b&gt;: NTP servers are categorized into strata, with Stratum 0 being the most accurate time source (e.g., atomic clocks or GPS satellites) and Stratum 15 being the least accurate. Stratum 1 servers directly synchronize with Stratum 0 sources, while lower-stratum servers synchronize with higher-stratum servers in a hierarchical manner.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Public NTP Servers&lt;/b&gt;: Public NTP servers are maintained by organizations and institutions worldwide, offering free access to accurate time information. These servers are commonly used by devices connected to the internet for time synchronization. In this post, I will be using one of the public NTP servers.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Private NTP Servers&lt;/b&gt;: Organizations may deploy private NTP servers within their networks for internal time synchronization. These servers can synchronize with public NTP servers or higher-stratum servers within the organization&#39;s network. These types of servers are used by companies.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;SNTP Servers:&lt;/h3&gt;&lt;div&gt;SNTP (Simple Network Time Protocol) is a lightweight version of NTP designed for simpler systems or applications where high accuracy is not critical. SNTP clients are capable of synchronizing their clocks with SNTP servers using a simplified subset of NTP functionality.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Synchronization Process&lt;/b&gt;: SNTP clients periodically query SNTP servers for time updates. The servers respond with the current time information, allowing clients to adjust their clocks accordingly. Unlike NTP, SNTP does not perform complex clock synchronization algorithms and does not maintain strict synchronization accuracy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Usage&lt;/b&gt;: SNTP is commonly used in embedded systems, IoT devices, and applications where lightweight time synchronization is sufficient. While it may not provide the same level of accuracy as NTP, it is suitable for many practical scenarios.&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Components Needed:&lt;/h2&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3OLR3cM&quot; target=&quot;_blank&quot;&gt;ESP32 Development Board&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3uIs0k0&quot; target=&quot;_blank&quot;&gt;ILI9341 TFT Display&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Breadboard and Jumper Wires&lt;/li&gt;&lt;li&gt;WiFi Router with which &lt;a href=&quot;https://amzn.to/3OLR3cM&quot; target=&quot;_blank&quot;&gt;ESP32 &lt;/a&gt;can connect&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Software Requirements:&lt;/h2&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;ESP-IDF (Espressif IoT Development Framework)&lt;/li&gt;&lt;li&gt;Time synchronization component from ESP-IDF&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3uIs0k0&quot; target=&quot;_blank&quot;&gt;ILI9341 &lt;/a&gt;Display Driver (&lt;a href=&quot;https://www.youtube.com/watch?v=hiunemNTnbE&quot; target=&quot;_blank&quot;&gt;Click Here&lt;/a&gt;)&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Software Development&lt;/h2&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;If you are following my blog and YouTube videos, you can use any of the following posts to reuse the existing modules, such as code to connect with the WiFi router, &lt;a href=&quot;https://amzn.to/3uIs0k0&quot; target=&quot;_blank&quot;&gt;ILI9341 &lt;/a&gt;drivers, and the LVGL integration.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2024/02/visualizing-temperature-and-humidity.html&quot; target=&quot;_blank&quot;&gt;Visualizing Temperature and Humidity Data on Display and ThingSpeak using ESP-IDF&lt;/a&gt;&lt;/h4&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2023/08/building-weather-station-web-server.html&quot; target=&quot;_blank&quot;&gt;Building a Weather Station Web Server with OTA Updates Using ESP32 and ESP-IDF Framework&lt;/a&gt;&lt;/h4&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2023/01/temperature-and-humidity-graph-using.html&quot; target=&quot;_blank&quot;&gt;Temperature and Humidity Graph Using ESP32 ILI9341 DHT11 and LVGL&lt;/a&gt;&lt;/h4&gt;&lt;div&gt;I prepared a simple activity diagram to depict what is happening inside the software.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/doc/ActivityDiagram.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;499&quot; data-original-width=&quot;800&quot; height=&quot;399&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/doc/ActivityDiagram.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Activity Diagram&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;The project is divided into three tasks, the first is the &quot;Main Task&quot; that triggers the other two tasks i.e. &quot;SNTP&quot; task and the &quot;GUI Manager&quot; task.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Main Task&lt;/h3&gt;&lt;div&gt;The main task is very simple in nature, it starts the GUI manager task, which in turn displays the busy indicator animation, that the &lt;a href=&quot;https://amzn.to/3OLR3cM&quot; target=&quot;_blank&quot;&gt;ESP32 &lt;/a&gt;is trying to connect with the WiFi router. Once the router is connected, it triggers an event to the GUI manager to task, to update the labels and indicate that now we are trying to connect with the SNTP server, and here we trigger the SNTP task.&lt;/div&gt;&lt;div&gt;The following is the source for the &quot;Main&quot; task.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;app_main&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Disable default gpio logging messages&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_log_level_set&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;gpio&quot;&lt;/span&gt;, ESP_LOG_NONE);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// disable default wifi logging messages&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_log_level_set&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;wifi&quot;&lt;/span&gt;, ESP_LOG_NONE);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_ERR_NVS_NO_FREE_PAGES &lt;span style=&quot;color: #d4d4d4;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_ERR_NVS_NEW_VERSION_FOUND)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_erase&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// start the GUI manager&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_start&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// wifi not connected, connect with WiFi (it will take some time)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;app_connect_wifi&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_status&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_send_event&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;GUI_MNG_EV_WIFI_CONNECTED&lt;/span&gt;, (&lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;)&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;WiFi connected, now synchronizing with NTP server.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// connection establish, start the SNTP task&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sntp_time_sync_start&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// check if synchronization with NTP server is cone or not&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_time_sync&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sntp_time_sync_get_time_tm&lt;/span&gt;( &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_year&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2016&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1900&lt;/span&gt;) )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_send_event&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;GUI_MNG_EV_SNTP_SYNC&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Time Synchronization done move to next screen.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_time_sync&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// now start a periodic timer to update the clock every second&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Tod Update timer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_timer_create_args_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tod_increment_timer_args&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .callback &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;tod_increment&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .name &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ToD Increment&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_timer_handle_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tod_increment_timer&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_timer_create&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tod_increment_timer_args&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tod_increment_timer&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_timer_start_periodic&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tod_increment_timer&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;TOD_INCREMENT_PERIOD_MS&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1000&lt;/span&gt;));&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp;// here time is in micro seconds&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Time not synchronize, will try again..&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_sync_counter&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_sync_counter&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;SNTP_TIME_SYNC&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_sync_counter&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Synchronizing Time&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sntp_time_sync_get_time_tm&lt;/span&gt;( &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// common delay for both scenarios&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelay&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;MAIN_TASK_TIME&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt;portTICK_PERIOD_MS);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;The following are the key points from the above program.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Connect with the Wi-Fi router&lt;/li&gt;&lt;li&gt;Once the connection is successful send the event to the GUI Manager task to update the graphics&lt;/li&gt;&lt;li&gt;Once the connection is successful start the SNTP task.&lt;/li&gt;&lt;li&gt;Once the connection with the NTP server is established and we get the valid date and time, post another event to the GUI manager task to update the graphics and display the analog clock&lt;/li&gt;&lt;li&gt;Start a 1-second timer, using the ESP-IDF timer software module, this timer module will increment the time by one second, and post the event to the graphical module to update the Analog clock.&lt;/li&gt;&lt;li&gt;In the main task itself, after every 1 minute, the time is synchronized with the NTP server.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;SNTP Task&lt;/h3&gt;&lt;div&gt;In the SNTP task, we configure the SNTP software module to synchronize India&#39;s time, and then we try to obtain the time every 1 minute.&lt;/div&gt;&lt;div&gt;The following is the code for the &quot;SNTP&quot; task.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@brief&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; SNTP Time Sync Task&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pvParameter&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sntp_time_sync_task&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pvParameter&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sntp_time_sync_obtain_time&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelay&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt;portTICK_PERIOD_MS);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelete&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the SNTP task function, we do the following things.&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Every 10 seconds (this can be variable also, my recommendation is to use 1 minute, as in the Main task we are getting the time after every minute), and we try to get the time information from the NTP server.&lt;/li&gt;&lt;li&gt;But at power-up the time is not correct this can be checked by getting the value year value.&lt;/li&gt;&lt;li&gt;If the year values are out-of-range, we initialize the SNTP software mode in polling mode and update the server name as &quot;pool.ntp.org&quot;, this is a free public NTP server, which we mentioned above, and once this is done, initialize the SNTP module by calling the function &quot;sntp_init&quot;.&lt;/li&gt;&lt;li&gt;Once the above step is done, we will set the India time zone as shown below.&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// set the local time zone (this is the Indian Time Zone)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setenv&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;TZ&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;IST-5:30&quot;&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;tzset&lt;/span&gt;();&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;Once this is done, we will try again to obtain the time, and since the connection is established, we will get the correct time from the NTP server.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;GUI Task&lt;/h3&gt;&lt;div&gt;The Graphical task is similar to the previous projects, here one of the important things is to develop the graphics, like the background, and dials for the clock, which can be done in tools like &quot;Inkscape&quot; etc, unfortunately this is not my expertise area, so I downloaded these graphics from online, there are several websites which provide free graphics. The following are the graphics that I used to make the analog clock.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/square-line/assets/bg.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;240&quot; data-original-width=&quot;240&quot; height=&quot;200&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/square-line/assets/bg.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Background for Analog Clock&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/square-line/assets/clock_hour.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;87&quot; data-original-width=&quot;19&quot; height=&quot;87&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/square-line/assets/clock_hour.png&quot; width=&quot;19&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Dial for Hour Hand of Analog Clock&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/square-line/assets/clock_min.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;115&quot; data-original-width=&quot;19&quot; height=&quot;115&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/square-line/assets/clock_min.png&quot; width=&quot;19&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Dial for Minute Hand of Analog Clock&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/square-line/assets/clock_sec.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;139&quot; data-original-width=&quot;11&quot; height=&quot;139&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/ESP32_Clock/square-line/assets/clock_sec.png&quot; width=&quot;11&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Dial for Second Hand of Analog Clock&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div&gt;Then all of these three dials are combined together and every second is updated, using the following code.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_update_time&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pData&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;tm&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;tm&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;)&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pData&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// one second increment is equals to 6 degrees, full round is 360 and total&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// seconds is 60, hence 360/60 = 6 and then for LVGL * 10&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;seconds_angle&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int16_t&lt;/span&gt;)(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_sec&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;60&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// same as seconds for minutes&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;minute_angle&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &amp;nbsp;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int16_t&lt;/span&gt;)(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_min&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;60&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// one hour increment is equal to 30 degrees, full round is 360 degree &amp;amp; total&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// hours is 12, hence 360/12 = 30 degrees, and then for LVGL x 10&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// also compensate for minute changes also, hour angle = hour*30 + (minute/60)*30 and then for LVGL multiply by 10&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// hour angle = (hour*30 + (minute*30/60))*10 =&amp;gt; this 10 is for LVGL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// simplified as = hour*30*10 + minute*300/60&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// further simplified as = hour*300 + minute*5&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;hour_angle&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int16_t&lt;/span&gt;)((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_hour&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;300&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_min&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Time Values: &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_hour&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_min&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_sec&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Time Angles: &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;hour_angle&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;minute_angle&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;seconds_angle&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_img_set_angle&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui_imgSecond&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;seconds_angle&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_img_set_angle&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui_imgSecDot&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;seconds_angle&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_img_set_angle&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui_imgMinute&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;minute_angle&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_img_set_angle&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui_imgHour&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;hour_angle&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The above code is executed every second because an event is triggered from the &quot;Main&quot; task every second to update the display, as shown below.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@brief&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; Increment Time of Day every second&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;In this function second value is updated and event is posted to gui&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;manager, so that it can update seconds dial&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arg&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;tod_increment&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arg&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_sec&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// this is temporary alignment, in actual this will be updated with ntp sync&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_sec&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;60&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_sec&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_min&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_min&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;60&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_min&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_hour&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_hour&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_hour&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_send_event&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;GUI_MNG_EV_TIME_UPDATE&lt;/span&gt;, (&lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;)&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_info&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;  ESP_LOGI&lt;/span&gt;(TAG, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;1sec Event to update display&quot;&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;

Conclusion&lt;/h2&gt;&lt;div&gt;You can download the complete code from the GitHub page by &lt;a href=&quot;https://github.com/xpress-embedo/ESP32/tree/master/ESP-IDF/ESP32_Clock&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;clicking here&lt;/b&gt;&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;So with this project, you have now synchronized the time just like the smartphones from the NTP servers.&lt;/div&gt;&lt;div&gt;This project can be further updated to synchronize and display the time of various locations by setting the respective time zone, and also a digital clock shall be added, in case someone wants to view the time using a digital clock.&lt;/div&gt;&lt;div&gt;In case you have some doubts or comments regarding this project, feel free to use the comment section.&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2024/02/analog-clock-using-esp32-with-sntp-time.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdOu3VoRnuOSkIZFWLVyPkIVR8MJIvtvKH-KQCxkP-PZKZ7Ex-m9QXvIn-afBr8Dgu9oRIg56SmSIs3nxKyrF-a-VjBNY7U72OZgY6etgeF3pDScZyTKruSZeEWHJXRwyl3-4JEkYpi4-tW49WzO4NBNGjTbSO6eL3lekiUYamnyaYgCRs_edM7Tbq_OU/s72-c/AnalogClockUsingESP32.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-6257266934666235560</guid><pubDate>Sat, 10 Feb 2024 08:11:00 +0000</pubDate><atom:updated>2024-02-10T05:49:43.937-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DHT11</category><category domain="http://www.blogger.com/atom/ns#">ESP32</category><category domain="http://www.blogger.com/atom/ns#">IOT</category><category domain="http://www.blogger.com/atom/ns#">ThingSpeak</category><title>Visualizing Temperature and Humidity Data on Display and ThingSpeak using ESP-IDF</title><description>In this post, I will demonstrate how we can use the &lt;a href=&quot;https://amzn.to/3HPGhQ4&quot;&gt;ESP32&lt;/a&gt; module to sense the temperature and humidity data from the &lt;a href=&quot;https://amzn.to/3YzITaO&quot;&gt;DHT11&lt;/a&gt; sensor and then display this data on the &lt;a href=&quot;https://amzn.to/3OyGn1d&quot; target=&quot;_blank&quot;&gt;ILI9341&lt;/a&gt;-based display module and also send this data to ThingSpeak cloud for visualization.&lt;div&gt;For visualization on the display, I am using the LVGL library, and to send data to the ThingSpeak cloud, I am using the ESP-IDF IOT Framework, not the Arduino.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/feature/GA-12-Send-the-measured-Temperature-and-Humidity-to-ThingSpeak-IOT-Cloud/ESP-IDF/LVGL_TemperatureHumidity/doc/TemperatureAndHumidityThingSpeak.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;398&quot; data-original-width=&quot;800&quot; height=&quot;318&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/feature/GA-12-Send-the-measured-Temperature-and-Humidity-to-ThingSpeak-IOT-Cloud/ESP-IDF/LVGL_TemperatureHumidity/doc/TemperatureAndHumidityThingSpeak.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Temperature and Humidity Data Visualization on ThingSpeak&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/LVGL_TemperatureHumidity/doc/Temp%26HumidityOnDisplay.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;509&quot; data-original-width=&quot;688&quot; height=&quot;296&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/LVGL_TemperatureHumidity/doc/Temp%26HumidityOnDisplay.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Temperature and Humidity Data Visualization on TFT&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;You can watch the below video or read the post.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/ZVSL4IXyavU&quot; width=&quot;320&quot; youtube-src-id=&quot;ZVSL4IXyavU&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://www.pcbway.com/&quot; style=&quot;font-weight: 700; text-align: center;&quot; target=&quot;_blank&quot;&gt;&lt;img data-original-height=&quot;90&quot; data-original-width=&quot;728&quot; height=&quot;79&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEja55GlkLXVgJuK6dwvfx8hA_J7lTRSagRfKibGjhcdCB3R9sAIuMUywpiq2D2IBGMuSbUWSFLLklA3oR3k5jYz8usZW3G3enjdMOfCdEYa_s7XeurkICZ7t53u_3JhCwA4F1hDAR7Ffc0HwEkgL6_bnWQgI4pPb9KZOfp8IUKWZcIcSVW1PuXxFUitadQ=w640-h79&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;This post is sponsored by PCBWay, with more than a decade in the field of PCB prototype and fabrication, PCBWay is committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness, and any other demanding requests.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;As one of the most experienced PCB manufacturers in the World, PCBWay prides itself on being your best business partner as well as a good friend in every aspect of your PCB needs.&lt;/i&gt;&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Prerequisite for this Tutorial&lt;/h3&gt;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot;&gt;&lt;/a&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot;&gt;&lt;/a&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot;&gt;ESP32&lt;/a&gt; Board&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3YzITaO&quot;&gt;DHT11&lt;/a&gt; Sensor&lt;/li&gt;&lt;li&gt;ILI9341 Based Display&lt;/li&gt;&lt;li&gt;Some Cables&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;If you are interested in Arduino-based tutorials, then there are some available on the blog itself, you can get help from it to build your project using Arduino, but this post uses the ESP-IDF and is written in &quot;Embedded-C&quot; programming language.&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2023/01/temperature-and-humidity-graph-using.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Temperature and Humidity Graph Using LVGL and ESP32 Using Arduino&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2022/12/weather-monitoring-using-esp32-and.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Weather Monitoring Using ESP32 and InfluxDB Using Arduino&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2016/10/posting-dht11-values-to-thingspeak.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Sending Temperature and Humidity Data to ThingSpeak using NodeMCU using Arduino&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The following is the connection diagram.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKF_-fNiEruOkIqsi7RDKBetXslFmjaq-OsMxaN_phbTfW_1EEqQe4BI5YQ87LMC5AZqWLPamLo_u35q1TGmBnxClRn9TRP2v3T4AkA33hUChSke4wf0prJ6nQRzqmUEnqKh-AVWLeao4038bJKCOAy3D6VQ97J-XgawfCJvg-xbcB7ArAh8kIugfAqA/s800/DHT11_ILI9341_SPI_ESP32_Schematic.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;503&quot; data-original-width=&quot;800&quot; height=&quot;201&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKF_-fNiEruOkIqsi7RDKBetXslFmjaq-OsMxaN_phbTfW_1EEqQe4BI5YQ87LMC5AZqWLPamLo_u35q1TGmBnxClRn9TRP2v3T4AkA33hUChSke4wf0prJ6nQRzqmUEnqKh-AVWLeao4038bJKCOAy3D6VQ97J-XgawfCJvg-xbcB7ArAh8kIugfAqA/s320/DHT11_ILI9341_SPI_ESP32_Schematic.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Connection Diagram&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The following is the Activity Diagram illustrating the software module arrangements.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/feature/GA-12-Send-the-measured-Temperature-and-Humidity-to-ThingSpeak-IOT-Cloud/ESP-IDF/LVGL_TemperatureHumidity/doc/ActivityDiagram.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;395&quot; data-original-width=&quot;800&quot; height=&quot;316&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/feature/GA-12-Send-the-measured-Temperature-and-Humidity-to-ThingSpeak-IOT-Cloud/ESP-IDF/LVGL_TemperatureHumidity/doc/ActivityDiagram.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Activity Diagram&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;What is ThingSpeak?&lt;/h3&gt;ThingSpeak is an IoT platform for data collection and analytics that serves as a bridge connecting edge node devices such as temperature, humidity, pressure, etc. sensors to collect data and data exploratory analysis software to analyze data.&lt;br /&gt;ThingSpeak serves as the data collector which collects data from edge node devices (ESP32 in this case) and also enables the data to be pulled into a software environment for historical data analysis.&lt;/div&gt;&lt;div&gt;The primary element of ThingSpeak activity is the channel, which contains data fields, location fields, and a status field. After you create a ThingSpeak channel, you can write data to the channel, process and view the data with MATLAB code (which is not the scope of this post), and react to the data with tweets and other alerts.&lt;br /&gt;The typical ThingSpeak workflow lets you:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Create a Channel and collect data&lt;/li&gt;&lt;li&gt;Analyze and Visualize the data&lt;/li&gt;&lt;li&gt;Act on the data using any of several Apps.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I am not going to tell you how to create an account on ThingSpeak, it&#39;s a very trivial process, and you just need to create an account using your email ID, and then create a channel with two fields, here I created two fields, one for temperature and another for humidity, in case you are using some other sensor, you can update the fields accordingly.&lt;/div&gt;So in the post, we will measure the temperature and humidity values using a DHT11 sensor with the help of an ESP32 module and then send these values to the ThingSpeak channel, by doing this you can see the temperature and humidity values of your home from any corner of the world using ThingSpeak.&lt;/div&gt;&lt;div&gt;Locally we will also display the temperature and humidity data in the form of labels and graphs on TFT display.&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Interfacing with DHT11 Sensor&lt;/h3&gt;&lt;div&gt;As a first step, we will use the &lt;a href=&quot;https://amzn.to/3HPGhQ4&quot;&gt;ESP32&lt;/a&gt; to capture the temperature and humidity information from the &lt;a href=&quot;https://amzn.to/3YzITaO&quot;&gt;DHT11&lt;/a&gt; temperature sensor. So, for this I have created a software library &quot;dht11&quot;, you can use this, or alternatively you can use any other software library, and update the software accordingly.&lt;/div&gt;&lt;div&gt;The library prepared is very straightforward to use, the following are the functions to initialize and get the temperature and humidity information.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// initialize dht sensor library&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_init&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;DHT11_PIN&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;line-height: 22px;&quot;&gt;&lt;div style=&quot;line-height: 22px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Get DHT11 Temperature and Humidity Values, when the status is DHT11_OK&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 22px;&quot;&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_read&lt;/span&gt;().&lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 22px;&quot;&gt;&lt;div style=&quot;line-height: 22px;&quot;&gt;&lt;div style=&quot;line-height: 22px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_read&lt;/span&gt;().&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp;// Get Temperature&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_read&lt;/span&gt;().&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt; // Get Humidity&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Initializing the Display SW Module&lt;/h3&gt;&lt;div&gt;The next step is to initialize the display module, which is very well handled by using multiple software modules such as &quot;display_mng&quot;, &quot;ili9341&quot;, &quot;xpt2046&quot; and &quot;gui_mng&quot;.&lt;/div&gt;&lt;div&gt;Here the idea of creating multiple modules is to make software modular in nature, from the application point of view, we just need to update the &quot;gui_mng&quot; module to get something displayed on the TFT screen, the rest of the files are used to achieve the modularity. The following lines explain the purpose of each software module.&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;ILI9341: This module contains the drivers for the ILI9341 display controller, if your project doesn&#39;t use this display controller then you have to update your drivers accordingly.&lt;/li&gt;&lt;li&gt;XPT2046: This module contains the drivers for the XPT2046 resistive touch controller, as of now this is not used in our project, but it is functional, and in my upcoming posts, I will show you some examples that use this also.&lt;/li&gt;&lt;li&gt;Display Manager: This module contains the actual code to send data to the ILI9341 controller and XPT2046 controller, this module implements the SPI communication interface and configures the LVGL graphics library display drivers and input drivers, and then this module also starts the GUI manager task.&lt;/li&gt;&lt;li&gt;GUI Manager: This is a software module that is exposed to the application code, all the graphics-related things will be implemented and handled here. For example, if we want to update some screen, we will handle this in this module only, by doing this we will make our code modular and easy to handle, and this is done using FreeRTOS Queues, so whenever we want to update something, we will just post an event from the main application code, and GUI manager will update the corresponding screen accordingly.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;The following are the important functions of the GUI manager module.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// start the gui task, this handles all the display related stuff&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_start&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;line-height: 22px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// trigger event to display temperature and humidity&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_send_event&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;GUI_MNG_EV_TEMP_HUMID&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt; );&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Initializing the ThingSpeak SW Module&lt;/h3&gt;&lt;div&gt;The ThingSpeak software module is used to send the data to the ThingSpeak cloud, this module is very simple and it uses the ESP-IDF IOT framework libraries to send HTTP Client GET requests with the temperature and humidity values, which are then received by ThingSpeak cloud and visualized on the dashboard.&lt;/div&gt;&lt;div&gt;To use this module, we have to first get connected with the WiFi router so that we can access the internet, if our connection is successful, then the ThingSpeak start API is called, which then starts the ThingSpeak task. To make our software development modular, just like in the GUI manager task, here also we used a queue to send events to the ThingSpeak module, and whenever the event is posted the ThingSpeak task, based on the event received, sends the data to the ThingSpeak cloud, this is done to make things modular and scalable for future updates.&lt;/div&gt;&lt;div&gt;The two important public APIs are as below.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;thingspeak_start&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;BaseType_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;thingspeak_send_event&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;thingspeak_event_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pData&lt;/span&gt; );&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;The first API i.e. the start API is used to create a FreeRTOS queue and start the ThingSpeak task, and the send event API is used to send the event to the ThingSpeak task.&lt;/div&gt;&lt;div&gt;Whenever the event is received, the ThingSpeak task parses the received event and then takes action based on the received event. In our case, we are sending the event to send the Temperature and Humidity data to the ThingSpeak cloud, as shown below.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// if wifi is connected, trigger the event to send data to ThingSpeak&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_status&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;thingspeak_send_event&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;THING_SPEAK_EV_TEMP_HUMID&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;And then how the event is received from the Queue is shown below.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;thingspeak_task&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pvParameters&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;thingspeak_q_msg_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;( &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Wait for events posted in Queue&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xQueueReceive&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;thingspeak_event&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;, portMAX_DELAY) )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// the below is the code to handle the state machine&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #4fc1ff;&quot;&gt;THING_SPEAK_EV_NONE&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_id&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;switch&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_id&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;THING_SPEAK_EV_TEMP_HUMID&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;thingspeak_send_temp_humidity&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;default&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #6a9955;&quot;&gt; // switch case end&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; // if event received in limit end&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; // xQueueReceive end&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;As you can see we are calling the function &quot;thingspeak_send_temp_humidity&quot; function, and this function contains the actual implementation of sending the temperature and humidity data to the ThingSpeak cloud, and its implementation is as below.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@brief&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; Send Temperature and Humidity data to ThingSpeak cloud&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;none&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;thingspeak_send_temp_humidity&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;err&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;thingspeak_url&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;200&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;sensor_data_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_temperature_humidity&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;size_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;SENSOR_BUFF_SIZE&lt;/span&gt;) )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// before posting the event we have incremented the index and hence to get&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// the last sensor data we have to use - 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;SENSOR_BUFF_SIZE&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;SENSOR_BUFF_SIZE&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;snprintf&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;thingspeak_url&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;thingspeak_url&lt;/span&gt;), &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;https://api.thingspeak.com/update?api_key=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%s&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;amp;field1=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%u&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;amp;field2=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%u&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;THINGSPEAK_KEY&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_http_client_config_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; .url &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;thingspeak_url&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; .method &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_METHOD_GET,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// todo: maybe for future&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// .transport_type = HTTP_TRANSPORT_OVER_SSL, &amp;nbsp; // Specify transport type&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// .crt_bundle_attach = esp_crt_bundle_attach, &amp;nbsp;// Attach the certificate bundle&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; };&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_http_client_handle_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_init&lt;/span&gt;( &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// set header&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_set_header&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;CLIENT_KEY&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;CLIENT_VALUE&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ThingSpeak URL = &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%s&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;thingspeak_url&lt;/span&gt;);&amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// perform the request&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;err&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_perform&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;err&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_OK)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;status_code&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_get_status_code&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;status_code&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;200&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Message Sent Successfully.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGE&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Message Sending Failed.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_cleanup&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;As can be seen from the above code, first we get the temperature and humidity data from the buffers and then send this data using an HTTP Client GET request.&lt;/div&gt;&lt;div&gt;The code is designed in such a way that it can handle multiple events and send multiple data to the ThingSpeak cloud.&lt;/div&gt;&lt;div&gt;To not face any problems, please make sure that in the SDK Config, then in the &quot;ESP-TLS&quot; setting, the &quot;Allow potentially insecure options&quot; and &quot;Skip server certificate verification by default&quot; are checked, as shown below.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/feature/GA-12-Send-the-measured-Temperature-and-Humidity-to-ThingSpeak-IOT-Cloud/ESP-IDF/LVGL_TemperatureHumidity/doc/ESPTLS_Setting.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;386&quot; data-original-width=&quot;800&quot; height=&quot;309&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/feature/GA-12-Send-the-measured-Temperature-and-Humidity-to-ThingSpeak-IOT-Cloud/ESP-IDF/LVGL_TemperatureHumidity/doc/ESPTLS_Setting.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;SDK Config (ESP-TLS Setting)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Final&lt;/h3&gt;&lt;div&gt;Now, let&#39;s see the main program or let&#39;s say the main task, which handles the connection with the WiFi router, getting the temperature and humidity data from the sensor, and then posting the events to the GUI manager and the ThingSpeak module, so that the GUI manager can update the labels with the latest available values, and the ThingSpeak module can send this data to the ThingSpeak cloud.&lt;/div&gt;&lt;div&gt;The source code for this module is as below.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;stdbool.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;driver/gpio.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;freertos/FreeRTOS.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;freertos/event_groups.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;freertos/task.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;nvs_flash.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;esp_event.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;esp_netif.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;esp_system.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;esp_log.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;esp_wifi.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;main.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;dht11.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;gui_mng.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;thingspeak.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// macros&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;DHT11_PIN&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (GPIO_NUM_12)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;MAIN_TASK_PERIOD&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;60000&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;APP_WIFI_SSID&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter SSID Here&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;APP_WIFI_PSWD&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter Password Here&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_MAX_RETRY&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_CONNECT_DELAY&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; // Initial delay in milliseconds&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_MAX_DELAY&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;60000&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; // Maximum delay in milliseconds&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// The following are the bits/flags for event group&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_CONNECTED_BIT&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BIT0&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;// connected to the access point with an IP&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_FAIL_BIT&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BIT1&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;// failed to connect after the max. amount of retries&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Private Variables&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;APP&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/* WiFi Connection Related Variables */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;EventGroupHandle_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_event_group&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // FreeRTOS event group to signal when we are connected&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_retry&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/* Sensor Related Variables */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;sensor_data_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; { .&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; };&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Private Function Declarations&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;app_connect_wifi&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_event_handler&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arg&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_event_base_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_base&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int32_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_id&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_data&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;app_main&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Disable default gpio logging messages&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_log_level_set&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;gpio&quot;&lt;/span&gt;, ESP_LOG_NONE);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// disable default wifi logging messages&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_log_level_set&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;wifi&quot;&lt;/span&gt;, ESP_LOG_NONE);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_ERR_NVS_NO_FREE_PAGES &lt;span style=&quot;color: #d4d4d4;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_ERR_NVS_NEW_VERSION_FOUND)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_erase&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// connect with WiFi (it will take some time)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;app_connect_wifi&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_status&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;thingspeak_start&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// initialize dht sensor library&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_init&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;DHT11_PIN&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// start the gui task, this handles all the display related stuff&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_start&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Get DHT11 Temperature and Humidity Values&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_read&lt;/span&gt;().&lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_OK&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_read&lt;/span&gt;().&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// humidity can&#39;t be greater than 100%, that means invalid data&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;100&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;SENSOR_BUFF_SIZE&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_read&lt;/span&gt;().&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Temperature: &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt;]);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Humidity: &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt;]);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// trigger event to display temperature and humidity&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gui_send_event&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;GUI_MNG_EV_TEMP_HUMID&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// if wifi is connected, trigger event to send data to ThingSpeak&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_status&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;thingspeak_send_event&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;THING_SPEAK_EV_TEMP_HUMID&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// reset the index&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;SENSOR_BUFF_SIZE&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGE&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;In-correct data received from DHT11 -&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%u&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGE&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Unable to Read DHT11 Status&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Wait before next measurement&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelay&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;MAIN_TASK_PERIOD&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt; portTICK_PERIOD_MS);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Public Function Definitions&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@brief&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; Get the Pointer to the Sensor Data Structure to get the temperature &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and Humidity values&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;None&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; sensor_data data structure pointer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;sensor_data_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_temperature_humidity&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_data&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Private Function Definitions&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@brief&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; Connect with the WiFi Router&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@note&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp;in future this function can be moved to a commom place.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;none&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;app_connect_wifi&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_event_group&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xEventGroupCreate&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_netif_init&lt;/span&gt;() );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_event_loop_create_default&lt;/span&gt;() );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_netif_create_default_wifi_sta&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;wifi_init_config_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cfg&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;WIFI_INIT_CONFIG_DEFAULT&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_wifi_init&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cfg&lt;/span&gt;) );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_event_handler_instance_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_any_id&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_event_handler_instance_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_got_ip&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_event_handler_instance_register&lt;/span&gt;( WIFI_EVENT, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ESP_EVENT_ANY_ID, &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_event_handler&lt;/span&gt;, &amp;nbsp;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_any_id&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_event_handler_instance_register&lt;/span&gt;( IP_EVENT, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IP_EVENT_STA_GOT_IP, &amp;nbsp;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_event_handler&lt;/span&gt;, &amp;nbsp;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;instance_got_ip&lt;/span&gt;) );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;wifi_config_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_config&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; .sta &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .ssid &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;APP_WIFI_SSID&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .password &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;APP_WIFI_PSWD&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;span style=&quot;color: #9cdcfe;&quot;&gt;threshold&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;authmode&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; WIFI_AUTH_WPA2_PSK,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; },&lt;/div&gt;&lt;div&gt;&amp;nbsp; };&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_wifi_set_mode&lt;/span&gt;(WIFI_MODE_STA) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_wifi_set_config&lt;/span&gt;(WIFI_IF_STA, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_config&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_wifi_start&lt;/span&gt;() );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;WiFi Initialized in Station Mode Finished.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* Wait until either the connection is established (WIFI_CONNECTED_BIT) or&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* connection failed for the maximum number of re-tries (WIFI_FAIL_BIT).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* The bits are set by event_handler() (see above) */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;EventBits_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bits&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xEventGroupWaitBits&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_event_group&lt;/span&gt;, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_CONNECTED_BIT&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_FAIL_BIT&lt;/span&gt;, &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pdFALSE, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pdFALSE, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; portMAX_DELAY);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* xEventGroupWaitBits() returns the bits before the call returned, hence we&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* can test which event actually happened. */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bits&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_CONNECTED_BIT&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Connected to Access Point &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%s&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;APP_WIFI_SSID&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bits&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_FAIL_BIT&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGE&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Failed to Connect to Access Point &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%s&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;APP_WIFI_SSID&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGE&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Unexpected Event&quot;&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vEventGroupDelete&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_event_group&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@brief&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; WiFi Event Handler Function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arg&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_base&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; Event Base whether WIFI Event or IP Event&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_id&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; Event ID &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_data&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; Data with Event&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_event_handler&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arg&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_event_base_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_base&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int32_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_id&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_data&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( WIFI_EVENT &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_base&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( WIFI_EVENT_STA_START &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_id&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_wifi_connect&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( WIFI_EVENT_STA_DISCONNECTED &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_id&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_retry&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_MAX_RETRY&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint32_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;delay&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_retry&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_CONNECT_DELAY&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;delay&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;delay&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_MAX_DELAY&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;?&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_MAX_DELAY&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;delay&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// waiting for some time before retrying again&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelay&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;delay&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt; portTICK_PERIOD_MS);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_wifi_connect&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_retry&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Retry Wi-Fi connection (&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;)...&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_retry&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_MAX_RETRY&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xEventGroupSetBits&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_event_group&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_FAIL_BIT&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGE&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Failed to connect to Access Point.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;span style=&quot;color: #6a9955;&quot;&gt; // if( WIFI_EVENT = event_base )&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( IP_EVENT &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_base&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ip_event_got_ip_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;event &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;ip_event_got_ip_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;)event_data;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Got IP:&quot;&lt;/span&gt; IPSTR, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;IP2STR&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ip_info&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ip&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_retry&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_connect_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xEventGroupSetBits&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_event_group&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_CONNECTED_BIT&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;The code is very simple and straightforward to understand, the following are the steps that how the program works.&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;WiFi and GPIO logs are disabled, else the Serial Terminal will be filled with the internal logs, which I don&#39;t want, in case you want to debug, it&#39;s a good option.&lt;/li&gt;&lt;li&gt;The next step is to initialize the NVS partition, and if this fails, erase the flash and try again.&lt;/li&gt;&lt;li&gt;The next step is to try to connect with the router using the function &quot;app_connect_wifi&quot;, and if the connection is successful then call the &quot;thingspeak_start&quot; function, which will create the &quot;ThingSpeak Task&quot;&lt;/li&gt;&lt;li&gt;The next step is to initialize the DHT11 sensor library.&lt;/li&gt;&lt;li&gt;The next step is to call the function &quot;gui_start&quot;, this will do a lot of work, by calling multiple modules, from &quot;display_mng&quot;, &quot;ili9341&quot; and &quot;xpt2046&quot; modules, this module configures the &quot;LVGL&quot; display drivers and input drivers, and then it starts the &quot;GUI&quot; task, which in turn will display the user interface, that we have designed using Square Line Studio.&lt;/li&gt;&lt;li&gt;Now finally we will wait in a while loop, and read the DHT11 sensor data periodically, whenever the data is read, we check if this is valid if is valid, store it in the buffer, and also trigger events to the &quot;GUI&quot; manager module and &quot;ThingSpeak&quot; module, which in turn will update the display and send data to the ThingSpeak cloud.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;The completed code can be downloaded from our GitHub page by &lt;a href=&quot;https://github.com/xpress-embedo/ESP32/tree/master/ESP-IDF/LVGL_TemperatureHumidity&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;clicking here&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;In case you have some comments or questions, feel free to contact us by using the comment section, or using the &quot;Contact Us&quot; page.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2024/02/visualizing-temperature-and-humidity.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/ZVSL4IXyavU/default.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-6573907116948091848</guid><pubDate>Sat, 26 Aug 2023 21:13:00 +0000</pubDate><atom:updated>2023-08-28T12:02:21.226-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ESP32</category><category domain="http://www.blogger.com/atom/ns#">IOT</category><title>Building a Weather Station Web Server with OTA Updates Using ESP32 and ESP-IDF Framework</title><description>In this tutorial, we&#39;ll guide you through the process of creating a Weather Station Web Server using the ESP32 microcontroller, the ESP-IDF (Espressif IoT Development Framework), and incorporating OTA (Over-The-Air) updates. This project will allow you to measure temperature and humidity, display the data on a web server, and remotely update the firmware over Wi-Fi.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfPkKL6JGec35b6Yf1yFKR1tdTkl6SI55kOtdtJkP2iEaarvtM2GOfY3mQ3RNK7NE7PtIH6fGBaXR4fOtdigoAM-iJO9tGjWNgzV3f95NIsBbi9Jcb6PsJHfEuxXY-_4LLEzbBqe59PqWV_ewXXZUlGzateI7A-C3HCdJeMjZ38gCVzC4qUIlJY2bXqBc/s1920/WeatherStationWebServerWithOTA.gif&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfPkKL6JGec35b6Yf1yFKR1tdTkl6SI55kOtdtJkP2iEaarvtM2GOfY3mQ3RNK7NE7PtIH6fGBaXR4fOtdigoAM-iJO9tGjWNgzV3f95NIsBbi9Jcb6PsJHfEuxXY-_4LLEzbBqe59PqWV_ewXXZUlGzateI7A-C3HCdJeMjZ38gCVzC4qUIlJY2bXqBc/w640-h360/WeatherStationWebServerWithOTA.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Project Demo With OTA Updates&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;h4&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://www.pcbway.com/&quot; target=&quot;_blank&quot;&gt;&lt;img data-original-height=&quot;90&quot; data-original-width=&quot;728&quot; height=&quot;79&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEja55GlkLXVgJuK6dwvfx8hA_J7lTRSagRfKibGjhcdCB3R9sAIuMUywpiq2D2IBGMuSbUWSFLLklA3oR3k5jYz8usZW3G3enjdMOfCdEYa_s7XeurkICZ7t53u_3JhCwA4F1hDAR7Ffc0HwEkgL6_bnWQgI4pPb9KZOfp8IUKWZcIcSVW1PuXxFUitadQ=w640-h79&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/h4&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;i&gt;This post is sponsored by PCBWay, with more than a decade in the field of PCB prototype and fabrication, PCBWay is committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests.&lt;br /&gt; As one of the most experienced PCB manufacturers in the World, PCBWay prides itself on being your best business partner as well as a good friend in every aspect of your PCB needs.&lt;/i&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/eC4Cntohxj8&quot; width=&quot;320&quot; youtube-src-id=&quot;eC4Cntohxj8&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Pre-Requisites&lt;/h3&gt;&lt;div&gt;Before you start, make sure you have the following:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;ESP32 Development Board: A popular and powerful microcontroller board for IoT projects.&lt;/li&gt;&lt;li&gt;ESP-IDF Installed: Set up the ESP-IDF development framework on your computer. You can find installation instructions in the &lt;a href=&quot;https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html&quot; target=&quot;_blank&quot;&gt;ESP-IDF documentation&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;DHT11 Sensor: A sensor that measures temperature and humidity.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;We should also have an idea of what we are going to develop, and this is illustrated with the help of a Use Case Diagram as shown below.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/WeatherStationServer/docs/WeatherStationServer-UseCase.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;530&quot; data-original-width=&quot;800&quot; height=&quot;424&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/WeatherStationServer/docs/WeatherStationServer-UseCase.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Use Case Diagram Weather Station Web Server&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Step 1: Setting up the Hardware&lt;/h4&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Connect the DHT11 sensor to the ESP32 board. Connect the VCC pin to 3.3V, GND to ground, and DATA to a GPIO pin of your choice (e.g., GPIO19).&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Step 2: Creating the Project&lt;/h4&gt;&lt;div&gt;This is a very basic topic and I am not going to cover that, you can use Eclipse-based ESP-IDF IDE or VS Code or even the command line version.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Step 3: Writing the Code&lt;/h4&gt;&lt;div&gt;The project is divided into several modules and each module handles the individual tasks.&lt;/div&gt;&lt;div&gt;The first module is the &quot;DHT11&quot; sensor module, this module is used to get the temperature and humidity values from the &quot;DHT11&quot; sensor module. The source code for this module can be downloaded from the links given at the bottom of this page, but a brief overview is given here.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/* Private Variables */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;gpio_num_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_gpio&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int64_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read_time&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2000000&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/* Private Function Prototypes */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_wait_or_timeout&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;useconds&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;level&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_status_e&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_check_checksum&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;[]&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_send_start_signal&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_check_response&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_timeout_error&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_crc_error&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/* Public Function Definitions */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_init&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;gpio_num_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;gpio_num&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* Wait for some seconds to make the device pass its initial unstable status */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelay&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;DHT11_INITIAL_WAKEUP_DELAY&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt; portTICK_PERIOD_MS);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_gpio&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;gpio_num&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_read&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* DHT11 sensor can take up-to 2 seconds for updated values, hence if some one&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* call this function too early, then we should return the old value&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( (&lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_timer_get_time&lt;/span&gt;() &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;DHT11_READING_WAIT_DELAY&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read_time&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read_time&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_timer_get_time&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; {&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* trigger the start signal */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_send_start_signal&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* Check for DHT11 Host Signal, here DHT11 should pull the line low for 80us&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* and then pull the line high for 80 us&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_check_response&lt;/span&gt;() &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_TIMEOUT_ERROR&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_timeout_error&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* Now DHT11 will send 40 bits of data, each bit transmission begins with the&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* low-voltage level that last around 50us, the following high-voltage level&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* signal length decides whether the bit is &quot;1&quot; or &quot;0&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;40&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; /* Initial low signal, should be around 50 us, if more than that it is a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; timeout error. */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_wait_or_timeout&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;50&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_TIMEOUT_ERROR&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_timeout_error&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; /* Now the high signal length will determine whether it is a bit 1 or 0, here&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; we check maximum for 70 us second, but if pin gets low and the micro ticks&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; are greater than 28 us seconds, then it means bit is 1 else bit is 0 */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_wait_or_timeout&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;70&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;28&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /* Bit received is a 1 */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;|=&lt;/span&gt; (&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; (&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;)));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* last step is to validate the received data by checking the checksum */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_check_checksum&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_CHECKSUM_ERROR&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_OK&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_crc_error&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;last_read&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/* Private Function Definitions */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_wait_or_timeout&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;useconds&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;level&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;micros_ticks&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;gpio_get_level&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_gpio&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;level&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;micros_ticks&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;useconds&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_TIMEOUT_ERROR&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ets_delay_us&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;micros_ticks&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_status_e&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_check_checksum&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;[]&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_status_e&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_CHECKSUM_ERROR&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;]))&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_OK&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_status&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_send_start_signal&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* Request Stage:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* To make the DHT11 send the sensor readings we have to send a request.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* The Request is to pull down the bus for more than 18ms, in order to give&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;* DHT11 time to understand it and then pull it up for 40 micro-seconds&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gpio_set_direction&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_gpio&lt;/span&gt;, GPIO_MODE_OUTPUT);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gpio_set_level&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_gpio&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ets_delay_us&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;DHT11_START_SIGNAL_PULL_DOWN_DELAY&lt;/span&gt;);&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; // 20ms delay&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gpio_set_level&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_gpio&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ets_delay_us&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;DHT11_START_SIGNAL_PULL_UP_DELAY&lt;/span&gt;);&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; // 40us delay&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;gpio_set_direction&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht_gpio&lt;/span&gt;, GPIO_MODE_INPUT);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_check_response&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* Wait for next step ~80us*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_wait_or_timeout&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_TIMEOUT_ERROR&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_TIMEOUT_ERROR&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; /* Wait for next step ~80us*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_wait_or_timeout&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_TIMEOUT_ERROR&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_TIMEOUT_ERROR&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_OK&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_timeout_error&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;timeout_error&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; { &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_TIMEOUT_ERROR&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;timeout_error&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_crc_error&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;crc_error&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; { &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_CHECKSUM_ERROR&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;crc_error&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;This module takes the help of the timing details provided by the esp timer module to generate exact timing signals needed by the DHT11 sensor module.&lt;/div&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;div&gt;The next module is the main module, we can also call this module as main task module, this is the starting point of the project and this module will initialize the DHT11 sensor module and also the WiFi Application module (which in turn will start the ESP32 in WiFi Access Point Mode).&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;app_main&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dht11_reading_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht11_value&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Initialize NVS&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_ERR_NVS_NO_FREE_PAGES &lt;span style=&quot;color: #d4d4d4;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_ERR_NVS_NEW_VERSION_FOUND)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_erase&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// initialize led manager module&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;led_init&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// initialize the dht11 module&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_init&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;DHT11_GPIO_NUM&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Start WiFi&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_start&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// read the data from dht11 sensor&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht11_value&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;dht11_read&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// If reading is valid then only print&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht11_value&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DHT11_OK&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht11_value&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dht11_value&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Temperature: &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, Humidity: &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelay&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;MAIN_TASK_PERIOD&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt; portTICK_PERIOD_MS);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This module also measures the temperature and humidity values from the DHT11 sensor and stores them in module-specific global variables, which can be used to display the temperature and humidity values on the web server page.&lt;/div&gt;&lt;span&gt;&lt;!--more--&gt;The next module is the &quot;WiFi Application&quot; module, this module is triggered from the main module, the purpose of this module is to configure the WiFi Settings such as SSID, Password, IP Address, Net Mask, Gateway, Number of Allowed Connection etc. This all is done inside a FreeRTOS task, which is used to initialize all the default configurations and the WiFi is started using the function &quot;esp_wifi_start&quot;. This module will trigger the &quot;HTTP Server&quot; module which is one of the most important modules for this project.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;The following is a high-level overview diagram of this WiFi Application Module.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/a1c9cc2e0101d8d8445bc7da0278cbd0a24f5593/ESP-IDF/WeatherStationServer/docs/WeatherStationServer-WiFiApplicationOverview.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;393&quot; data-original-width=&quot;800&quot; height=&quot;314&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/a1c9cc2e0101d8d8445bc7da0278cbd0a24f5593/ESP-IDF/WeatherStationServer/docs/WeatherStationServer-WiFiApplicationOverview.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Simplified Overview of WiFi Application Software Module&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;span&gt;The following is the simplified version of the Activity Diagram of this WiFi Application SW Module.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/WeatherStationServer/docs/WeatherStationServer-WifiApplicationActivityDiagram.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;510&quot; data-original-width=&quot;800&quot; height=&quot;408&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/WeatherStationServer/docs/WeatherStationServer-WifiApplicationActivityDiagram.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Activity Diagram WiFi Application SW Module&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Sends a message to the queue.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @param msg_id message from wifi_app_msg_e enum&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @return pdTRUE if an item was successfully sent to the queue, otherwise pdFALSE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;BaseType_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_send_msg&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;wifi_app_msg_e&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg_id&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;wifi_app_q_msg_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg_id&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg_id&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xQueueSend&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_app_q_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;, portMAX_DELAY);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Starts the WiFi RTOS Task&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_start&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;,&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Starting WiFi Application&quot;&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Start the WiFi Led&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;LED_WIFI_APP_STARTED&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Disable default wifi logging messages&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_log_level_set&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;wifi&quot;&lt;/span&gt;, ESP_LOG_NONE);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Create Message Queue with length 3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_app_q_handle&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xQueueCreate&lt;/span&gt;( &lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;wifi_app_q_msg_t&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Start the WiFi Application Task&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xTaskCreate&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_task&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;wifi_app_task&quot;&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_APP_TASK_STACK_SIZE&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_APP_TASK_PRIORITY&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Main task for the WiFi Application&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_task&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pvParameter&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;wifi_app_q_msg_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Initialize the Event Handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_event_handler_init&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Initialize the TCP/IP stack and WiFi Configuration&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_default_wifi_init&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Soft AP Configuration&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_soft_ap_config&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Start WiFi&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_wifi_start&lt;/span&gt;());&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Send First Event Message&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;wifi_app_send_msg&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;WIFI_APP_MSG_START_HTTP_SERVER&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;(;;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;xQueueReceive&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;wifi_app_q_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;, portMAX_DELAY))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;switch&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg_id&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;WIFI_APP_MSG_START_HTTP_SERVER&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;,&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;WIFI_APP_MSG_START_HTTP_SERVER&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_start&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;LED_WIFI_HTTP_SERVER_STARTED&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;WIFI_APP_MSG_CONNECTING_FROM_HTTP_SERVER&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;,&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;WIFI_APP_MSG_CONNECTING_FROM_HTTP_SERVER&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;WIFI_APP_MSG_STA_CONNECTED_GOT_IP&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;,&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;WIFI_APP_MSG_STA_CONNECTED_GOT_IP&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;LED_WIFI_CONNECTED&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;default&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;div&gt;The next software module is the HTTP Server module, which is the key component of this Wireless LAN Application and also supports the Web Page Functionality. The implementation overview of this module is as follows.&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The HTTP Server will support the web pages (HTML, CSS and JavaScript files)&lt;/li&gt;&lt;li&gt;It will also support OTA (Over the Air) Firmware Updates&lt;/li&gt;&lt;li&gt;It will also support the temperature and humidity sensor readings displayed on the web pages.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;This module has some web pages files as shown in the below image.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgSb7jvO2tR2G8JjxjA_RLdSRJKvdYw53MrT1w0mMUpDkHWEZpqNGyx2w_fQzqkUEY2AAlNkZ19ql8f4jFtjQ3rzdiizO2zFhp1xHfWxhqlozcZ8L0-DUfurm3KPOvYPv9CuI4_APQGy_5j_sJ6aSBj3PDdOMaPGRU7W21vVZR9aPvbPY2KoxzJKPQVWYo&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;572&quot; data-original-width=&quot;759&quot; height=&quot;302&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgSb7jvO2tR2G8JjxjA_RLdSRJKvdYw53MrT1w0mMUpDkHWEZpqNGyx2w_fQzqkUEY2AAlNkZ19ql8f4jFtjQ3rzdiizO2zFhp1xHfWxhqlozcZ8L0-DUfurm3KPOvYPv9CuI4_APQGy_5j_sJ6aSBj3PDdOMaPGRU7W21vVZR9aPvbPY2KoxzJKPQVWYo=w400-h302&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Web Pages Files&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;index.html&lt;/li&gt;&lt;ul&gt;&lt;li&gt;HTML markup that will display the temperature and humidity reading, and also provide the buttons and dialog to update the ESP32 firmware.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;app.css&lt;/li&gt;&lt;ul&gt;&lt;li&gt;This is used to style the index.html document&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;app.js&lt;/li&gt;&lt;ul&gt;&lt;li&gt;This is the JavaScript program that will be used for interactions.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;favicon.ico&lt;/li&gt;&lt;ul&gt;&lt;li&gt;The icon that gets displayed in the address bar of the browser&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;jquery-3.3.1.min.js&lt;/li&gt;&lt;ul&gt;&lt;li&gt;JavaScript Library&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;The following piece of code is the abstract from the HTTP Server Software module.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Starts the HTTP Server&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_start&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_configure&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Stops the HTTP Server&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_stop&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_stop&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;http_server_stop: stopping HTTP Server&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;task_http_server_monitor&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelete&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;task_http_server_monitor&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;,&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;http_server_stop: stopping HTTP server monitor&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;task_http_server_monitor&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Timer Callback function which calls esp_restart function upon successful&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* firmware update&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_fw_update_reset_cb&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arg&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;http_fw_update_reset_cb: Timer timed-out, restarting the device&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_restart&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Sends a message to the Queue&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @param msg_id Message ID from the http_server_msg_e enum&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @return pdTRUE if an item was successfully sent to the queue, otherwise pdFALSE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;BaseType_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_monitor_send_msg&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;http_server_msg_e&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg_id&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;http_server_q_msg_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg_id&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg_id&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xQueueSend&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_monitor_q_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;, portMAX_DELAY );&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Private Function Definitions&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* HTTP Server Monitor Task used to track events of the HTTP Server.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @param pvParameter parameters which can be passed to the task&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @return http server instance handle if successful, NULL otherwise&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_monitor&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pvParameter&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;http_server_q_msg_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;( ;; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xQueueReceive&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_monitor_q_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;, portMAX_DELAY) )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;switch&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;msg_id&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;HTTP_MSG_WIFI_CONNECT_INIT&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;HTTP_MSG_WIFI_CONNECT_INIT&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;HTTP_MSG_WIFI_CONNECT_SUCCESS&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;HTTP_MSG_WIFI_CONNECT_SUCCESS&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;HTTP_MSG_WIFI_CONNECT_FAIL&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;HTTP_MSG_WIFI_CONNECT_FAIL&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;HTTP_MSG_WIFI_OTA_UPDATE_SUCCESSFUL&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;HTTP_MSG_OTA_UPDATE_SUCCESSFUL&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;fw_update_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;OTA_UPDATE_SUCCESSFUL&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_fw_update_reset_timer&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;HTTP_MSG_WIFI_OTA_UPDATE_FAILED&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;HTTP_MSG_OTA_UPDATE_FAILED&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;fw_update_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;OTA_UPDATE_FAILED&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;default&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;This module configures the HTTP Server and also creates an HTTP Monitoring Task, and when the HTTP Server is started we register some URIs&#39;s as shown below.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Sets up the default httpd server configuration&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @return http server instance handle if successful, NULL otherwise&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_handle_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_configure&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Generate the default configuration&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_config_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;HTTPD_DEFAULT_CONFIG&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// create HTTP Server Monitor Task&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xTaskCreate&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_monitor&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;http_server_monitor&quot;&lt;/span&gt;, &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_SERVER_MONITOR_STACK_SIZE&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;, &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_SERVER_MONITOR_PRIORITY&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;task_http_server_monitor&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// create a message queue&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_monitor_q_handle&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;xQueueCreate&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_SERVER_MONITOR_QUEUE_LEN&lt;/span&gt;,&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;http_server_q_msg_t&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// No need to specify the core id as this is esp32s2 with single core&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Adjust the default priority to 1 less than the wifi application task&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;task_priority&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_SERVER_TASK_PRIORITY&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Specify the Stack Size (default is 4096)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;stack_size&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_SERVER_TASK_STACK_SIZE&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Increase our URI Handlers&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_uri_handlers&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_SERVER_MAX_URI_HANDLERS&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Increase the timeout limits&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;recv_wait_timeout&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_SERVER_RECEIVE_WAIT_TIMEOUT&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;send_wait_timeout&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_SERVER_SEND_WAIT_TIMEOUT&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;http_server_configure: Starting Server on port: &#39;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39; with task priority: &#39;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;server_port&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;task_priority&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Start the httpd server port&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_start&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_OK )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;http_server_configure: Registering URI Handlers&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register jQuery handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_uri_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;jquery_js&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .uri &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/jquery-3.3.1.min.js&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .method &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_GET,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .handler &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_j_query_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .user_ctx &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register index.html handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_uri_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_html&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .uri &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .method &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_GET,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .handler &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_index_html_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .user_ctx &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register app.css handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_uri_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;app_css&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .uri &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/app.css&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .method &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_GET,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .handler &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_app_css_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .user_ctx &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register app.js handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_uri_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;app_js&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .uri &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/app.js&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .method &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_GET,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .handler &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_app_js_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .user_ctx &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register favicon.ico handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_uri_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;favicon_ico&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .uri &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/favicon.ico&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .method &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_GET,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .handler &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_favicon_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .user_ctx &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register OTA Update Handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_uri_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ota_update&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .uri &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/OTAupdate&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .method &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_POST,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .handler &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_ota_update_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .user_ctx &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register OTA Status Handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_uri_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ota_status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .uri &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/OTAstatus&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .method &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_POST,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .handler &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_ota_status_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .user_ctx &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register Sensor.json handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_uri_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_json&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .uri &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/Sensor&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .method &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_GET,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .handler &amp;nbsp; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_sensor_value_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .user_ctx &amp;nbsp;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Register Query Handler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_register_uri_handler&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;jquery_js&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_register_uri_handler&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_html&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_register_uri_handler&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;app_css&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_register_uri_handler&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;app_js&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_register_uri_handler&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;favicon_ico&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_register_uri_handler&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ota_update&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_register_uri_handler&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ota_status&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_register_uri_handler&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_json&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;http_server_handle&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;http_server_configure: Error starting server!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;This URIs callback function handles all the requests from and to the web page. For example, the below-mentioned function is called from the web page every 5 seconds to request the temperature and humidity values to be displayed on the web page.&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Sensor Readings JSON handler responds with the Sensor Data&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @param req HTTP request for which the URI needs to be handled&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* @return ESP_OK&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_sensor_value_handler&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_req_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;req&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_JSON&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;100&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Sensor Readings Requested&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sprintf&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_JSON&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;{&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;temp&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;}&quot;&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_temperature&lt;/span&gt;(), &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_humidity&lt;/span&gt;() );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_resp_set_type&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;req&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;application/json&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;httpd_resp_send&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;req&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_JSON&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;strlen&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sensor_JSON&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; ESP_OK;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Similarly, the following callback function is called when we try to upload a file from the web page into the ESP32 controller. This function is actually huge, but I have commented on the code very properly so that it can be understandable by anyone.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@brief&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; Receives the *.bin file via the web page and handles the firmware update&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;req&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; HTTP request for which the uri needs to be handled&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; ESP_OK, other ESP_FAIL if timeout occurs and the update canot be started&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;http_server_ota_update_handler&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;httpd_req_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;req&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Download Link&lt;/h3&gt;&lt;div&gt;The code is available in my ESP32 repository on GitHub, &lt;a href=&quot;https://github.com/xpress-embedo/ESP32/tree/master/ESP-IDF/WeatherStationServer&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;click on this link&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;. This repository contains many projects, so to get only this project you guys have to still clone everything, and to avoid this I am also providing you guys with the&lt;a href=&quot;https://drive.google.com/drive/folders/1rlYTRAXRjW5K_G84q3VxOQ1tmOupuJcL?usp=sharing&quot; target=&quot;_blank&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Google Drive link to download this project&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Conclusion&lt;/h3&gt;&lt;div&gt;Congratulations! You&#39;ve created a Weather Station Web Server with OTA update functionality using ESP32 and ESP-IDF. This project showcases the power of ESP32 in IoT applications, enabling remote updates to ensure your devices are always up to date.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can further refine the project by enhancing security for OTA updates, implementing version control, and adding additional sensors or features. Remember to consult the ESP-IDF documentation for deeper insights and advanced features.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Happy building and experimenting with your IoT project!&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2023/08/building-weather-station-web-server.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfPkKL6JGec35b6Yf1yFKR1tdTkl6SI55kOtdtJkP2iEaarvtM2GOfY3mQ3RNK7NE7PtIH6fGBaXR4fOtdigoAM-iJO9tGjWNgzV3f95NIsBbi9Jcb6PsJHfEuxXY-_4LLEzbBqe59PqWV_ewXXZUlGzateI7A-C3HCdJeMjZ38gCVzC4qUIlJY2bXqBc/s72-w640-h360-c/WeatherStationWebServerWithOTA.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-3862261204746127992</guid><pubDate>Fri, 04 Aug 2023 20:49:00 +0000</pubDate><atom:updated>2023-08-06T12:43:45.741-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Bluetooth</category><category domain="http://www.blogger.com/atom/ns#">Others</category><category domain="http://www.blogger.com/atom/ns#">Wireless</category><title>Accelerometer Data Visualization on Desktop and Android using Qt</title><description>&lt;p&gt;The &lt;a href=&quot;https://amzn.to/3YebMJG&quot; target=&quot;_blank&quot;&gt;MPU6050 &lt;/a&gt;is a popular and widely used accelerometer and gyroscope sensor that can measure motion and orientation. In this tutorial, we will learn how to interface the &lt;a href=&quot;https://amzn.to/3YebMJG&quot; target=&quot;_blank&quot;&gt;MPU6050 &lt;/a&gt;with the ESP32, a powerful microcontroller board, to obtain motion data and then use this data to visualize a cube using Qt, and since we are using Qt which is a cross-platform framework, we can easily develop an application for the Desktop environment and also for Android. The following image illustrates the Accelerometer Visualization on Windows Applications and on Android Phones.&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijpGkgbKVruXY5gnMw5i_tlwJdPQPHBUsp3ekYuePkEFNjZfkSF4VuMYokoXG7urCY9YM6oCMopWzNtjbK7LylEESlWl6g5L_zqAIqDEPjtO29w__7BmoKsVAGuVBx61ORIFhjKqfoXAWqAYBMBmxbcXlwJ_it-JyB9Jr_5d_Y_cQ86ZlqYoV_fn4wFAM/s480/87-AccelerometerVisualizationShortsGIF-2.gif&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;270&quot; data-original-width=&quot;480&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijpGkgbKVruXY5gnMw5i_tlwJdPQPHBUsp3ekYuePkEFNjZfkSF4VuMYokoXG7urCY9YM6oCMopWzNtjbK7LylEESlWl6g5L_zqAIqDEPjtO29w__7BmoKsVAGuVBx61ORIFhjKqfoXAWqAYBMBmxbcXlwJ_it-JyB9Jr_5d_Y_cQ86ZlqYoV_fn4wFAM/w400-h225/87-AccelerometerVisualizationShortsGIF-2.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Working Demo&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Note: ESP32 is sending data to Windows using Serial Communication, while ESP32 is sending data to Android Phones using Bluetooth connection.&lt;h3 style=&quot;text-align: left;&quot;&gt;Requirements:&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;ESP32 development board (If you don&#39;t have an ESP32 board then you can use any Arduino-based board, but just make sure to remove the Bluetooth prints from the code)&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://amzn.to/3YebMJG&quot; target=&quot;_blank&quot;&gt;MPU6050 &lt;/a&gt;sensor module&lt;/li&gt;&lt;li&gt;Breadboard and jumper wires&lt;/li&gt;&lt;li&gt;Arduino IDE (or you can use ESP-IDF also but I am not covering that)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h4&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://www.pcbway.com/&quot; target=&quot;_blank&quot;&gt;&lt;img data-original-height=&quot;90&quot; data-original-width=&quot;728&quot; height=&quot;79&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEja55GlkLXVgJuK6dwvfx8hA_J7lTRSagRfKibGjhcdCB3R9sAIuMUywpiq2D2IBGMuSbUWSFLLklA3oR3k5jYz8usZW3G3enjdMOfCdEYa_s7XeurkICZ7t53u_3JhCwA4F1hDAR7Ffc0HwEkgL6_bnWQgI4pPb9KZOfp8IUKWZcIcSVW1PuXxFUitadQ=w640-h79&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;/h4&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;This post is sponsored by PCBWay, with more than a decade in the field of PCB prototype and fabrication, PCBWay is committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests.&amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;As one of the most experienced PCB manufacturers in the World, PCBWay prides itself to be your best business partner as well as a good friend in every aspect of your PCB needs.&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/h4&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Step 1: Wiring the MPU6050 to ESP32:&lt;/h4&gt;&lt;p&gt;Start by connecting the MPU6050 sensor to the ESP32 development board. The MPU6050 communicates using the I2C protocol, so we will connect it as follows:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Connect VCC to 3.3V (or 5V if your MPU6050 module supports it).&lt;/li&gt;&lt;li&gt;Connect GND to the ground pin on the ESP32.&lt;/li&gt;&lt;li&gt;Connect SDA to GPIO 21 on the ESP32.&lt;/li&gt;&lt;li&gt;Connect SCL to GPIO 22 on the ESP32.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiQfXgOypnvi6--U2nyV4uLm8f1G29t2tN0JmQMhyoQdsG57UFcMsaL0piZhbSY7szAO-y8Ixu9DCJ7W7OeaxQRy5btfd81qFpyPyml7fvp2-iHNDtpWvA_PMeu8vuhgYP82LAH1dFuCc4FhGt05jlKr3LS4fwbyZok6LQ7jKmMS-Pp3XcWl5UdNJlSqKg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;437&quot; data-original-width=&quot;492&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiQfXgOypnvi6--U2nyV4uLm8f1G29t2tN0JmQMhyoQdsG57UFcMsaL0piZhbSY7szAO-y8Ixu9DCJ7W7OeaxQRy5btfd81qFpyPyml7fvp2-iHNDtpWvA_PMeu8vuhgYP82LAH1dFuCc4FhGt05jlKr3LS4fwbyZok6LQ7jKmMS-Pp3XcWl5UdNJlSqKg&quot; width=&quot;270&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ESP32 MPU6050 Connection&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Step 2: Installing the Required Libraries:&lt;/h4&gt;&lt;p&gt;To communicate with the MPU6050 and access its data, we need to install the necessary libraries. As we are using the Arduino IDE, open the Library Manager and search for &quot;MPU6050.&quot; Install the library named &quot;MPU6050_Light&quot;. This is not a hard requirement, you can use any other library of your choice, the ultimate aim is to send the &quot;Roll&quot; and &quot;Pitch&quot; values to the Serial Port and over Bluetooth, which will be used by Qt to visualize a cube 3D object.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjp58XZ7crVHjZ2qlIHBXHwx1RqpI5Z8exq2T7vyTpyegPlVcyD5Hip8IVkjYZSD3_SPual3Qe8v_gIdNe5TcOIeirnHvWtab3XBfZ-32PbvgXcsLGLX9RR0s6FLqVHWebGze-pE9qgYwIPGmmmpeVVH0nla77TXRJh-8E1xoB7APXRnm3pHNi8z4lwQJI&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;459&quot; data-original-width=&quot;802&quot; height=&quot;229&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjp58XZ7crVHjZ2qlIHBXHwx1RqpI5Z8exq2T7vyTpyegPlVcyD5Hip8IVkjYZSD3_SPual3Qe8v_gIdNe5TcOIeirnHvWtab3XBfZ-32PbvgXcsLGLX9RR0s6FLqVHWebGze-pE9qgYwIPGmmmpeVVH0nla77TXRJh-8E1xoB7APXRnm3pHNi8z4lwQJI=w400-h229&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Install MPU6050_Light Library&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Step 3: Setting up the Code:&lt;/h4&gt;&lt;p&gt;Create a new sketch in the Arduino IDE. Begin by including the required libraries for the MPU6050 and I2C communication. Then, initialize the I2C interface and the MPU6050 sensor.&lt;/p&gt;&lt;p&gt;Step 4: Reading Data from MPU6050:&lt;/p&gt;&lt;p&gt;In the main loop of your code, read data from the MPU6050 sensor. You can obtain the accelerometer and gyroscope values in three axes (X, Y, Z) using appropriate functions from the MPU6050 library.&lt;/p&gt;&lt;p&gt;As shown in the below-mentioned code, I am just getting &quot;Roll&quot; and &quot;Pitch&quot; values and then transmitting these values to the PC using Serial Communication, and also sending the same value over Bluetooth communication, if your device doesn&#39;t support Bluetooth, you can skip this part.&lt;/p&gt;&lt;p&gt;To get the &quot;Roll&quot; the function &quot;mpu.getAngleX()&quot; is used and similarly to get the value of &quot;Pitch&quot; the function &quot;mpu.getAngleY()&quot; is used.&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Wire.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;BluetoothSerial.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;MPU6050_light.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#if&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;defined&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;(CONFIG_BT_ENABLED) &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;defined&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;(CONFIG_BLUEDROID_ENABLED)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#error&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Bluetooth is not enabled! Please run `make menuconfig` to and enable it&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#endif&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Private Objects and Variables&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;MPU6050&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;mpu&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Wire&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;BluetoothSerial &lt;span style=&quot;color: #9cdcfe;&quot;&gt;SerialBT&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;timer&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;setup&lt;/span&gt;() &lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;115200&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // Bluetooth Device Name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;SerialBT&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;ESP32-Blue&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Wire&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; byte &lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;mpu&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;){ }&lt;span style=&quot;color: #6a9955;&quot;&gt; // stop everything if could not connect to MPU6050&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;delay&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1000&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // mpu.upsideDownMounting = true; // uncomment this line if the MPU6050 is mounted upside-down&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;mpu&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;calcOffsets&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt; // gyro and accelero&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;loop&lt;/span&gt;() &lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;mpu&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;update&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( (&lt;span style=&quot;color: #dcdcaa;&quot;&gt;millis&lt;/span&gt;()&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;timer&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;100&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;timer&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;millis&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; /*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; Serial.print(&quot;X : &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; Serial.print(mpu.getAngleX());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; Serial.print(&quot;\tY : &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; Serial.print(mpu.getAngleY());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; Serial.print(&quot;\tZ : &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; Serial.println(mpu.getAngleZ());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // Printing Data as per our Qt PC Application format&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mpu&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getAngleX&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;,&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mpu&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getAngleY&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // Sending Data as per our Qt Android format&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;SerialBT&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mpu&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getAngleX&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;SerialBT&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;,&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;SerialBT&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mpu&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getAngleY&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Step 5: Receiving this data with Qt and visualizing the MPU6050 sensor position with Qt (Windows)&lt;/h4&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/mFtqv0CtvVY&quot; width=&quot;320&quot; youtube-src-id=&quot;mFtqv0CtvVY&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;This is a complex topic to explain here in a post, so that&#39;s why I have prepared a video to explain the whole steps, you can watch the above-mentioned video.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Step 6: Receiving this data with Qt and visualizing the MPU6050 sensor position with Qt (Android)&lt;/h4&gt;&lt;div&gt;Again this is a complex topic to explain here, so that&#39;s why I have prepared a video to explain some basic steps, plus most of the steps are already in the above mentioned video.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/dY2k-vN_rCI&quot; width=&quot;320&quot; youtube-src-id=&quot;dY2k-vN_rCI&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;Code Download&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/ESP32/tree/master/AccelerometerVisualization&quot; target=&quot;_blank&quot;&gt;Get the ESP32 Arduino Code&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/Qt/tree/master/Projects/AccelerometerVisualizer&quot; target=&quot;_blank&quot;&gt;Get the Qt Code for Windows Application&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/Qt/tree/master/Projects/AccelerometerVisualizerBluetooth&quot; target=&quot;_blank&quot;&gt;Get the Qt Code for Android Application&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Some Other Project Ideas:&lt;/h3&gt;&lt;p&gt;Now that you have successfully interfaced the MPU6050 with the ESP32, you can use the motion data in various exciting projects. Here are a few ideas to get you started:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Create a motion-controlled robot or vehicle.&lt;/li&gt;&lt;li&gt;Build a gesture-based controller for your computer or smart home devices.&lt;/li&gt;&lt;li&gt;Develop a stabilizing platform for a camera or a quadcopter.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Conclusion:&lt;/h3&gt;&lt;p&gt;Interfacing the MPU6050 with the ESP32 opens up a world of possibilities for motion-sensing projects. You can now accurately measure acceleration and rotation, enabling you to create a wide range of applications, from robotics to virtual reality. Experiment with the data, explore new ideas, and have fun building your projects!&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2023/08/accelerometer-data-visualization-on.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijpGkgbKVruXY5gnMw5i_tlwJdPQPHBUsp3ekYuePkEFNjZfkSF4VuMYokoXG7urCY9YM6oCMopWzNtjbK7LylEESlWl6g5L_zqAIqDEPjtO29w__7BmoKsVAGuVBx61ORIFhjKqfoXAWqAYBMBmxbcXlwJ_it-JyB9Jr_5d_Y_cQ86ZlqYoV_fn4wFAM/s72-w400-h225-c/87-AccelerometerVisualizationShortsGIF-2.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-4681553751885578925</guid><pubDate>Thu, 13 Jul 2023 16:57:00 +0000</pubDate><atom:updated>2023-08-26T02:50:03.527-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ESP32</category><category domain="http://www.blogger.com/atom/ns#">IOT</category><title>Sensor Less Weather Station using ESP32 Open Weather Map Website and LVGL</title><description>&lt;p&gt;Hello Everyone, In this post I will show you guys, how to make a Sensorless Weather Station using Open Weather Map website and display the temperature, humidity and pressure values on the LCD along with the city image and name, as shown in the below images.&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/Delhi.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;561&quot; data-original-width=&quot;800&quot; height=&quot;281&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/Delhi.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Delhi Weather Information&lt;br /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/Leh.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;550&quot; data-original-width=&quot;800&quot; height=&quot;275&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/Leh.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Leh Weather Information&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/Shimla.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;553&quot; data-original-width=&quot;800&quot; height=&quot;277&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/Shimla.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Shimla Weather Information&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/Jaipur.JPG&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;558&quot; data-original-width=&quot;800&quot; height=&quot;279&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/Jaipur.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Jaipur Weather Information&lt;br /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;a href=&quot;https://pcbway.com/g/a8XEUi&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;90&quot; data-original-width=&quot;728&quot; height=&quot;90&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/pcbway_banner.jpg&quot; width=&quot;728&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;This post is sponsored by&amp;nbsp;PCBWay, with more than a decade in the field of PCB prototype and fabrication, PCBWay is committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests.&amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;As one of the most experienced PCB manufacturers in the World, PCBWay prides itself to be your best business partner as well as a good friend in every aspect of your PCB needs.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;In the past, I had done a similar project but using Arduino Mega connected to ESP8266 (with AT command firmware), to get similar data and display it using OLED or on a TFT screen, links are given below.&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2021/02/weather-station-using-arduino-and.html&quot;&gt;&lt;b&gt;Weather Station using Arduino and ESP8266 with Open Weather API using AT Command - Embedded Laboratory&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;In this project, I will just use the ESP32 connected to 3.2 inch LCD, to make the connections a little less complex, I am using &lt;a href=&quot;https://amzn.to/3JMzZkk&quot; target=&quot;_blank&quot;&gt;ESP32 Kaluga Development Kit&lt;/a&gt;. This is a low-cost development kit with an onboard 3.2-inch LCD, audio support, camera support etc.&lt;/p&gt;&lt;p&gt;You can watch the following video to understand or read the below-mentioned post.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/aytLCZDDmYU&quot; width=&quot;320&quot; youtube-src-id=&quot;aytLCZDDmYU&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Open Weather Map&lt;/h3&gt;OpenWeatherMap is an online service, owned by OpenWeather Ltd, that provides global &lt;a href=&quot;https://en.wikipedia.org/wiki/Weather&quot;&gt;weather&lt;/a&gt; data via &lt;a href=&quot;https://en.wikipedia.org/wiki/API&quot;&gt;API&lt;/a&gt;, including current weather data, &lt;a href=&quot;https://en.wikipedia.org/wiki/Weather_forecasting&quot;&gt;forecasts&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Nowcasting_(meteorology)&quot;&gt;nowcasts&lt;/a&gt; and historical weather data for any geographical location.&amp;nbsp;&lt;div&gt;The company provides a minute-by-minute hyperlocal &lt;a href=&quot;https://en.wikipedia.org/wiki/Precipitation&quot;&gt;precipitation&lt;/a&gt; forecast for any location. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Convolution&quot;&gt;convolutional&lt;/a&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Machine_learning&quot;&gt;machine learning&lt;/a&gt; model is used to utilise meteorological broadcast services and data from &lt;a href=&quot;https://en.wikipedia.org/wiki/Airport&quot;&gt;airport&lt;/a&gt; &lt;a href=&quot;https://en.wikipedia.org/wiki/Weather_station&quot;&gt;weather stations&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Weather_radar&quot;&gt;on-ground radar stations&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Weather_satellite&quot;&gt;weather satellites&lt;/a&gt;, remote sensing satellites, &lt;a href=&quot;https://en.wikipedia.org/wiki/METAR&quot;&gt;METAR&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Automatic_weather_station&quot;&gt;automated weather stations&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;The company has more than 2 million customers, ranging from independent developers to &lt;a href=&quot;https://en.wikipedia.org/wiki/Fortune_500&quot;&gt;Fortune 500&lt;/a&gt; companies.&lt;/div&gt;&lt;div&gt;I am not going to share how to create an account on the &quot;OpenWeatherMap&quot; website, but in case you want to have some more information, you can read the above-mentioned post and also have a look at the mentioned videos in that post.&lt;/div&gt;&lt;div&gt;Let&#39;s say you wanted to get the weather information of the &quot;Leh&quot; city in India, you can simply type the following line in your web browser and you get the JSON data, as shown below.&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;http:&lt;span style=&quot;color: #6a9955;&quot;&gt;//api.openweathermap.org/data/2.5/weather?q=leh&amp;amp;appid={API_KEY}=metric&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;coord&quot;&lt;/span&gt;:{&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;lon&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;77.5833&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;lat&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;34.1667&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;weather&quot;&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; [&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;id&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;804&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;main&quot;&lt;/span&gt;:&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Clouds&quot;&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;description&quot;&lt;/span&gt;:&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;overcast clouds&quot;&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;icon&quot;&lt;/span&gt;:&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;04n&quot;&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&amp;nbsp; ],&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;base&quot;&lt;/span&gt;:&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;stations&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;main&quot;&lt;/span&gt;:{&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;temp&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;9.05&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;feels_like&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;8.67&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;temp_min&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;9.05&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;temp_max&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;9.05&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;pressure&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;1016&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;humidity&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;91&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;sea_level&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;1016&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;grnd_level&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;676&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;visibility&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;9138&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;wind&quot;&lt;/span&gt;:{&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;speed&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;1.41&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;deg&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;226&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;gust&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;1.33&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;clouds&quot;&lt;/span&gt;:{&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;all&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;100&lt;/span&gt;},&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;dt&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;1688915861&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;sys&quot;&lt;/span&gt;:{&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;country&quot;&lt;/span&gt;:&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;IN&quot;&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;sunrise&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;1688859900&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;sunset&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;1688911451&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;timezone&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;19800&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;id&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;1264976&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;name&quot;&lt;/span&gt;:&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Leh&quot;&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;cod&quot;&lt;/span&gt;:&lt;span style=&quot;color: #b5cea8;&quot;&gt;200&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And then using a JSON parser we can decode this data to extract the &quot;temperature&quot;, &quot;humidity&quot; and pressure information, which can be displayed on the 3.2-inch LCD using the LVGL graphics library.&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Software Architecture&lt;/h3&gt;&lt;div&gt;The software is written using the ESP-IDF framework and is available on my GitHub page free of charge.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/AppMain.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;800&quot; data-original-width=&quot;800&quot; height=&quot;640&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/AppMain.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Main Code Flow&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;The above Activity Diagram is used to explain the steps of this small project.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The first step is to connect with the router so that ESP32 can be connected to the internet to get the data from the &quot;OpenWeatherMap&quot; website.&lt;/li&gt;&lt;li&gt;In the second step, the &quot;OpenWeatherMap&quot; software module is initialized, which doesn&#39;t do much, it will just initialize the names of the city (this also can be configured, but I have kept them hard-coded inside the module)&lt;/li&gt;&lt;li&gt;In the third step, the &quot;Display&quot; software module is initialized, it will initialize the 3.2 Inch LCD and also initialize the LVGL Graphics Library, in the background a FreeRTOS task is created and this task keeps on refreshing the display by calling the LVGL functions.&lt;/li&gt;&lt;li&gt;So now only two FreeRTOS tasks running, one is &quot;app_main&quot; which is also known as the main task and another task is the &quot;LVGL&quot; task which is hidden from us directly, ideally we can create another task also dedicated to &quot;Open Weather Map&quot; but I avoided to do so, as of now.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Main Code:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Main Program Starts from Here&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;app_main&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int64_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;current_time&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_ERR_NVS_NO_FREE_PAGES &lt;span style=&quot;color: #d4d4d4;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_ERR_NVS_NEW_VERSION_FOUND)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_erase&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;nvs_flash_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_ERROR_CHECK&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Connect to Wireless Access Point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;connect_wifi&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ret&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;WIFI_SUCCESS&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Initialize the OpenWeatherMap module&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Initialize the Display Manager&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;display_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;openweathermap_timestamp&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_timer_get_time&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;display_timestamp&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_timer_get_time&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;current_time&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_timer_get_time&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// OpenWeatherMap Management&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;current_time&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;openweathermap_timestamp&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;OPENWEATHERMAP_MNG_EXEC_RATE&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;openweathermap_timestamp&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;current_time&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_mng&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Display Management&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;current_time&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;display_timestamp&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;DISPLAY_MNG_EXEC_RATE&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;display_timestamp&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;current_time&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;display_mng&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelay&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;MAIN_TASK_EXEC_RATE&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt; portTICK_PERIOD_MS);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/OpenWeatherMapManager.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;433&quot; data-original-width=&quot;800&quot; height=&quot;347&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/OpenWeatherMapManager.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Open Weather Map HTTP Client Request&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The above Activity Diagram shows how the &quot;OpenWeather Map&quot; software module us handling the different cases to send the HTTP GET requests and get the data from the &quot;Open Weather Map&quot; website using API calls.&lt;/div&gt;&lt;div&gt;And once the data is received which is in JSON format, the &quot;cJSON&quot; inbuilt library is used to extract the &quot;Temperature&quot;, &quot;Pressure&quot; and &quot;Humidity&quot; data from it, and saved in the global structures.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Open Weather Map Module:&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_init&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Initialize the City Names&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;strcpy&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;].&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_name&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;delhi&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;strcpy&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;].&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_name&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;shimla&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;strcpy&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;].&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_name&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;jaipur&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;strcpy&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;].&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_name&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;leh&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// OpenWeatherMap Manager&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_mng&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;request_in_process&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;request_in_process&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_send_request&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// OpenWeatherMap Task (optional, if we don&#39;t want to use above two functions manually)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_task&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pvParameters&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_init&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;(;;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_mng&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelay&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;HTTP_REQ_EXEC_RATE&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt;portTICK_PERIOD_MS);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;vTaskDelete&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Private Function Definitions&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_send_request&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;openweathermap_url&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;200&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;snprintf&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;openweathermap_url&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;openweathermap_url&lt;/span&gt;), &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%s%s%s&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;CLIENT_REQ_PRE&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt;].&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_name&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;CLIENT_REQ_POST&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_http_client_config_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; .url &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;openweathermap_url&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; .method &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; HTTP_METHOD_GET,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; .event_handler &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_event_handler&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; };&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// ESP_LOGI(TAG, &quot;URL:%s&quot;, openweathermap_url);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Free Heap: &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%lu&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_get_free_heap_size&lt;/span&gt;() );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_http_client_handle_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_init&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;config&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_set_header&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;CLIENT_KEY&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;CLIENT_VALUE&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;err&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_perform&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;err&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; ESP_OK )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_get_status_code&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;200&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Message Sent Successfully&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Message Sent Failed&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Message Sent Failed&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;esp_http_client_cleanup&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;client&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_err_t&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_event_handler&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;esp_http_client_event_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;switch&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;event_id&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; HTTP_EVENT_ON_DATA:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Copy the Data to response_data buffer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;memcpy&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;response_data&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;response_data_idx&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;data&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;data_len&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Update the Length&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;response_data_idx&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;event&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;data_len&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; HTTP_EVENT_ON_FINISH:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Decode/Parse the weather data from the response data&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_get_weather&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;response_data&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt;]);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// reset the response buffer and also the length to initial state&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_reset_buffer&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ESP_LOGI&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;TAG&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;City=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%s&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, Temp=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, Pressure=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, Humidity=&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt;].city_name, &amp;nbsp; &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt;].temperature, &lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt;].pressure, &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt;].humidity);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Reset back to Initial Position&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;NUM_OF_CITIES&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;city_weather_index&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Free the system for next requests&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;request_in_process&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;case&lt;/span&gt; HTTP_EVENT_ERROR:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// In case of Error, exit&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_reset_buffer&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Free the system for next requests&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;request_in_process&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;default&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; ESP_OK;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;openweathermap_get_weather&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;json_string&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;weather_data_t&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;weather_data&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; cJSON &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;root &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;cJSON_Parse&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;json_string&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; cJSON &lt;span style=&quot;color: #d4d4d4;&quot;&gt;*&lt;/span&gt;obj &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;cJSON_GetObjectItemCaseSensitive&lt;/span&gt;(root, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;main&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;weather_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;cJSON_GetObjectItemCaseSensitive&lt;/span&gt;(obj, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;temp&quot;&lt;/span&gt;)-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;valueint&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;weather_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pressure&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;cJSON_GetObjectItemCaseSensitive&lt;/span&gt;(obj, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;pressure&quot;&lt;/span&gt;)-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;valueint&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;weather_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;cJSON_GetObjectItemCaseSensitive&lt;/span&gt;(obj, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;humidity&quot;&lt;/span&gt;)-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;valueint&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;cJSON_Delete&lt;/span&gt;(root);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/DisplayRefreshManager.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;526&quot; data-original-width=&quot;800&quot; height=&quot;421&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/ESP-IDF/OpenWeatherMap/docs/DisplayRefreshManager.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Display Refreshing Logic&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And then in another function &quot;display_mng&quot; is used to update the &quot;Temperature&quot;, &quot;Pressure&quot;, &quot;Humidity&quot; and &quot;City Name&quot; with the city image on the display using LVGL functions.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The code snippet attached above is just for reference, &lt;span style=&quot;color: #6fa8dc; font-size: medium;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/ESP32/tree/master/ESP-IDF/OpenWeatherMap&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;click here to get the code from GitHub&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;.&lt;/div&gt;&lt;div&gt;&lt;p&gt;Thanks&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2023/07/sensor-less-weather-station-using-esp32.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/aytLCZDDmYU/default.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-1731893763166737447</guid><pubDate>Sun, 28 May 2023 11:53:00 +0000</pubDate><atom:updated>2023-05-28T04:55:56.880-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Others</category><title>Temperature Controlled Switch without Microcontroller</title><description>&lt;p&gt;Hello Everyone, in this post I will share with you guys a simple circuit without a microcontroller, which can be used to control or switch an external load based on the temperature information.&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGd3CKWCcB39XqhU_3S0HERbHXXaaKv2NtLhzEGi7QcCULXb9_9sBzQkcnBt570gS7sNMxr7K4oYlTmH76r5_EINpdTx_epmLw1V805OODpp5KOuIQCQZqQnN3l6aCgHISNDWXAyc3yFfx13YJMTkCr-DB1STalU4FUjEuoaPLGyaHQUIv6sPv6kIp/s1920/Temperature%20Controlled%20Switch.gif&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGd3CKWCcB39XqhU_3S0HERbHXXaaKv2NtLhzEGi7QcCULXb9_9sBzQkcnBt570gS7sNMxr7K4oYlTmH76r5_EINpdTx_epmLw1V805OODpp5KOuIQCQZqQnN3l6aCgHISNDWXAyc3yFfx13YJMTkCr-DB1STalU4FUjEuoaPLGyaHQUIv6sPv6kIp/w400-h225/Temperature%20Controlled%20Switch.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Temperature Controlled Switch&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;The temperature-controlled switch triggers automatically when the ambient temperature goes beyond the set temperature (in the above-mentioned circuit it is set to 50 degree Celsius but can be changed easily to any other value with the help of a potentiometer).&lt;/p&gt;&lt;p&gt;The circuit has three main parts.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The Temperature Sensor LM35&lt;/li&gt;&lt;li&gt;The Main Control Unit (Simple Circuit based on OP-AMP)&lt;/li&gt;&lt;li&gt;Relay (used to control the external load, here it is used to control the Lamp)&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Circuit and Working&lt;/h3&gt;&lt;div&gt;The circuit comprises a step-down transformer, a bridge rectifier and a voltage regulator 7805 integrated circuit chip, a temperature sensor integrated circuit chip LM35, an Operation Amplifier LM35, and a changeover 5V relay, apart from this we have used some simple components like resistor, capacitor, diodes and LEDs.&lt;/div&gt;&lt;div&gt;The IC LM35, the heart of the circuit, is a 3-pin device like a transistor with pins for VCC, GND, and&lt;/div&gt;OUTPUT. It gives variable voltage at the output based on temperature up to 150 degrees Celsius. This popular and inexpensive temperature sensor is generally used in digital thermometers.&lt;div&gt;For every one-degree centigrade rise in temperature, there is a 10mV increase in voltage at the output pin. Let us say, at 0°C the output of the sensor is 0V. When the temperature rises to 10°C the output will become 100mV; at 25°C it will become 250mV.&lt;/div&gt;Temperature sensor LM35 senses the temperature and gives the signal to the controller built around IC&lt;br /&gt;LM358. The data received by the controller is then given to the relay driver circuit built around the driver transistor&amp;nbsp;and changeover relay. On receiving the signal from the controller,&amp;nbsp;the relay is turned on/off. This process repeats forever.&lt;div&gt;Calibration of the LM35 sensor should be done as we have used opamp LM358 to compare the output voltage of LM35 with the reference voltage. Since the circuit has been set for the threshold voltage of 50°C,&lt;br /&gt;to trigger the op-amp we need to set the reference voltage to 0.5V, as at 50°C the output of LM35 will be 0.5V. The reference voltage is at pin 2 of LM358.&lt;/div&gt;The working of the circuit is simple. When power is switched on, the LED glows and the circuit is ready to use. As soon as some heat is provided near the LM35 sensor, the voltage at pin 3 of the Operational Amplifier goes higher than the reference voltage at pin 2, so the output of the op-amp at pin 1 goes high and relay energies. As a result, the light bulb gets connected to the 230V AC supply and switches on.&lt;br /&gt;When the temperature at pin 3 of the op-amp goes lower than the reference voltage at pin 2, the output of the op-amp at its pin 1 goes low and the relay de-energises. As a result, the light bulb gets disconnected from the 230V AC and switches off.&lt;div&gt;The bulb can be replaced with any other appliance, such as a fan or an air cooler, which will switch&lt;br /&gt;on automatically when the room temperature goes beyond a limit. The circuit can also be used as a fire&lt;br /&gt;alarm circuit by setting the reference temperature very high, like 100°C, and connecting an electric bell or siren as the load. After using a higher current rating relay, the circuit can be designed to automatically switch on even an air-conditioner when the room temperature becomes high.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://drive.google.com/file/d/1pweRgVaoAiUMovEvnKC7wXDNk-U6mvy2/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Click Here to download the Proteus Simulation File&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2023/05/temperature-controlled-switch-without.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGd3CKWCcB39XqhU_3S0HERbHXXaaKv2NtLhzEGi7QcCULXb9_9sBzQkcnBt570gS7sNMxr7K4oYlTmH76r5_EINpdTx_epmLw1V805OODpp5KOuIQCQZqQnN3l6aCgHISNDWXAyc3yFfx13YJMTkCr-DB1STalU4FUjEuoaPLGyaHQUIv6sPv6kIp/s72-w400-h225-c/Temperature%20Controlled%20Switch.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-1106159268431595991</guid><pubDate>Sat, 29 Apr 2023 10:48:00 +0000</pubDate><atom:updated>2023-04-29T03:48:16.899-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Others</category><title>Real Time Temperature and Humidity Plot Using QML and QCharts</title><description>&lt;p&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;Hello! In this post, I will show you how to plot the data in real-time using QML and QCharts Library.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/Qt/master/Documentation/RealTimeTemperatureAndHumidityPlotQtQML.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;800&quot; data-original-width=&quot;603&quot; height=&quot;400&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/Qt/master/Documentation/RealTimeTemperatureAndHumidityPlotQtQML.gif&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;QML Application&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #2e2e2e; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;font-family: verdana; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;In this post, I am using the sensor &lt;a href=&quot;https://amzn.to/3KYQ2LR&quot; target=&quot;_blank&quot;&gt;BME280&lt;/a&gt; which can give us temperature, humidity and pressure data, and we will only use the temperature and humidity for this post. This data is transmitted over Serial Port with the help of Arduino UNO. Then this data is received by Qt using the QSerialPort library and then plotted in real-time using QCharts Library.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #2e2e2e; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;font-family: verdana; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;I will not explain the BME280 sensor part, as this is very basic and can be found in several other posts on the internet, but I will share the connection diagram and the code&amp;nbsp;I am using for Arduino UNO.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #2e2e2e; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;font-family: verdana; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg91EIeFp1MDQ7PsOChbpuPKoQTgj2YaX5J0ROkTa-1uMiqHGx0L0HAXhmq4lx_3Dj28C1yD8CJ5bSE44CQxco-himC7ETV8X5lf6Wi7Euii-Y5E2wu0X-he7hX5_ev6X1Rrsw2ulVm_V0yt0ilOEQiw7qtD2OGDXaDxO79CIX_cjqLonzoTawAj1H6&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;770&quot; data-original-width=&quot;1277&quot; height=&quot;241&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg91EIeFp1MDQ7PsOChbpuPKoQTgj2YaX5J0ROkTa-1uMiqHGx0L0HAXhmq4lx_3Dj28C1yD8CJ5bSE44CQxco-himC7ETV8X5lf6Wi7Euii-Y5E2wu0X-he7hX5_ev6X1Rrsw2ulVm_V0yt0ilOEQiw7qtD2OGDXaDxO79CIX_cjqLonzoTawAj1H6=w400-h241&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Arduino UNO Connection with BME280 Sensor Module&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;The Arduino IDE source code which I am using is as below, note in order to make this code work you guys have to install Adafruit BME280 Sensor Library.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; color: #2e2e2e; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;font-family: verdana; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;Wire.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;Adafruit_Sensor.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;Adafruit_BME280.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;SEALEVELPRESSURE_HPA&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; (1013.25)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Adafruit_BME280&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bme&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// I2C&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;delayTime&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;BUFFER_SIZE&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (20u)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;buffer&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;BUFFER_SIZE&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printValues&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt; = (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #9cdcfe;&quot;&gt;bme&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;readTemperature&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt; = (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #9cdcfe;&quot;&gt;bme&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;readHumidity&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;snprintf&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;buffer&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;BUFFER_SIZE&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%.2d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%.2d&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\r\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;buffer&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;setup&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;9600&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;delay&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;100&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // default settings&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bme&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(); &amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // You can also pass in a Wire library object like &amp;amp;Wire2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // status = bme.begin(0x76, &amp;amp;Wire2)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (!&lt;span style=&quot;color: #9cdcfe;&quot;&gt;status&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Could not find a valid BME280 sensor, check wiring, address, sensor ID!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;SensorID was: 0x&quot;&lt;/span&gt;); &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;bme&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sensorID&lt;/span&gt;(),&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ID of 0xFF probably means a bad address, a BMP 180 or BMP 085&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp; ID of 0x56-0x58 represents a BMP 280,&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ID of 0x60 represents a BME 280.&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ID of 0x61 represents a BME 680.&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;) &lt;span style=&quot;color: #dcdcaa;&quot;&gt;delay&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;delayTime&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1000&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;loop&lt;/span&gt;() &lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printValues&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;delay&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;delayTime&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style=&quot;background-color: white; color: #2e2e2e; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; transition: all 0.3s ease 0s;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;background-color: white; color: #2e2e2e; font-family: &amp;quot;Open Sans&amp;quot;, sans-serif; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; text-align: left; transition: all 0.3s ease 0s;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: verdana;&quot;&gt;Writing Qt Program&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;The Qt Program can be divided into multiple steps, and they are mentioned below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;Get the list of available COM ports available on the Computer&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;Updating the Combo Box with the list of available serial ports&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;Updating the data in line series&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;Scrolling the plot when the configured time frame is reached&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;Get the List of the available COM Ports&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;TODO steps in the coming days.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2e2e2e; font-family: verdana;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 14px;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/Qt/tree/master/QtCharts/PlotTempAndHumidityRealTimeQML&quot; target=&quot;_blank&quot;&gt;Get the code from GitHub&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2e2e2e; font-family: verdana;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 14px;&quot;&gt;&lt;a href=&quot;https://drive.google.com/file/d/18fEZq0G2etfFVcc72EsFuGy5jWyIPI-t/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;Download the Code Directly&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2023/04/real-time-temperature-and-humidity-plot.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEg91EIeFp1MDQ7PsOChbpuPKoQTgj2YaX5J0ROkTa-1uMiqHGx0L0HAXhmq4lx_3Dj28C1yD8CJ5bSE44CQxco-himC7ETV8X5lf6Wi7Euii-Y5E2wu0X-he7hX5_ev6X1Rrsw2ulVm_V0yt0ilOEQiw7qtD2OGDXaDxO79CIX_cjqLonzoTawAj1H6=s72-w400-h241-c" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-3667721908710293305</guid><pubDate>Mon, 10 Apr 2023 13:53:00 +0000</pubDate><atom:updated>2023-04-10T06:53:50.480-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Others</category><title>Real-Time Temperature Plot using Qt and QCustomPlot</title><description>&lt;p&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Hello! Everyone, in this post I will show you how to plot the data in real-time using Qt and QCustomPlot library.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-size: 14px;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuKIO1fcXBczti3sOGvF3oti-x_hdR6z2a9JNS63CC103le2sUW8MiRpdzjG_-IdbcSmi2yrHdJe1zQe7_vj9-Fwfta0dItzcd60JqMOn73ihA4f40wmd-in6fH7BtJchoBAbRUEIEelDFkswSkJZYwe09zCSuol7hVbHnw6ZpV0BXekpONHITTMLVjg/s808/83-ForBloggerGIF.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;644&quot; data-original-width=&quot;808&quot; height=&quot;319&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuKIO1fcXBczti3sOGvF3oti-x_hdR6z2a9JNS63CC103le2sUW8MiRpdzjG_-IdbcSmi2yrHdJe1zQe7_vj9-Fwfta0dItzcd60JqMOn73ihA4f40wmd-in6fH7BtJchoBAbRUEIEelDFkswSkJZYwe09zCSuol7hVbHnw6ZpV0BXekpONHITTMLVjg/w400-h319/83-ForBloggerGIF.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Temperature Real-Time Plot using Qt and QCustomPlot&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #2e2e2e; font-family: verdana; font-size: 14px;&quot;&gt;In this post, I am using a temperature sensor LM35 which is connected to Arduino UNO, and the Arduino UNO is converting the analog values received from the sensor into a corresponding digital value, which is then transmitted over Serial Terminal, and this data is then received by Qt using QSerialPort library, and then plotted using QCustomPlot library.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #2e2e2e; font-family: verdana;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 14px;&quot;&gt;I am not going to explain the LM35 sensor part, as this is very basic and can be found in several other posts on my blog post itself, one such blog post is available below.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2017/03/real-time-temperature-monitoring-using.html&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Real-Time Temperature Monitoring using MATLAB &amp;amp; Python - Embedded Laboratory&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;QtCharts vs QCustomPlot&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;QtCharts is the charting library provided by Qt company while the QCustomPlot library is from some another vendor, now the questions might be asked why I am using the QCustomPlot library instead of QtCharts, and the reason is I don&#39;t know 😊.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;What I have read on several Qt forums is that the QtChart library is poorly designed, but to be very honest with you guys I am not an expert so I don&#39;t know if this is true or not, I will try to share my personal experience, initially, I started using the QtCharts library, and simple things were working fine, but then I moved to a complex part of updating the data in real-time, and unfortunately I couldn&#39;t make it work, I spent several hours on finding a fix, but nothing works, I am 100% that I am doing something wrong but I don&#39;t have a solution and just as a random try I started with the QCustomPlot library, and I am really liking this, and this is the reason that this blog post I am using the QCustomPlot library.&lt;/span&gt;&lt;/p&gt;&lt;h3&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Challenges Faced&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I would like to list down the challenges I faced while developing this small project, and they are as below.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The first challenge was using the QCustomPlot library with Qt6 as a CMake project, for some of you this might be not a must, but these days I switched to CMake and hence it was quite shocking for me why I am not able to use the QCustomPlot library in my Qt CMake project. But then thanks to &quot;Leger Charlie&quot; a GitHub user, who has already solved this problem and has a repository for this, I used his library as a git submodule project for my development.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/leger50/QCustomPlot-library&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;leger50/QCustomPlot-library (github.com)&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Another problem I was facing was setting the ticker properly for X-axis, and the reason was also very simple, here I was using the class &quot;QCPAxisTickerTime&quot;, the problem was my time was in seconds since &lt;a href=&quot;https://www.codingem.com/epoch-time/&quot; target=&quot;_blank&quot;&gt;Epoch time&lt;/a&gt;, while this class only considers the pure time, and the solution was to use the class &quot;QCPAxisTickerDateTime&quot; to format my ticker on X-Axis.&lt;/span&gt;&lt;/p&gt;&lt;h3&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Source Code&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I prepared a temperature viewer class which is handling all the things from getting the data from the serial port and plotting the data.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following is the content of the &lt;b&gt;main.cpp&lt;/b&gt; file.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;temperatureviewer.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;QApplication&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;argc&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;argv&lt;/span&gt;[])&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; QApplication &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;argc&lt;/span&gt;, argv);&lt;/div&gt;&lt;div&gt;&amp;nbsp; TemperatureViewer &lt;span style=&quot;color: #9cdcfe;&quot;&gt;w&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;w&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;show&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;exec&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This is very simple, we created an application and just showed this application, and all the things are happening inside the application class instance.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following is the content of the temperatureviewer.h file.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#ifndef&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; TEMPERATUREVIEWER_H&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;TEMPERATUREVIEWER_H&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;QMainWindow&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;QDebug&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;QTimer&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;QSerialPort&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;QSerialPortInfo&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;QT_BEGIN_NAMESPACE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Ui&lt;/span&gt; { &lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;TemperatureViewer&lt;/span&gt;; }&lt;/div&gt;&lt;div&gt;QT_END_NAMESPACE&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;TemperatureViewer&lt;/span&gt; : &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QMainWindow&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; Q_OBJECT&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;public:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;TemperatureViewer&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;QWidget&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;parent&lt;/span&gt; = &lt;span style=&quot;color: #569cd6;&quot;&gt;nullptr&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;~TemperatureViewer&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;private slots:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;on_btn_ConnectDisconnect_clicked&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;public slots:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;read_data&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;private:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Ui&lt;/span&gt;::TemperatureViewer *ui;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; connect_status = &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; QSerialPort m_serial;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;refreshGraph&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#endif&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; // TEMPERATUREVIEWER_H&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I will try to explain the usage of all members and methods of this class.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&quot;connect_status&quot;: this member is used to track the status of the QSerialPort connection status, if the connection is successful its value is true else false.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&quot;m_serial&quot;: this member is a &quot;QSerialPort&quot; object, and we will communicate with the actual serial port using this object.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&quot;refreshGraph&quot;: this method is used to update/refresh the graph every second.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following is the content of the temperatureviewer.cpp file.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;temperatureviewer.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;./ui_temperatureviewer.h&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;QDateTime&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;const&lt;/span&gt; qint8 &lt;span style=&quot;color: #9cdcfe;&quot;&gt;SECONDS_SHOW_ON_GRAPH&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;120&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp;// Display 120 seconds on the graph&lt;/span&gt;&lt;/div&gt;&lt;div&gt;QList&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;double&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_axis&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;QList&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;double&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature_axis&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; qint64 &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp_data_idx&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; // to be used later for x-axis range setting&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; qint64 &lt;span style=&quot;color: #9cdcfe;&quot;&gt;startTime&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;TemperatureViewer&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;TemperatureViewer&lt;/span&gt;(QWidget *parent) : &lt;span style=&quot;color: #dcdcaa;&quot;&gt;QMainWindow&lt;/span&gt;(parent) , &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ui&lt;/span&gt;(&lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Ui&lt;/span&gt;::TemperatureViewer)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setupUi&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;qDebug&lt;/span&gt;() &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Detecting Available Serial Ports&quot;&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; QList&amp;lt;QSerialPortInfo&amp;gt; serial_port_infos = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QSerialPortInfo&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;availablePorts&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;const&lt;/span&gt; QSerialPortInfo &amp;amp;port_info : serial_port_infos )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;qDebug&lt;/span&gt;() &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Port:&quot;&lt;/span&gt; &amp;lt;&amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;port_info&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;portName&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // Add these found com ports to the combo box&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cb_COMP&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addItem&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;port_info&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;portName&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // Plotting Stuff&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // Create graph and assign data to it&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addGraph&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // give axis some labels&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xAxis&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setLabel&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Time&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yAxis&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setLabel&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Temperature&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; QColor &lt;span style=&quot;color: #dcdcaa;&quot;&gt;color&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;40&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;110&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;255&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;graph&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setLineStyle&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QCPGraph&lt;/span&gt;::lsLine );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;graph&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setPen&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;QPen&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;color&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;lighter&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;30&lt;/span&gt;)) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;graph&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setBrush&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;QBrush&lt;/span&gt;(color) );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // configure bottom axis to show date instead of number:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; QSharedPointer&amp;lt;QCPAxisTickerDateTime&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;date_time_ticker&lt;/span&gt;(&lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; QCPAxisTickerDateTime);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;date_time_ticker&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setDateTimeFormat&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;hh:mm:ss&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xAxis&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setTicker&lt;/span&gt;(date_time_ticker);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // make left and bottom axes transfer their ranges to right and top axes:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;connect&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xAxis&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;SIGNAL&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;rangeChanged&lt;/span&gt;(QCPRange)), &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xAxis2&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;SLOT&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setRange&lt;/span&gt;(QCPRange)));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;connect&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yAxis&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;SIGNAL&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;rangeChanged&lt;/span&gt;(QCPRange)), &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yAxis2&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;SLOT&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setRange&lt;/span&gt;(QCPRange)));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // Allow user to drag axis ranges with mouse, zoom with mouse wheel and select graphs by clicking:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setInteractions&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;QCP&lt;/span&gt;::iRangeDrag | &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QCP&lt;/span&gt;::iRangeZoom | &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QCP&lt;/span&gt;::iSelectPlottables);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // first we create and prepare a text layout element:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; QCPTextElement *&lt;span style=&quot;color: #9cdcfe;&quot;&gt;title&lt;/span&gt; = &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;QCPTextElement&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;title&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setText&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Temperature Real-Time Plot&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;title&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setFont&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;QFont&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sans&quot;&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QFont&lt;/span&gt;::Bold));&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // then we add it to the main plot layout:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // insert an empty row above the axis rect&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;plotLayout&lt;/span&gt;()-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;insertRow&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // place the title in the empty cell we&#39;ve just created&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;plotLayout&lt;/span&gt;()-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addElement&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, title);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // Start Timer to Refresh the graph&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; QTimer *&lt;span style=&quot;color: #9cdcfe;&quot;&gt;timer&lt;/span&gt; = &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;QTimer&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;connect&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;timer&lt;/span&gt;, &amp;amp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;QTimer&lt;/span&gt;::timeout, &lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;, &amp;amp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;TemperatureViewer&lt;/span&gt;::refreshGraph );&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // Start Timer @ 1 second&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;timer&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;start&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1000&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;TemperatureViewer&lt;/span&gt;::~&lt;span style=&quot;color: #dcdcaa;&quot;&gt;TemperatureViewer&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;isOpen&lt;/span&gt;() )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // if serial port is open close it&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;close&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;delete&lt;/span&gt; ui;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;TemperatureViewer&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;on_btn_ConnectDisconnect_clicked&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;double&lt;/span&gt; now;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; // if false, we have to connect, else disconnect&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( connect_status == &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;qInfo&lt;/span&gt;() &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Connecting...&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setBaudRate&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QSerialPort&lt;/span&gt;::Baud9600 );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setDataBits&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QSerialPort&lt;/span&gt;::Data8 );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setParity&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QSerialPort&lt;/span&gt;::NoParity );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setStopBits&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QSerialPort&lt;/span&gt;::OneStop );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setFlowControl&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QSerialPort&lt;/span&gt;::NoFlowControl );&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // Select the COM Port from Combo Box&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setPortName&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cb_COMP&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;currentText&lt;/span&gt;() );;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;open&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QIODevice&lt;/span&gt;::ReadWrite ) )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;qDebug&lt;/span&gt;() &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Serial Port Opened Successfully&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;write&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Hello World from Qt&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\r\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; connect_status = &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;btn_ConnectDisconnect&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setText&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Disconnect&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // disable the combo box&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cb_COMP&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setEnabled&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // Connect Signal and Slots&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;connect&lt;/span&gt;(&amp;amp;m_serial, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;SIGNAL&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;readyRead&lt;/span&gt;() ), &lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;SLOT&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;read_data&lt;/span&gt;() ) );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;startTime&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QDateTime&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;currentSecsSinceEpoch&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;startTime&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // set axes ranges, so we see all data:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xAxis&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setRange&lt;/span&gt;( now, now+SECONDS_SHOW_ON_GRAPH);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yAxis&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setRange&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;60&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;qDebug&lt;/span&gt;() &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Unable to open the Selected Serial Port&quot;&lt;/span&gt; &amp;lt;&amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;error&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;qInfo&lt;/span&gt;() &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Disconnecting...&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // close the serial port&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;close&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; connect_status = &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;btn_ConnectDisconnect&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setText&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Connect&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // Enable the combo box&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cb_COMP&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setEnabled&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;TemperatureViewer&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;read_data&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; data;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;float&lt;/span&gt; temp_value;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;double&lt;/span&gt; now = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QDateTime&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;currentSecsSinceEpoch&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;bytesAvailable&lt;/span&gt;() )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // Read one byte at a time&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m_serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;read&lt;/span&gt;(&amp;amp;data, &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( (data != &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&lt;/span&gt;) &amp;amp;&amp;amp; (data != &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&lt;/span&gt;) )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // convert adc counts back to the temperature value&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // temperature = (adc counts * VCC in mV/ADC Resolution)/10mV&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; temp_value = (data * &lt;span style=&quot;color: #b5cea8;&quot;&gt;500.0&lt;/span&gt; / &lt;span style=&quot;color: #b5cea8;&quot;&gt;1023.0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;time_axis&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;append&lt;/span&gt;(now);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature_axis&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;append&lt;/span&gt;(temp_value);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; temp_data_idx++;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;qDebug&lt;/span&gt;() &amp;lt;&amp;lt; temp_data_idx &amp;lt;&amp;lt; temp_value;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;TemperatureViewer&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;refreshGraph&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;double&lt;/span&gt; now = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;QDateTime&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;currentSecsSinceEpoch&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( connect_status )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;graph&lt;/span&gt;()-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setData&lt;/span&gt;( time_axis, temperature_axis);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // if time has elapsed then only start shifting the graph&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( ((qint64)(now) - startTime) &amp;gt; SECONDS_SHOW_ON_GRAPH )&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // If SECONDS_SHOW_GRAPH&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xAxis&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setRange&lt;/span&gt;(now, SECONDS_SHOW_ON_GRAPH, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Qt&lt;/span&gt;::AlignRight);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ui&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;customPlot&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;replot&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In the constructor code of this class we are doing the following things:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;With the help of the &quot;QSerialPortInfo&quot; class, we are getting the information on the available serial ports, and these port names are added to the combo box so that they can be selected by the user.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;A graph is added, where labels for the x and y axis are specified, and some other configuration is done like line color and brush&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Then the x-axis ticker is updated in an hour, minute and seconds format.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Interactions are also added to the graph for dragging, zooming and scrolling.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;A title is specified in the graph.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In the destructor part of the code, we are closing the serial port if open and deleting the UI object.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Then we have a button named as connect button, and whenever this button is clicked a signal is emitted internally, and we have mapped a slot for this clicked event, and hence the &quot;on_btn_ConnectDisiconnect_clicked&quot; function is called.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this function, if the connection status is false, we are configuring the serial port and opening it, and also changing the name of the connect button to disconnect, as next time the same button will be used for disconnecting from the com port.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Then the &quot;read_data&quot; function is called whenever we receive some data over the serial port, and once this data is received it is decoded and converted into the temperature value, and then these values are updated in the list along with the timestamp.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Plotting of this data in real-time is done using the function &quot;refreshGraph&quot; function here graph is updated periodically, here a timer is configured to update the graph every second.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana; font-size: x-small;&quot;&gt;&lt;i&gt;NOTE: I am not a C++ programmer, I have mostly used C in my life and now started learning C++, so it might be possible I made some silly mistakes that can be avoided by some expert, any feedback is welcomed.&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The code is available on my &lt;a href=&quot;https://github.com/xpress-embedo/ArduinoTempLogger/tree/master/TemperatureViewer&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;GitHub Repository&lt;/b&gt;&lt;/span&gt;&lt;/a&gt; and can also be downloaded by &lt;a href=&quot;https://drive.google.com/file/d/1TrfSi9dsALa-OpO-Q6J6LHF3zCHsFEYu/view?usp=share_link&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;clicking here&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;</description><link>http://embeddedlaboratory.blogspot.com/2023/04/real-time-temperature-plot-using-qt-and.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuKIO1fcXBczti3sOGvF3oti-x_hdR6z2a9JNS63CC103le2sUW8MiRpdzjG_-IdbcSmi2yrHdJe1zQe7_vj9-Fwfta0dItzcd60JqMOn73ihA4f40wmd-in6fH7BtJchoBAbRUEIEelDFkswSkJZYwe09zCSuol7hVbHnw6ZpV0BXekpONHITTMLVjg/s72-w400-h319-c/83-ForBloggerGIF.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-8517217883365971313</guid><pubDate>Sun, 29 Jan 2023 10:48:00 +0000</pubDate><atom:updated>2023-08-26T02:50:50.491-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">IOT</category><category domain="http://www.blogger.com/atom/ns#">Others</category><title>Getting Started with MQTT using Qt</title><description>&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Qt is a cross-platform framework written in C++ for creating graphical user interfaces as well as cross-platform applications that run on various software and hardware platforms such as Linux, Windows, macOS, Android, or embedded systems with little or no change in the underlying code base while still being a native application with native capabilities and speed.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;MQTT is a lightweight, publish-subscribe, machine-to-machine 
network protocol for message queue/message queuing service. It is 
designed for connections with remote locations that have devices with 
resource constraints or limited network bandwidth.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this post, I will show you how to get started quickly with MQTT using Qt. Qt already provides the QTMQTT library but unfortunately for the open-source version of Qt, we have to build the QtMQTT source code to generate the library, and this is the main motive behind this post.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;If you are interested in watching the video, please watch the below-mentioned video, or else continue reading this post. &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/DGB0GfFRqPo&quot; width=&quot;320&quot; youtube-src-id=&quot;DGB0GfFRqPo&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;The above-mentioned video is for Linux Users and the below-mentioned video is for Windows.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/LIOw1c8I394&quot; width=&quot;320&quot; youtube-src-id=&quot;LIOw1c8I394&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;h4&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://www.pcbway.com/&quot; target=&quot;_blank&quot;&gt;&lt;img data-original-height=&quot;90&quot; data-original-width=&quot;728&quot; height=&quot;79&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEja55GlkLXVgJuK6dwvfx8hA_J7lTRSagRfKibGjhcdCB3R9sAIuMUywpiq2D2IBGMuSbUWSFLLklA3oR3k5jYz8usZW3G3enjdMOfCdEYa_s7XeurkICZ7t53u_3JhCwA4F1hDAR7Ffc0HwEkgL6_bnWQgI4pPb9KZOfp8IUKWZcIcSVW1PuXxFUitadQ=w640-h79&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/h4&gt;&lt;i&gt;This post is sponsored by PCBWay, with more than a decade in the field of PCB prototype and fabrication, PCBWay is committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. &lt;br /&gt;As one of the most experienced PCB manufacturers in the World, PCBWay prides itself to be your best business partner as well as a good friend in every aspect of your PCB needs.&lt;/i&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Cloning Qt&#39;s MQTT Library&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;If we do a simple google search with the keyword &quot;Qt MQTT Repository&quot; we will land on the following link. &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://code.qt.io/cgit/qt/qtmqtt.git/&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;https://code.qt.io/cgit/qt/qtmqtt.git/&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And on this page, we can see various development branches, and now as a first step we have to clone the repository based on the Qt installed on our laptop, in my case the Qt version installed is &quot;6.2.4&quot;, hence I will clone the same branch from the above page, and the command to do this is given below.&lt;/span&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;git clone -b 6.2.4 git://code.qt.io/qt/qtmqtt.git&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In the above command &quot;6.2.4&quot; is the Qt version, you have to replace it with the version which is installed on your computer.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The above command will clone the Qt MQTT Source Code on our computer and the next step is to compile the source code to generate the Qt MQTT Library.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;h3 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Compiling the Qt MQTT Source&lt;/span&gt;&lt;/h3&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Compiling the source files to generate the library is the most important step. Sin&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;ce we will be compiling the Qt MQTT Source files from the command line terminal hence it is desirable&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;to have proper environment variables set while building Qt projects from the command line.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here we will make a script file on our computer with all the relevant environment variables, and let&#39;s name this file &quot;&lt;i&gt;Qt_Environment.s&lt;/i&gt;h&quot;, and the content of this file is shown below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;export&lt;/span&gt; QT_VERSION=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;6.2.4&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;export&lt;/span&gt; QT_INSTALL_DIR=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;/opt/Qt&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;export&lt;/span&gt; CMAKE_BIN_DIR=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;${QT_INSTALL_DIR}/Tools/CMake/bin&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;export&lt;/span&gt; QMAKE_BIN_DIR=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64/bin&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;export&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;CMAKE_PREFIX_PATH&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64/&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;export&lt;/span&gt; NINJA_DIR=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;${QT_INSTALL_DIR}/Tools/Ninja&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;export&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;PATH&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;${PATH}:${CMAKE_BIN_DIR}:${QMAKE_BIN_DIR}:${NINJA_DIR}&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Update &quot;&lt;i&gt;QT_VERSION&lt;/i&gt;&quot; and &quot;&lt;i&gt;QT_INSTALL_DIR&lt;/i&gt;&quot; as per your computer installation, in my case the Qt is installed inside the &quot;opt&quot; folder and its version is &quot;6.2.4&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red; font-family: verdana;&quot;&gt;Note: Make Sure there are no spaces in the above file else it will not work and gives you a lot of errors.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now, the next step is to load these environment variables, and this can be done with the help of the below command.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;source QT_Environment.sh&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This above command will load the environment variables for only one session of the terminal, and if the terminal is closed, we need to execute the same command again. But in case you wanted to avoid this step, you can load this script at power-up, but for me this is fine, so I will not do this.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The next step is to generate the build environment, build the source files and install the library, and all this can be done using the below mentioned commands.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;cd&lt;/span&gt; qtmqtt&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;mkdir&lt;/span&gt; build&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;cd&lt;/span&gt; build&lt;/div&gt;&lt;div&gt;/opt/Qt/6.2.4/gcc_64/bin/qt-configure-module ..&lt;/div&gt;&lt;div&gt;/opt/Qt/Tools/CMake/bin/cmake --build .&lt;/div&gt;&lt;div&gt;/opt/Qt/Tools/CMake/bin/cmake --install . --verbose&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The first command is &quot;cd qtmqtt&quot;, here &quot;qtmqtt&quot; is the name of the directory where we cloned the repository, if your directory name is different, please use that, the main idea is to just go inside this directory.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The second command is &quot;mkdir build&quot;, the purpose of this command is to create a directory named &quot;build&quot;, which contains all the build-related information.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The third command is &quot;cd build&quot;, the purpose of this command is to go inside the empty directory build, and from here we will run our main commands.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The fourth command is &quot;/opt/Qt/6.2.4/gcc_64/bin/qt-configure-module ..&quot;, this command will change according to your Qt installation path, this command will basically generate the build environment, you can always check in the directory explorer where your &quot;qt-configure-module&quot; is present, and update this command accordingly.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The fifth command is &quot;/opt/Qt/Tools/CMake/bin/cmake --build .&quot;, this command will build the project and generate the Qt MQTT library.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And then the sixth and last step is to install the Qt MQTT Library, and this can be done by using the command &quot;/opt/Qt/Tools/CMake/bin/cmake --install . --verbose&quot;, this command will install the Qt MQTT library and then it can be accessed directly from the Qt Creator. Sometimes this command can give error, if your Qt is installed in some special location, like in my case it is installed inside the &quot;/opt/&quot; folder, and in this case we have to execute this command as &quot;sudo&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now, the library is installed the next step is to test the library.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Testing Qt MQTT Project&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The repository which we have cloned contains several example projects and we will use one of these projects to test the Qt MQTT&#39;s library.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjAxFBodg3oBHgolKC5TP_0qC_GRSfjNbIPM87ODTKoLAGmox6pzYrb3yZRpQXlmftKSbolvP55vau28q4a92TsIkm5Wa5vYp9YF8K5w9RIQ8dMU0qC1z7GfhQc_kBCQ9Jnk0sLLmqfw1wkXCRHEjWQaQ-6kKa606irm48GUwAxfoi2lrBL4RcpbC867Q&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;369&quot; data-original-width=&quot;798&quot; height=&quot;185&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjAxFBodg3oBHgolKC5TP_0qC_GRSfjNbIPM87ODTKoLAGmox6pzYrb3yZRpQXlmftKSbolvP55vau28q4a92TsIkm5Wa5vYp9YF8K5w9RIQ8dMU0qC1z7GfhQc_kBCQ9Jnk0sLLmqfw1wkXCRHEjWQaQ-6kKa606irm48GUwAxfoi2lrBL4RcpbC867Q=w400-h185&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Qt MQTT Example Projects&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;I will be using the &quot;simple client&quot; project from these example projects. The following is the user interface of this project.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEigvPU34AlPksduLDSywUeJkqHCDwV01NxH1Z405IOS7iGZ9vZ3JtZ8lSEZYqQD9qPajuohrenP4X9DTzSOyaO6D8fJGzlSYbwzt67yBCW-q7a5F15cAm5QY68hriIpitvYoJ5CUjczmnQ5b7Kpy1h57MA9T4tHhRckd1ZrS4i5jeXPDJyBIS9pv6-lGw&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;817&quot; data-original-width=&quot;1038&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEigvPU34AlPksduLDSywUeJkqHCDwV01NxH1Z405IOS7iGZ9vZ3JtZ8lSEZYqQD9qPajuohrenP4X9DTzSOyaO6D8fJGzlSYbwzt67yBCW-q7a5F15cAm5QY68hriIpitvYoJ5CUjczmnQ5b7Kpy1h57MA9T4tHhRckd1ZrS4i5jeXPDJyBIS9pv6-lGw&quot; width=&quot;305&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Simple Client Qt MQTT project&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;As can be seen in the above image, we can specify the Host Name, Port, Topic, and Message, and then there are Connect, Publish and Subscribe buttons.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In my case, I am running an MQTT broker on my local machine, and hence in Host Name I have specified &quot;localhost&quot;, and in the port name, I have specified 1883.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following animation file will show how it works, whenever publish button is pressed, the topic message is received on the terminal which is subscribing to the topic.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBU83AzLHKC8FQ1dvROrKBZOjuwP_JeLga8crQ1Hxt0zSeEVTMQ9M8LgRFJA90qLENUiGYM6RqPDwN0XKPQNqYOr_tc_C99FeOPCp0_YVdQ39HfBZzd3LDG_O01B7AUHskDlmPVeyhbLEgkAn-_MGMXHfNPQagBO0B7xvZ58eTCFS_wWy1rcA4ktFwqw/s1920/GIF.gif&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBU83AzLHKC8FQ1dvROrKBZOjuwP_JeLga8crQ1Hxt0zSeEVTMQ9M8LgRFJA90qLENUiGYM6RqPDwN0XKPQNqYOr_tc_C99FeOPCp0_YVdQ39HfBZzd3LDG_O01B7AUHskDlmPVeyhbLEgkAn-_MGMXHfNPQagBO0B7xvZ58eTCFS_wWy1rcA4ktFwqw/w400-h225/GIF.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Project Demo&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;That&#39;s all from this tutorial, the reason why I created this post is that in the future I am working on a simple project where we can control the devices and get the status of some sensors using ESP32, and all this is done using the &quot;MQTT&quot; protocol, and this all is done using the Android application, and to develop that Android application, I will be using the Qt, hence this is needed to get started.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;NOTE:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I did the same thing under Windows, open the Qt Creator and opened the &quot;MQTT&quot; project, and compiled the project for Windows and Android. After this, I used the following command to install the library for Windows and Android, from their respective build folders.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;c:\Qt\Tools\CMake_64\bin\cmake.exe&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;--install&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;--verbose&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;For Windows, the library is installed in the proper place, but for Android, it gets installed inside the &quot;C&quot; drive and &quot;Program Files&quot; folder, and then I have to copy them manually inside the Android library folders.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I don&#39;t know why this happen, I am not an expert on CMake, in case someone knows please let me know in the comment section.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2023/01/getting-started-with-mqtt-using-qt.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/DGB0GfFRqPo/default.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-3486746735822033429</guid><pubDate>Tue, 03 Jan 2023 22:05:00 +0000</pubDate><atom:updated>2023-01-23T10:35:18.630-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><title>Temperature and Humidity Graph Using ESP32 ILI9341 DHT11 and LVGL</title><description>&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this post, I will tell you, how to interface &lt;a href=&quot;https://amzn.to/3GxESf1&quot; target=&quot;_blank&quot;&gt;ILI9341 &lt;/a&gt;with &lt;a href=&quot;https://amzn.to/3Ck0El2&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;, and then I will use the &lt;a href=&quot;https://amzn.to/3VK4ASV&quot; target=&quot;_blank&quot;&gt;DHT11 &lt;/a&gt;sensor to get the temperature and humidity data and plot this data on the&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://amzn.to/3GxESf1&quot; style=&quot;font-family: verdana;&quot; target=&quot;_blank&quot;&gt;ILI9341&lt;/a&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;display, but for plotting I will be using &quot;lv_chart&quot; objects provided by LVGL, LVGL stands for Light and Versatile Embedded Graphics Library, this is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;the most popular free and open-source embedded graphics library to create beautiful UIs for any MCU, MPU and display type.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM1jTBvNdryHRmX2GI6TbTPFymskOdSkBke4zenP0kbeG2BvcPbxpl8Bo1Dyk6s2BtEsnHb4nZCqYwmIRrtOsPi0lp2j8YOG-v9txUj--GYtYNaus62q-4HrEB-6LqbK7kGqnudNw6s_TM-559TEYMS3OeBxi5Hd3TFDqCTcHG1-d4TzaH_OhNOviwLw/s2717/Graph.jpg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1369&quot; data-original-width=&quot;2717&quot; height=&quot;201&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM1jTBvNdryHRmX2GI6TbTPFymskOdSkBke4zenP0kbeG2BvcPbxpl8Bo1Dyk6s2BtEsnHb4nZCqYwmIRrtOsPi0lp2j8YOG-v9txUj--GYtYNaus62q-4HrEB-6LqbK7kGqnudNw6s_TM-559TEYMS3OeBxi5Hd3TFDqCTcHG1-d4TzaH_OhNOviwLw/w400-h201/Graph.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Temperature and Humidity Graph using ESP32 and ILI9341&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/RNACmN4dKWg&quot; width=&quot;320&quot; youtube-src-id=&quot;RNACmN4dKWg&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In one of my previous posts, I showed you guys how to use &lt;/span&gt;&lt;a href=&quot;http://embeddedlaboratory.blogspot.com/2022/12/lvgl-with-stm32f4-and-stm32f7.html&quot; style=&quot;font-family: verdana;&quot; target=&quot;_blank&quot;&gt;LVGL with STM32F4 and STM32F7 Discovery Boards&lt;/a&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;, so this post is basically an extension of that post.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;We will do the same thing which we have done in the post on STM32 and LVGL integration, and if you compare both the code you can see that basically there is very less difference. So, in this project, we will do the following.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Display VIBGYOR Colors for 4 seconds&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Display Red, Green, and Blue Sliders, and by changing the value of these sliders, the rectangle color is updated&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Once all slider value reaches 255 value the software switches to the next screen.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this screen, the temperature and humidity values taken from the DHT11 sensor are plotted on the graph using the &quot;lv_chart&quot; object.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The difference between the previous post and this post is that here I will be plotting temperature and humidity data, while in the previous post, I was just plotting the temperature value.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Project Setup&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;For this project, I will be using Arduino framework for ESP32, but instead of using Arduino IDE, I will be using PlatformIO with Visual Studio Code, as it has more advantages as compared to Arduino IDE, and for me, the following are some of the main advantages.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;PlatformIO with Visual Studio Code Extension is much faster in compiling the code as compared to the Arduino IDE (I don&#39;t the exact reason, but I read somewhere that PlatformIO utilizes all cores of our processor, I don&#39;t know how true this statement is, but for me, it is absolutely much faster)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The auto-Completion feature is missing in Arduino IDE&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Libraries are added to individual projects rather than to all projects.&lt;/span&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In PlatformIO whenever we add a library it is added to only that project, and all the changes done to our project are specific to our project, while for Arduino IDE, if we have to customize something we have to do that in the libraries folder and that usually creates a mess in most of the cases, this project is also an example of this, because here also we have to modify some of the library files.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;We can see the content of the Library just inside the Visual Studio Code, which is not available on Arduino IDE&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The schematic diagram or connection diagram for this project is as below.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKF_-fNiEruOkIqsi7RDKBetXslFmjaq-OsMxaN_phbTfW_1EEqQe4BI5YQ87LMC5AZqWLPamLo_u35q1TGmBnxClRn9TRP2v3T4AkA33hUChSke4wf0prJ6nQRzqmUEnqKh-AVWLeao4038bJKCOAy3D6VQ97J-XgawfCJvg-xbcB7ArAh8kIugfAqA/s1626/DHT11_ILI9341_SPI_ESP32_Schematic.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1023&quot; data-original-width=&quot;1626&quot; height=&quot;251&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKF_-fNiEruOkIqsi7RDKBetXslFmjaq-OsMxaN_phbTfW_1EEqQe4BI5YQ87LMC5AZqWLPamLo_u35q1TGmBnxClRn9TRP2v3T4AkA33hUChSke4wf0prJ6nQRzqmUEnqKh-AVWLeao4038bJKCOAy3D6VQ97J-XgawfCJvg-xbcB7ArAh8kIugfAqA/w400-h251/DHT11_ILI9341_SPI_ESP32_Schematic.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Connection Diagram&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;From the above picture, the pinout is not visible properly, so you use the below-mentioned table for the connections.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn9db8dOBZDuaauIGv95_H3cDTtJK7tDucgiUPRWNfa6hokAVeY-o7UZZdG06jTStpT7mW0grwET1pu8f9T6bNiDywEwzoJUIppXdvGLQQ7BZdQTR5D-dsjvmS2nCG0bR-RxfZm480Xt-4GyRNWjcAbwzgdASHHowl7DONiV6HMAb44JuLqXUs7YcjwA/s594/ESP32_ILI9341_Touch_SPI_PinOut.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;411&quot; data-original-width=&quot;594&quot; height=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn9db8dOBZDuaauIGv95_H3cDTtJK7tDucgiUPRWNfa6hokAVeY-o7UZZdG06jTStpT7mW0grwET1pu8f9T6bNiDywEwzoJUIppXdvGLQQ7BZdQTR5D-dsjvmS2nCG0bR-RxfZm480Xt-4GyRNWjcAbwzgdASHHowl7DONiV6HMAb44JuLqXUs7YcjwA/w400-h276/ESP32_ILI9341_Touch_SPI_PinOut.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ESP32 ILI9341 DHT11 Pin Out&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;After doing this, we have to install three libraries, one is for the DHT11 sensor, the second is for SPI communication and the other one is the LVGL library, this can be done by going into the PlatformIO libraries section.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Install DHT11 Sensor Library.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEibCYOMw5QC6QPe0eKfyAEHyXAa3WOTgapkU6W4fXTJjl1-dzKPtJGbX4lgWveS9TTnFcjlTEww7EJckK_AmpCFcq3T40ZBua9ZUIJmx_80D-R0wUpdiSPWn0lKD26SCCTHgJvIO5PxINYx_VIKn7iKzyC02Kp7loXHCgTrOammdM76qoU1kmhYN-xacQ&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;544&quot; data-original-width=&quot;858&quot; height=&quot;254&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEibCYOMw5QC6QPe0eKfyAEHyXAa3WOTgapkU6W4fXTJjl1-dzKPtJGbX4lgWveS9TTnFcjlTEww7EJckK_AmpCFcq3T40ZBua9ZUIJmx_80D-R0wUpdiSPWn0lKD26SCCTHgJvIO5PxINYx_VIKn7iKzyC02Kp7loXHCgTrOammdM76qoU1kmhYN-xacQ=w400-h254&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Installing DHT11 Sensor Library&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Install the TFT_eSPI library by Bodmer.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEje94ARq9s-IlXRXkFT4s3M2lBpauqtIUQYDe-aY0zkWuMclw39ePnlU9vii_ySZ8nOqQlrFV46ZA-DoCju7mX9-Tf71FFdJR3m5xVpOQArczNQ2Lbw-ZDXcCBneM4lOKDp8nprsPVtisEHJfo0x8_C9fC5qnqo7z2z-4GUAGqj41TxA7iwmLjQuN2HXg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;446&quot; data-original-width=&quot;679&quot; height=&quot;263&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEje94ARq9s-IlXRXkFT4s3M2lBpauqtIUQYDe-aY0zkWuMclw39ePnlU9vii_ySZ8nOqQlrFV46ZA-DoCju7mX9-Tf71FFdJR3m5xVpOQArczNQ2Lbw-ZDXcCBneM4lOKDp8nprsPVtisEHJfo0x8_C9fC5qnqo7z2z-4GUAGqj41TxA7iwmLjQuN2HXg=w400-h263&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Install LVGL Library by LVGL.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhb_q4WnPFIKgSVBtJThcb2l-CX1TPcpiGMVAXmHxhvNbUxd4z6nB9D5povsmn089ZiGH4o0eQuD9uB50RuD7MSYYgkg1hUPrkfMOCjUyOPhlyhawsnGItWaxugQo1CAr2R7qCL2hQjNEbIlYu76lCSPPoNYqLImzMoVdL5uafQ60Dqg5XruRT_Fgn43g&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;496&quot; data-original-width=&quot;615&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhb_q4WnPFIKgSVBtJThcb2l-CX1TPcpiGMVAXmHxhvNbUxd4z6nB9D5povsmn089ZiGH4o0eQuD9uB50RuD7MSYYgkg1hUPrkfMOCjUyOPhlyhawsnGItWaxugQo1CAr2R7qCL2hQjNEbIlYu76lCSPPoNYqLImzMoVdL5uafQ60Dqg5XruRT_Fgn43g&quot; width=&quot;298&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Install LVGL Library&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Once all three libraries are installed the &quot;platformio.ini&quot; file will look something like this.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;div&gt;[env:esp32doit-devkit-v1]&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;platform&lt;/span&gt; = espressif32&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;board&lt;/span&gt; = esp32doit-devkit-v1&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;framework&lt;/span&gt; = arduino&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;lib_deps&lt;/span&gt; = &lt;/div&gt;&lt;div&gt;&amp;nbsp; lvgl/lvgl@^8.3.4&lt;/div&gt;&lt;div&gt;&amp;nbsp; bodmer/TFT_eSPI@^2.4.79&lt;/div&gt;&lt;div&gt;&amp;nbsp; adafruit/Adafruit Unified Sensor@^1.1.7&lt;/div&gt;&lt;div&gt;&amp;nbsp; adafruit/DHT sensor library@^1.4.4&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;monitor_speed&lt;/span&gt; = 115200&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span&gt;&lt;!--more--&gt;&lt;/span&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Configuring SPI&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The &quot;TFT_eSPI&quot; library is a generic library, and we have to configure this library for our project as per the connections.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;If PlatformIO is used, then this library is present inside the &quot;*.pio&quot; folder as shown in the below image.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiCJMJv19IitGryjdzQpPywFSS42BeBjTtBigvCkquxc1YKmfsU7x2Eglr5Suusg7ztygHZgQFKFx-huJxLaCgvsEDx9ofAz39LFSaS4wepR_dL2gtLI3s4sJdxv6E2eylUtyg5mejP5CW2npDpunEd-j3XxR0kigrWvNHg-2o3AnpqTMCqWjACV6l62w&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;808&quot; data-original-width=&quot;819&quot; height=&quot;395&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiCJMJv19IitGryjdzQpPywFSS42BeBjTtBigvCkquxc1YKmfsU7x2Eglr5Suusg7ztygHZgQFKFx-huJxLaCgvsEDx9ofAz39LFSaS4wepR_dL2gtLI3s4sJdxv6E2eylUtyg5mejP5CW2npDpunEd-j3XxR0kigrWvNHg-2o3AnpqTMCqWjACV6l62w=w400-h395&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;TFT_eSPI Library with PlatformIO&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;And if Arduino IDE is used then this library is usually installed under the &quot;Arduino\libraries\TFT_eSPI&quot; path, as shown in the below image.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjPHhYVFyWjcxUMh-eB_l5GfJ3tI2ksfsVP_voS8gAENEMpsn3gnCTwJ4CZqn_c2Lqr4Rg7Y4W4a8a1o1O-SjLct-ixyBT0hPm38g_cK5Rrdf1B6xvm2hubksxWq1pfEOc5yjKColP-7r7R3RCEnAC3o58EbwtNsDDVELWE_9iyhebf2SoB91G2cXQpwA&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;559&quot; data-original-width=&quot;790&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjPHhYVFyWjcxUMh-eB_l5GfJ3tI2ksfsVP_voS8gAENEMpsn3gnCTwJ4CZqn_c2Lqr4Rg7Y4W4a8a1o1O-SjLct-ixyBT0hPm38g_cK5Rrdf1B6xvm2hubksxWq1pfEOc5yjKColP-7r7R3RCEnAC3o58EbwtNsDDVELWE_9iyhebf2SoB91G2cXQpwA=w400-h283&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;TFT_eSPI Library with Arduino IDE&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;In both cases, we have to modify the &quot;User_Setup.h&quot; file, as shown below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;First select the correct driver, in my case it is &quot;ILI9341_DRIVER&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// Only define one driver, the other ones must be commented out&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;ILI9341_DRIVER&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Generic driver for common displays&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//#define ILI9341_2_DRIVER &amp;nbsp; &amp;nbsp; // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//#define ST7735_DRIVER &amp;nbsp; &amp;nbsp; &amp;nbsp;// Define additional parameters below for this display&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//#define ILI9163_DRIVER &amp;nbsp; &amp;nbsp; // Define additional parameters below for this display&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//#define S6D02A1_DRIVER&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The second step is to configure the SPI pins, as shown below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;TFT_MISO&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;19&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;TFT_MOSI&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;23&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;TFT_SCLK&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;18&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;TFT_CS&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;// Chip select control pin&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;TFT_DC&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;// Data Command control pin&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//#define TFT_RST &amp;nbsp; 4 &amp;nbsp;// Reset pin (could connect to RST pin)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;TFT_RST&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp;// Set TFT_RST to -1 if display RESET is connected to ESP32 board RST&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;If on the hardware, if you have connected the &quot;TFT_RST&quot; with some ESP32 pin, then specify that pin here, else specify &quot;-1&quot; as I have done in my case.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The next step is to specify the Touch Chip Select pin, which in my case is &quot;2&quot; pin.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;TOUCH_CS&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; // Chip select pin (T_CS) of touch screen&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Note: You can change &quot;TFT_CS&quot; which is the chip select pin, &quot;TFT_DC&quot; pin which is TFT Data or Command Mode control signal pin, &quot;TFT_RST&quot; pin which is the reset pin, and &quot;TOUCH_CS&quot; which is Touch Chip Select Pin, but for SPI pins always select the pins specified here.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Make sure this piece of code is also like this.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LOAD_GLCD&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LOAD_FONT2&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;// Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LOAD_FONT4&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;// Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LOAD_FONT6&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;// Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LOAD_FONT7&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;// Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LOAD_FONT8&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;// Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LOAD_GFXFF&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;// FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;line-height: 22px;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// this will save ~20kbytes of FLASH&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;SMOOTH_FONT&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And then configure the SPI Frequency to be used, for TFT I am using 40MHz, for Reading 20MHz and for Touch 25MHz, as shown below.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// Define the SPI clock frequency, this affects the graphics rendering speed. Too&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// fast and the TFT driver will not keep up and display corruption appears.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// With an ILI9341 display 40MHz works OK, 80MHz sometimes fails&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// With a ST7735 display more than 27MHz may not work (spurious pixels and lines)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// With an ILI9163 display 27 MHz works OK.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// #define SPI_FREQUENCY &amp;nbsp; 1000000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// #define SPI_FREQUENCY &amp;nbsp; 5000000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// #define SPI_FREQUENCY &amp;nbsp;10000000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// #define SPI_FREQUENCY &amp;nbsp;20000000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// #define SPI_FREQUENCY &amp;nbsp;27000000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;SPI_FREQUENCY&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;40000000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// #define SPI_FREQUENCY &amp;nbsp;55000000 // STM32 SPI1 only (SPI2 maximum is 27MHz)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// #define SPI_FREQUENCY &amp;nbsp;80000000&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// Optional reduced SPI frequency for reading TFT&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;SPI_READ_FREQUENCY&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;20000000&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;SPI_TOUCH_FREQUENCY&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;2500000&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Calibrating Touch&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Once the above step is done, the next step is to get the calibration data for the Touch Screen, which can be get easily by using the Example Sketch. The path of this example sketch is as follows.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;Examples\TFT_eSPI\Generic\Touch_calibrate&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And the touch calibration project is as below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; Sketch to generate the setup() calibration values, these are reported&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; to the Serial Monitor.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; The sketch has been tested on the ESP8266 and screen with XPT2046 driver.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178; font-size: x-small;&quot;&gt;&amp;lt;SPI.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178; font-size: x-small;&quot;&gt;&amp;lt;TFT_eSPI.h&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// Hardware-specific library&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0; font-size: x-small;&quot;&gt;TFT_eSPI&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;TFT_eSPI&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt; // Invoke custom library&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;setup&lt;/span&gt;() {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Use serial port&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;115200&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Initialise the TFT screen&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;init&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Set the rotation to the orientation you wish to use in your project before calibration&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // (the touch coordinates returned then correspond to that rotation only)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setRotation&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Calibrate the touch screen and retrieve the scaling factors&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;touch_calibrate&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Replace above line with the code sent to Serial Monitor&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // once calibration is complete, e.g.:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; uint16_t calData[5] = { 286, 3534, 283, 3600, 6 };&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; tft.setTouch(calData);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Clear the screen&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;fillScreen&lt;/span&gt;(TFT_BLACK);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;drawCentreString&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Touch screen to test!&quot;&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;width&lt;/span&gt;()/&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;height&lt;/span&gt;()/&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;loop&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt; // To store the touch coordinates&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Pressed will be set true is there is a valid touch on the screen&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;pressed&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getTouch&lt;/span&gt;(&amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Draw a white spot at the detected coordinates&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pressed&lt;/span&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;fillCircle&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;, TFT_WHITE);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; //Serial.print(&quot;x,y = &quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; //Serial.print(x);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; //Serial.print(&quot;,&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; //Serial.println(y);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;//------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;// Code to run a screen calibration, not needed when calibration values set in setup()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;touch_calibrate&lt;/span&gt;()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;calData&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;calDataOK&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Calibrate&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;fillScreen&lt;/span&gt;(TFT_BLACK);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setCursor&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setTextFont&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setTextSize&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setTextColor&lt;/span&gt;(TFT_WHITE, TFT_BLACK);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Touch corners as indicated&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setTextFont&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;calibrateTouch&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;calData&lt;/span&gt;, TFT_MAGENTA, TFT_BLACK, &lt;span style=&quot;color: #b5cea8;&quot;&gt;15&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(); &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;// Use this calibration code in setup():&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp;uint16_t calData[5] = &quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;{ &quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;calData&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;]);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;) &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;, &quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; };&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp;tft.setTouch(calData);&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(); &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Serial&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;fillScreen&lt;/span&gt;(TFT_BLACK);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setTextColor&lt;/span&gt;(TFT_GREEN, TFT_BLACK);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Calibration complete!&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tft&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Calibration code sent to Serial port.&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;delay&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;4000&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Once you run this project, after following all the instructions you will get something like this on Serial Terminal.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // Replace above line with the code sent to Serial Monitor&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; // once calibration is complete, e.g.:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; uint16_t calData[5] = { 286, 3534, 283, 3600, 6 };&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; tft.setTouch(calData);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;These are the calibration values and we have to use these calibration values in our project, or else touch might not work properly.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Configuring LVGL&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The LVGL is a generic library that can be used with any display, with just some basic configuration.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;If PlatformIO is used the library is present inside the &quot;.pio&quot; folder with the name &quot;lvgl&quot; as shown below.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEirWIzxZowb3wptT1H5V-c0IQEJ1as0n-UP_0voqlBQYAQ6RhX4saftz5dRLR1Z2HBj4anm4PklZifYmEf7QuylJGNgb2IuSioJiZNC8M7JDc8FCjjCfMXnWng_6CNuPjG3R2EpgUx909dWJnPieTFkZRnYPazddyDoF8Q7mQ_fRCx49696pIe8Q4mFvg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;788&quot; data-original-width=&quot;782&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEirWIzxZowb3wptT1H5V-c0IQEJ1as0n-UP_0voqlBQYAQ6RhX4saftz5dRLR1Z2HBj4anm4PklZifYmEf7QuylJGNgb2IuSioJiZNC8M7JDc8FCjjCfMXnWng_6CNuPjG3R2EpgUx909dWJnPieTFkZRnYPazddyDoF8Q7mQ_fRCx49696pIe8Q4mFvg=w397-h400&quot; width=&quot;397&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;LVGL Library with PlatformIO&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here there is a file &quot;lv_conf_template.h&quot;, we have to copy this file outside the &quot;lvgl&quot; folder and rename this file to &quot;lv_conf.h&quot;.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And we have to enable the code/configuration present inside this file to 1, from 0, as shown below.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#if&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; /*Set it to &quot;1&quot; to enable content*/&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#ifndef&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; LV_CONF_H&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_CONF_H&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178; font-size: x-small;&quot;&gt;&amp;lt;stdint.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The next, step is to make sure that the color dept is 16, for RGB565 color format, and SWAP is set &quot;0&quot;, as shown below.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_COLOR_DEPTH&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;16&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_COLOR_16_SWAP&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*Enable features to draw on transparent background.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp;*It&#39;s required if opa, and transform_* style properties are used.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp;*Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_COLOR_SCREEN_TRANSP&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp;* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_COLOR_MIX_ROUND_OFS&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*Images pixels with this color will not be drawn if they are chroma keyed)*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_COLOR_CHROMA_KEY&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa; font-size: x-small;&quot;&gt;lv_color_hex&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0x00ff00&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /*pure green*/&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Then we can configure the memory allocated to lvgl, which should be greater than 2 kilobytes as shown below it is set to 48 kilobytes.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_MEM_CUSTOM&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#if&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_MEM_CUSTOM&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;==&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; /*Size of the memory available for `lv_mem_alloc()` in bytes (&amp;gt;= 2kB)*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_MEM_SIZE&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; (48U * 1024U)&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*[bytes]*/&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_MEM_ADR&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; /*0: unused*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;#if&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;LV_MEM_ADR&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;==&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#undef&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; LV_MEM_POOL_INCLUDE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#undef&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; LV_MEM_POOL_ALLOC&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; #endif&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#else&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; /*LV_MEM_CUSTOM*/&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Then the next step is to configure the tick source, I will set it to 1 for Arduino-based platforms as shown below. This removes the need to manually update the tick with the function call &quot;lv_tick_inc&quot;.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*Use a custom tick source that tells the elapsed time in milliseconds.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp;*It removes the need to manually update the tick with `lv_tick_inc()`)*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_TICK_CUSTOM&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#if&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_TICK_CUSTOM&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_TICK_CUSTOM_INCLUDE&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178; font-size: x-small;&quot;&gt;&quot;Arduino.h&quot;&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /*Header for the system time function*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_TICK_CUSTOM_SYS_TIME_EXPR&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa; font-size: x-small;&quot;&gt;millis&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp;/*Expression evaluating to current system time in ms*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#endif&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp; /*LV_TICK_CUSTOM*/&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This step is optional, by setting LV_USE_LOG, we can log different types of the log messages, at the moment I have set it to &quot;LV_LOG_LEVEL_WARN&quot;.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_USE_LOG&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#if&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_USE_LOG&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; /*How important log should be added:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; *LV_LOG_LEVEL_TRACE &amp;nbsp; &amp;nbsp; &amp;nbsp; A lot of logs to give detailed information&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; *LV_LOG_LEVEL_INFO &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Log important events&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; *LV_LOG_LEVEL_WARN &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Log if something unwanted happened but didn&#39;t cause a problem&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; *LV_LOG_LEVEL_ERROR &amp;nbsp; &amp;nbsp; &amp;nbsp; Only critical issue, when the system may fail&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; *LV_LOG_LEVEL_USER &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Only logs added by the user&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; *LV_LOG_LEVEL_NONE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Do not log anything*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_LEVEL&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;LV_LOG_LEVEL_WARN&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; /*1: Print the log with &#39;printf&#39;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; *0: User need to register a callback with `lv_log_register_print_cb()`*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_PRINTF&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_TRACE_MEM&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_TRACE_TIMER&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_TRACE_INDEV&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_TRACE_DISP_REFR&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_TRACE_EVENT&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_TRACE_OBJ_CREATE&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_TRACE_LAYOUT&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_LOG_TRACE_ANIM&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#endif&lt;/span&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt; &amp;nbsp;/*LV_USE_LOG*/&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And finally, we can enable and disable the fonts as shown below, I have enabled MONTSERRAT_12, 14, and 16 fonts. Again this is an optional step.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;/*Montserrat fonts with ASCII range and some symbols using bpp = 4&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955; font-size: x-small;&quot;&gt;&amp;nbsp;*https://fonts.google.com/specimen/Montserrat*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_8&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_10&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_12&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_14&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_16&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_18&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_20&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_22&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_24&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_26&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_28&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_30&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_32&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_34&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_36&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_38&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_40&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_42&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_44&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_46&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-size: x-small;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt;LV_FONT_MONTSERRAT_48&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Final Step&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/ESP32/tree/master/Temperature_Humidity_Graph/src&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Get the Source Code from the GitHub&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I have shown the important and tricky configuration steps, and the rest of the part is really simple just copy and paste after running the above code from GitHub you will see the following screens on the display.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgWvyWm0uQdk-65p3bhioLzuzt5-l8Sd1AVwrvjzxXmw2wUocUustd6TZAd0JlYiYIJKIwGe5b8CiX_M8-brURwR5N1Zu5lPdOAorS4XPc2S5IteBN7BsVXdJC-7BhDrRJEYkKgy4MWxjtCuYVzd6W9NJKbtFb_DgdEKWGEDGaUhqzpH9q2kOMlg5e-TQ&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;692&quot; data-original-width=&quot;1323&quot; height=&quot;209&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgWvyWm0uQdk-65p3bhioLzuzt5-l8Sd1AVwrvjzxXmw2wUocUustd6TZAd0JlYiYIJKIwGe5b8CiX_M8-brURwR5N1Zu5lPdOAorS4XPc2S5IteBN7BsVXdJC-7BhDrRJEYkKgy4MWxjtCuYVzd6W9NJKbtFb_DgdEKWGEDGaUhqzpH9q2kOMlg5e-TQ=w400-h209&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;VIBGYOR Display for 4 seconds&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgQzLtfuov8ZzDGNhREsb36OxpDIHAvbl2xCDMlDulggywiwpHoST2NVNvoBIHcSxhpYJ6r-0y9tj3SntNhbVHq17Xk61JEb6O2BepMU7unpH3S5xNFDHrCsmwUyJgPpuRIfgAK9Or8HR4HwMMAzWhoFli_3ZCr2rFFFmODfTkxet8wYNkXvVlbqeKZkg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;673&quot; data-original-width=&quot;1258&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgQzLtfuov8ZzDGNhREsb36OxpDIHAvbl2xCDMlDulggywiwpHoST2NVNvoBIHcSxhpYJ6r-0y9tj3SntNhbVHq17Xk61JEb6O2BepMU7unpH3S5xNFDHrCsmwUyJgPpuRIfgAK9Or8HR4HwMMAzWhoFli_3ZCr2rFFFmODfTkxet8wYNkXvVlbqeKZkg=w400-h214&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;RGB Mixer&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjAlAeQHMwrL9Ld9lDAQ6uCO06ntbeID-9P8gkbpgX_70aKzKbmmmjskbS5XmNbdUiPbeZU23RvZgdqVNfeXxlEMLOcNno2xWJKkgGy3FjUZiYDzLQqnCRjyEcqt0C9QM7VcMDwY2R2lKg4sF4HC_5hhXMPZyeidNYGI4PWTDLT-Ow1bv3_EgXi3slhiQ&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;639&quot; data-original-width=&quot;1243&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjAlAeQHMwrL9Ld9lDAQ6uCO06ntbeID-9P8gkbpgX_70aKzKbmmmjskbS5XmNbdUiPbeZU23RvZgdqVNfeXxlEMLOcNno2xWJKkgGy3FjUZiYDzLQqnCRjyEcqt0C9QM7VcMDwY2R2lKg4sF4HC_5hhXMPZyeidNYGI4PWTDLT-Ow1bv3_EgXi3slhiQ=w400-h206&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;RGB Mixer&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh-nbQX9w-faX1FPmnrZ7DUo-WJerDJQBYzKC5zDQWhk_Qx2YfQhPIT7x1luDkjxxM-pONLLqKYZqxmoMb_QgFYtxRnMDM-P3eHwr70c69ThBXYb7IVchcyW_5czEJLX6aVRxpZkkpeyL5T3A1WejZq_wUaf4ABqrKDKV9YVM7gVFKw2Cz18cvPBf_T1w&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;783&quot; data-original-width=&quot;1516&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh-nbQX9w-faX1FPmnrZ7DUo-WJerDJQBYzKC5zDQWhk_Qx2YfQhPIT7x1luDkjxxM-pONLLqKYZqxmoMb_QgFYtxRnMDM-P3eHwr70c69ThBXYb7IVchcyW_5czEJLX6aVRxpZkkpeyL5T3A1WejZq_wUaf4ABqrKDKV9YVM7gVFKw2Cz18cvPBf_T1w=w400-h206&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Temperature and Humidity Graph&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;</description><link>http://embeddedlaboratory.blogspot.com/2023/01/temperature-and-humidity-graph-using.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM1jTBvNdryHRmX2GI6TbTPFymskOdSkBke4zenP0kbeG2BvcPbxpl8Bo1Dyk6s2BtEsnHb4nZCqYwmIRrtOsPi0lp2j8YOG-v9txUj--GYtYNaus62q-4HrEB-6LqbK7kGqnudNw6s_TM-559TEYMS3OeBxi5Hd3TFDqCTcHG1-d4TzaH_OhNOviwLw/s72-w400-h201-c/Graph.jpg" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-282495975855699569</guid><pubDate>Tue, 20 Dec 2022 12:28:00 +0000</pubDate><atom:updated>2022-12-30T08:48:35.294-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">IOT</category><title>Weather Monitoring Using ESP32 and InfluxDB</title><description>&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this post, I will demonstrate how we can use the &lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt; module to sense the temperature and humidity from the &lt;a href=&quot;https://amzn.to/3YzITaO&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt; sensor and send this data to the InfluxDB cloud database, and then using InfluxDB and Grafana Dashboard, we can visualize this data in the form of graphs and gauges. Below is the image of the dashboard created in InfluxDB.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Note: Grafana Dashboard post will be a separate topic else this will be a very long post.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/Support/HomeDataLogger_InfluxDB.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;450&quot; data-original-width=&quot;800&quot; height=&quot;360&quot; src=&quot;https://raw.githubusercontent.com/xpress-embedo/ESP32/master/Support/HomeDataLogger_InfluxDB.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Dashboard in InfluxDB Cloud&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;You can watch the video or read the below post.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/LatI7kNxGmc&quot; width=&quot;320&quot; youtube-src-id=&quot;LatI7kNxGmc&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Prerequisite for this Tutorial&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&amp;nbsp;Board&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://amzn.to/3YzITaO&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt;&amp;nbsp;Sensor&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Some Cables&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Note: I prefer PlatformIO with VSCode for my software development, but the same project will work on the Arduino platform also. In PlatformIO you have to click on Libraries and then search for the library and then add that library to the project, while in Arduino you have to use &quot;Library Manager&quot; and search for the library and install it. Both are really simple methods and I assume you all are very much familiar with them.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;As a first step, we will use the&amp;nbsp;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&amp;nbsp;to capture the temperature and 
humidity information from the&amp;nbsp;&lt;a href=&quot;https://amzn.to/3YzITaO&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt;&amp;nbsp;temperature sensor. Fortunately, the 
software library is already available for this purpose from Adafruit.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Install the DHT sensor library if using PlatformIO or Arduino as shown in the image below.&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrCCQJZckl7nkNIZpDWCiWwd6ayHaMHowGPsYZlP4T9fBEc-lvSDZf8KXzpG_Gl3_f7FBNblCTTwDglhGvQhx31U0H7SLAxr1tHC4ZBhC2stuuJ_Xz7eqFjaAiUJ1hUbf3ZsuQZL6XxWQ1sYr3SLYugr_rkgln6sZF-kdeEgIuaT2hIxlTw8atk2y5Dg/s1189/Install_DHT11_Library_PlatformIO.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;662&quot; data-original-width=&quot;1189&quot; height=&quot;223&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrCCQJZckl7nkNIZpDWCiWwd6ayHaMHowGPsYZlP4T9fBEc-lvSDZf8KXzpG_Gl3_f7FBNblCTTwDglhGvQhx31U0H7SLAxr1tHC4ZBhC2stuuJ_Xz7eqFjaAiUJ1hUbf3ZsuQZL6XxWQ1sYr3SLYugr_rkgln6sZF-kdeEgIuaT2hIxlTw8atk2y5Dg/w400-h223/Install_DHT11_Library_PlatformIO.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Install Adafruit DHT Sensor Library for PlatformIO&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVCdtY2Am0DGTQN_tWFm6wtqkscycvPwf1hTt6Y-ZdwYbSwZC04VkzRQHdavmNiDddPQ0VhznJdTcvQzH-t_TMttmGH4Dti9GBC6rr-FPk31wn4fUwM95kAOYu-how54kZ9wjNJy2NW7cb2XG0AhRXsBiOJReGwyvo_VVQjiOQjRwUppdoV2VLzwDweQ/s999/Install_DHT11_Arduino.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;695&quot; data-original-width=&quot;999&quot; height=&quot;279&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVCdtY2Am0DGTQN_tWFm6wtqkscycvPwf1hTt6Y-ZdwYbSwZC04VkzRQHdavmNiDddPQ0VhznJdTcvQzH-t_TMttmGH4Dti9GBC6rr-FPk31wn4fUwM95kAOYu-how54kZ9wjNJy2NW7cb2XG0AhRXsBiOJReGwyvo_VVQjiOQjRwUppdoV2VLzwDweQ/w400-h279/Install_DHT11_Arduino.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Install Adafruit DHT Sensor Library for Arduino&lt;/span&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Install the InfluxDB library if using PlatformIO or Arduino as shown in the image, this library has the name ESP8266 but don&#39;t worry about that, it works very well with&amp;nbsp;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&amp;nbsp;also.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwu29xsov6CN4rMrFquDmOwi8WKYtM-I2wY80eBkfDU5iSHK8biMFh5pslBih2akRsvTCKKwBkWiOpf0vsdD90X8P-1sytA138RQN9d0sWhVbCGFFpQCnPovbrJTzsLP3YLtKm2uAO6vZyJv9nXNI-85U9IxQ7LMSLmLX7GM4pqdYF8PB7sXK8SlMiMw/s1189/InstallInfluxDB_LibraryPlatformIO.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;662&quot; data-original-width=&quot;1189&quot; height=&quot;223&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwu29xsov6CN4rMrFquDmOwi8WKYtM-I2wY80eBkfDU5iSHK8biMFh5pslBih2akRsvTCKKwBkWiOpf0vsdD90X8P-1sytA138RQN9d0sWhVbCGFFpQCnPovbrJTzsLP3YLtKm2uAO6vZyJv9nXNI-85U9IxQ7LMSLmLX7GM4pqdYF8PB7sXK8SlMiMw/w400-h223/InstallInfluxDB_LibraryPlatformIO.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Install InfluxDB ESP8266 Library for PlatformIO&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdMinuoR-_yWKUJY_pVRCy9ldOFoct0CLWP5CHF_Njlck8sU6Zm8mkpBQ77jeqOIyEkfM_YauAljmwkl3vz6AV8YdvKnQxJ60Y2Mp_dUIFdqSyIyEvRyccjWlh5bCRyd0_VL7kYXsho6VBQoqobaEILEMQSgL1Y6XL2yHweIczViIv8Dcoh0Aamnrfuw/s999/InstallInfluxDB_Arduino.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;695&quot; data-original-width=&quot;999&quot; height=&quot;279&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdMinuoR-_yWKUJY_pVRCy9ldOFoct0CLWP5CHF_Njlck8sU6Zm8mkpBQ77jeqOIyEkfM_YauAljmwkl3vz6AV8YdvKnQxJ60Y2Mp_dUIFdqSyIyEvRyccjWlh5bCRyd0_VL7kYXsho6VBQoqobaEILEMQSgL1Y6XL2yHweIczViIv8Dcoh0Aamnrfuw/w400-h279/InstallInfluxDB_Arduino.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Install InfluxDB ESP8266 Library for Arduino&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;DHT11 Sensor Interfacing&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;As a first step, we will test the&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://amzn.to/3YzITaO&quot; style=&quot;font-family: verdana;&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;sensor to make sure it is working, this is basically a modular approach that helps the software development easier.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Let&#39;s start our coding, first, we need to include the DHT sensor include files in the project as shown below.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;DHT.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;DHT_U.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The next step is to select the DHT sensor type and the pin it is connected to, here it is connected to&amp;nbsp;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&amp;nbsp;pin 12, we have also created a macro &quot;DHT11_REFRESH_TIME&quot;, this macro is used to trigger the measurement from the&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://amzn.to/3YzITaO&quot; style=&quot;font-family: verdana;&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;sensor, this we will see below.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHTPIN&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;                          &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHTTYPE&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;                         &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;DHT11&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHT11_REFRESH_TIME&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;              &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;5000u&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The next step is to create the DHT sensor object and define some variables to store temperature and humidity data, another variable is created named &quot;dht_refresh_timestamp&quot;, this variable along with macro &quot;DHT11_REFRESH_TIME&quot; is used to get the temperature and humidity after every 5 seconds, which is programmed in &quot;DHT11_REFRESH_TIME&quot; macro.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_temperature&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_humidity&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;DHT&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHTPIN&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHTTYPE&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Below are the two main important functions, one is the &quot;DHT11_TaskInit&quot; function and another is the &quot;DHT11_TaskMng()&quot; function.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;DHT11_TaskInit&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This function is called inside the &quot;setup&quot; function and it basically setup the sensor pins and sets pull timings, also initializes the &quot;dht_refresh_timestamp&quot; variable with the current values millisecond value using &quot;millis()&quot; function.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;DHT11_TaskMng&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This function is called inside the &quot;loop&quot; function and it basically triggers the temperature and humidity measurements and prints the information on the serial port and also saves the data into the variables &quot;dht11_temperature&quot; and &quot;dht11_humidity&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The content of both of these functions are as below.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // delay(2000);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht_refresh_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;millis&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint32_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;millis&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht_refresh_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHT11_REFRESH_TIME&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht_refresh_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Reading temperature or humidity takes about 250 milliseconds!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Sensor readings may also be up to 2 seconds &#39;old&#39; (its a very slow sensor)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;readHumidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Read temperature as Celsius (the default)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;readTemperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Check if any reads failed and exit early (to try again).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;isnan&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;isnan&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Failed to read from DHT sensor!&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Humidity: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;%  Temperature: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;°C &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;      // store this in the global variables&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_humidity&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_temperature&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setup&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;System_Init&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;loop&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;We will test this much and if this works we will proceed further with the connection to the InfluxDB cloud server.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Creating InfluxDB Database&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;With the above piece of code, we can get the temperature and humidity data from the&amp;nbsp;&lt;a href=&quot;https://amzn.to/3YzITaO&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt;&amp;nbsp;sensor, and as a next step we have to store this data on the InfluxDB database we need an account for that, which can be created for free of cost for primary usage.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;To create a free account, register with an email id on this &lt;b&gt;&lt;a href=&quot;https://cloud2.influxdata.com/signup&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;&lt;/b&gt;. And once you are registered you have the possibility to select from the following three options.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;AWS Amazon Web Services&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Google Cloud&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Microsoft Azure&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;You can select anyone of them, and opt for &quot;Free Account&quot;, which looks like this.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl6A7tBicrd_WhAzy4uY-hReZbLJyKlGIDv3bmwvMz1RPVjWCVkzf8L2VD6wCBmIMz4__zEOy6EA_RcpS8fl_o8dOqMBJygySAYmtYVoWIbHnBzJoqf0FWUzfBouqaLAe7wdIe7Tir24QpmMc3jza5il1didtj0NFaz3s2VNfnA0tAJTJNcG3Eh-9yiQ/s1024/InfluxDB+PlanType.webp&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;538&quot; data-original-width=&quot;1024&quot; height=&quot;210&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl6A7tBicrd_WhAzy4uY-hReZbLJyKlGIDv3bmwvMz1RPVjWCVkzf8L2VD6wCBmIMz4__zEOy6EA_RcpS8fl_o8dOqMBJygySAYmtYVoWIbHnBzJoqf0FWUzfBouqaLAe7wdIe7Tir24QpmMc3jza5il1didtj0NFaz3s2VNfnA0tAJTJNcG3Eh-9yiQ/w400-h210/InfluxDB+PlanType.webp&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;InfluxDB Plan Type&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;InfluxDB Database Connection Details&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;InfluxDB has already done some work for us in interfacing Arduino-based devices, so we can take advantage of it, this is shown below where we get the option of &quot;Client Libraries&quot;, one can click on &quot;Arduino&quot; icon and follow along.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtq8p7R0MBMDPvJ-QMCVii3Wt0t-odvIrvTqTOCkKWqO1N-n5z5MKzh8J-MwvgDQDJQEgiyoB37j8Hzs8C6c-cLHHoOL7s1QEVsmrp9XUSaBst88GTJnG0ZPaSAPC1i7X6rKQ8CZ89EhF1JaXs18E3G-5v33ODL3m4hg6wvzr3kPM14hF8wimBxF4iCw/s1298/Screenshot%20from%202022-12-20%2016-34-08.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;803&quot; data-original-width=&quot;1298&quot; height=&quot;248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtq8p7R0MBMDPvJ-QMCVii3Wt0t-odvIrvTqTOCkKWqO1N-n5z5MKzh8J-MwvgDQDJQEgiyoB37j8Hzs8C6c-cLHHoOL7s1QEVsmrp9XUSaBst88GTJnG0ZPaSAPC1i7X6rKQ8CZ89EhF1JaXs18E3G-5v33ODL3m4hg6wvzr3kPM14hF8wimBxF4iCw/w400-h248/Screenshot%20from%202022-12-20%2016-34-08.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;But let&#39;s do it differently here, although it means the same thing, we need two things here, one is &quot;Bucket&quot; and the other thing is &quot;API Tokens&quot; by which the other application can access the InfluxDB database.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Click on &lt;b&gt;Generate API Token &lt;/b&gt;button to generate token.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW4feY-puiOOk4m_HU_TW7mNeq7iBkExCNbOTBXDeiqSmhl5moX7vvaT2gS6yYPE9JMkyMz2kJ2KXcHVB1sg83rmTEGCsFTJLtTkmm58uhtYn5CuMMhIYRRXeysc7e01oAB25T5ij0T3AqsrejBqIRtyBKOYAovEdLZBPN1LIdUpWuIqnoo4w-nEXdxw/s867/GenerateAPIToken.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;363&quot; data-original-width=&quot;867&quot; height=&quot;168&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW4feY-puiOOk4m_HU_TW7mNeq7iBkExCNbOTBXDeiqSmhl5moX7vvaT2gS6yYPE9JMkyMz2kJ2KXcHVB1sg83rmTEGCsFTJLtTkmm58uhtYn5CuMMhIYRRXeysc7e01oAB25T5ij0T3AqsrejBqIRtyBKOYAovEdLZBPN1LIdUpWuIqnoo4w-nEXdxw/w400-h168/GenerateAPIToken.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Generate API Token&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Click on &lt;b&gt;Create Bucket &lt;/b&gt;button to create a bucket. The purpose of bucket is to collect all data&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnPGrSfBa7aNHVozn7tBfqpAjxAhI1m91i2vQAOc3kvPgVHZigCMHskHfyMlqd_LWa7Sla66ePLY4VleEu5VsAjwqVgEcVXgq0S35U1mzXjMHkTImzKzvcHIh-x9B6oY0zKJE64ektvxIK3NBvMVzd-AaC4DQYOPHhEKqPOQw6EhGJJT5NkZdrwJZMTg/s867/CreateBucket.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;654&quot; data-original-width=&quot;867&quot; height=&quot;301&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnPGrSfBa7aNHVozn7tBfqpAjxAhI1m91i2vQAOc3kvPgVHZigCMHskHfyMlqd_LWa7Sla66ePLY4VleEu5VsAjwqVgEcVXgq0S35U1mzXjMHkTImzKzvcHIh-x9B6oY0zKJE64ektvxIK3NBvMVzd-AaC4DQYOPHhEKqPOQw6EhGJJT5NkZdrwJZMTg/w400-h301/CreateBucket.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Create Bucket&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/b&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And now next step is to update our program to connect with the InfluxDB server and send data to the InfluxDB database. And for this we will include the InfluxDB-related header files and also the WiFiMulti header file which will handle all WiFi-related operations for the&amp;nbsp;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&amp;nbsp;chip, so now our header file inclusion will look like this.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Arduino.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;WiFiMulti.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;InfluxDbClient.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;InfluxDbCloud.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;DHT.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;DHT_U.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The next step is to fill in the WiFi Router&#39;s SSID and Password information so that our&amp;nbsp;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&amp;nbsp;module can be connected to the router and the internet. &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_SSID&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;             &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Enter SSID Here&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_PASSWORD&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;         &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Enter Password Here&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;After this, we must enter the InfluxDB database-related information, as mentioned below.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_URL&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;          &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;????????????&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_TOKEN&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;????????????&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_ORG&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;          &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;????????????&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_BUCKET&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;       &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;????????????&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;All of this information we can get from the InfluxDB account, like for example we just created the &quot;Bucket&quot; and also generated the &quot;API Token&quot;, so that information needs to be entered here, similarly URL and also the organization, which is just your email id.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The next step is to set the time zone and this is done using the following statements.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here I have specified the Central European Time i.e. CET.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Set timezone string according to https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Examples:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;//  Pacific Time: &quot;PST8PDT&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;//  Eastern: &quot;EST5EDT&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;//  Japanesse: &quot;JST-9&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;//  Central Europe: &quot;CET-1CEST,M3.5.0,M10.5.0/3&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;TZ_INFO&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;CET-1CEST,M3.5.0,M10.5.0/3&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Once this is done we need to define the Device Name, and also a macro named &quot;INFLUXDB_SEND_TIME&quot; to send data periodically to InfluxDB database.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DEVICE&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;                          &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;ESP32&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_SEND_TIME&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;              &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;10000u&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;After this, I will create a WiFi object, a Point object which stores the data for the bucket, and an InfluxDB client object for connecting and sending data to the InfluxDB database, and this can be done using the following line of code.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// InfluxDB client instance with preconfigured InfluxCloud Certificate&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;InfluxDBClient&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_URL&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_ORG&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_BUCKET&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_TOKEN&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;InfluxDbCloud2CACert&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Data point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Point&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Sensor_Data&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;WiFiMulti&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;wifiMulti&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now let&#39;s start working on writing our important function, just like we did for the&amp;nbsp;&lt;a href=&quot;https://amzn.to/3YzITaO&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt;&amp;nbsp;sensor, this part also includes three important functions, first &quot;WiFi_Setup&quot;, the second one is &quot;InfluxDB_TaskInit()&quot; and the last and most important one &quot;InfluxDB_TaskMng()&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;WiFi_Setup&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This function connects the&amp;nbsp;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&amp;nbsp;with the WiFi router and connects it to the internet, here first configure the&amp;nbsp;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&amp;nbsp;in station mode and then connect it to the router, as shown below.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;WiFi_Setup&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Connect WiFi&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Connecting to WiFi&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;WiFi&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;mode&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_STA&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;wifiMulti&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addAP&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_SSID&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_PASSWORD&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;wifiMulti&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;WL_CONNECTED&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;delay&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;InfluxDB_TaskInit&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This function synchronizes time and connects with the InfluxDB database as shown with the help of the below piece of code, we also added a &quot;Tag&quot; named device, to identify that this data is coming from this device which in this case is &quot;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&quot;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;InfluxDB_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Add constant tags - only once&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addTag&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;device&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DEVICE&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Accurate time is necessary for certificate validation &amp;amp; writing in batches&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // For the fastest time sync find NTP servers in your area: &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // https://www.pool.ntp.org/zone/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Syncing progress and the time will be printed to Serial.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;timeSync&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;TZ_INFO&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;pool.ntp.org&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;time.nis.gov&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Check server connection&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;validateConnection&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Connected to InfluxDB: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getServerUrl&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;InfluxDB connection failed: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getLastErrorMessage&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;InfluxDB_TaskMng&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This
 function is the most important function and this function, and this function sends the WiFi RSSI value of the WiFi, with Temperature and Humidity data to the InfluxDb database. As shown in the below piece of source code.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This function executes every 10 seconds, but I would suggest it changed to every minute as temperature and humidity values don&#39;t change that quickly.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this function, the following things are done.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt; Clear All Fields for the Point&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Then add fields, one is RSSI, then&amp;nbsp;&lt;a href=&quot;https://amzn.to/3YzITaO&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt;&amp;nbsp;Temperature, and then&amp;nbsp;&lt;a href=&quot;https://amzn.to/3YzITaO&quot; target=&quot;_blank&quot;&gt;DHT11&lt;/a&gt;&amp;nbsp;Humidity&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Once the above step is done we send this to Serial for debugging purposes to see if everything looks fine or not.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The next step is that check if the WiFi is still connected or not.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;If connected we will write the Point data to the InfluxDB server&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;InfluxDB_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint32_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;millis&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;influxdb_send_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_SEND_TIME&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;influxdb_send_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;clearFields&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Report RSSI of currently connected network&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addField&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;rssi&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;WiFi&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;RSSI&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // add temperature and humidity values also&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addField&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_temperature&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addField&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_humidity&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Print what are we exactly writing&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Writing: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;pointToLineProtocol&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // If no Wifi signal, try to reconnect it&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;wifiMulti&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;WL_CONNECTED&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Wifi connection lost&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Write point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(!&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;writePoint&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;InfluxDB write failed: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getLastErrorMessage&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;b&gt;&lt;a auxonclick=&quot;open_links()&quot; href=&quot;https://github.com/xpress-embedo/ESP32/tree/master/02-DataLogger_InfluxDB&quot; onclick=&quot;open_links()&quot;&gt;Download the code from the GitHub Repository&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Or you can use the below-mentioned code also.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #dadada; font-family: &amp;quot;Droid Sans Mono&amp;quot;, &amp;quot;monospace&amp;quot;, monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; * Basic Write Example code for InfluxDBClient library for Arduino&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; * Data can be immediately seen in a InfluxDB &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;UI:&lt;/span&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; wifi_status measurement&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; * Enter WiFi and InfluxDB parameters below&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; *&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; * Measures signal level of the actually connected WiFi network&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; * This example supports only InfluxDB running from unsecure (http://...)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; * For secure (https://...) or Influx Cloud 2 use SecureWrite example&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt; **/&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Arduino.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;WiFiMulti.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;InfluxDbClient.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;InfluxDbCloud.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;DHT.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;DHT_U.h&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Project Macros&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_SSID&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;             &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Enter SSID Here&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_PASSWORD&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;         &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Enter Password Here&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_URL&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;          &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;????????????&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_TOKEN&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;????????????&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_ORG&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;          &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;????????????&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_BUCKET&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;       &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;????????????&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Set timezone string according to https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Examples:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;//  Pacific Time: &quot;PST8PDT&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;//  Eastern: &quot;EST5EDT&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;//  Japanesse: &quot;JST-9&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;//  Central Europe: &quot;CET-1CEST,M3.5.0,M10.5.0/3&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;TZ_INFO&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;CET-1CEST,M3.5.0,M10.5.0/3&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DEVICE&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;                          &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;ESP32&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// DHT Sensor Configuration Macros&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHTPIN&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;                          &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHTTYPE&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;                         &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;DHT11&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHT11_REFRESH_TIME&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;              &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;5000u&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_SEND_TIME&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;              &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;10000u&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Priavate Variables&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// InfluxDB client instance with preconfigured InfluxCloud Certificate&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;InfluxDBClient&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_URL&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_ORG&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_BUCKET&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_TOKEN&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;InfluxDbCloud2CACert&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Data point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Point&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Sensor_Data&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;WiFiMulti&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;wifiMulti&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_temperature&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_humidity&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;DHT&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHTPIN&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHTTYPE&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Task Time related Variables&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint32_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht_refresh_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint32_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;influxdb_send_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Private Function Prototypes&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;System_Init&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;WiFi_Setup&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;InfluxDB_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;InfluxDB_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;setup&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;System_Init&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;WiFi_Setup&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;InfluxDB_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;loop&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;InfluxDB_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;// Private Function Definitions&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;System_Init&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;115200&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // TODO: XS&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;WiFi_Setup&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Connect WiFi&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Connecting to WiFi&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;WiFi&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;mode&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_STA&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;wifiMulti&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addAP&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_SSID&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;WIFI_PASSWORD&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;wifiMulti&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;WL_CONNECTED&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;delay&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // delay(2000);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht_refresh_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;millis&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DHT11_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint32_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;millis&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht_refresh_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DHT11_REFRESH_TIME&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht_refresh_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Reading temperature or humidity takes about 250 milliseconds!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Sensor readings may also be up to 2 seconds &#39;old&#39; (its a very slow sensor)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;readHumidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Read temperature as Celsius (the default)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;readTemperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Check if any reads failed and exit early (to try again).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;isnan&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;isnan&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Failed to read from DHT sensor!&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Humidity: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;%  Temperature: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;°C &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;      // store this in the global variables&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_humidity&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_temperature&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint8_t&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;InfluxDB_TaskInit&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Add constant tags - only once&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addTag&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;device&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;DEVICE&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Accurate time is necessary for certificate validation &amp;amp; writing in batches&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // For the fastest time sync find NTP servers in your area: &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // https://www.pool.ntp.org/zone/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Syncing progress and the time will be printed to Serial.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;timeSync&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;TZ_INFO&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;pool.ntp.org&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;time.nis.gov&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;  // Check server connection&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;validateConnection&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Connected to InfluxDB: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getServerUrl&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;InfluxDB connection failed: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getLastErrorMessage&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;InfluxDB_TaskMng&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;uint32_t&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;millis&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;influxdb_send_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #beb7ff;&quot;&gt;INFLUXDB_SEND_TIME&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;influxdb_send_timestamp&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Store measured value into point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;clearFields&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Report RSSI of currently connected network&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addField&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;rssi&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;WiFi&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;RSSI&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // add temperature and humidity values also&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addField&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;temperature&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_temperature&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addField&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;humidity&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;dht11_humidity&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Print what are we exactly writing&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Writing: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;pointToLineProtocol&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // If no Wifi signal, try to reconnect it&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;wifiMulti&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;WL_CONNECTED&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Wifi connection lost&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #57a64a;&quot;&gt;    // Write point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #d8a0df;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #dadada;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(!&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;writePoint&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;sensor&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;InfluxDB write failed: &lt;/span&gt;&lt;span style=&quot;color: #e8c9bb;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;Serial&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #c8c8c8;&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getLastErrorMessage&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dadada;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Visualizing Data on InfluxDB Database&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now the data is sent to the InfluxDB database, it is very easy to visualize the data, we just have to go to following the following steps as mentioned in the image.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhnsGhfLrB2RoxHefZNSvVJjrXZ9_v50-2_cY2mwGC0sEx81aeyICUItlpWtA4qWT3SG2rwm_UQbEB4fx8w63kvL-e9TsHGqSe57cUIhyaCy7bCEXsbLt_fxLwEqNQQFIK2HbntDDravtivIX7X8cmwYT0ln8QJKe6XGuOtq93bCd9QXAcP7l7D6rrEMA&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;855&quot; data-original-width=&quot;1840&quot; height=&quot;298&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhnsGhfLrB2RoxHefZNSvVJjrXZ9_v50-2_cY2mwGC0sEx81aeyICUItlpWtA4qWT3SG2rwm_UQbEB4fx8w63kvL-e9TsHGqSe57cUIhyaCy7bCEXsbLt_fxLwEqNQQFIK2HbntDDravtivIX7X8cmwYT0ln8QJKe6XGuOtq93bCd9QXAcP7l7D6rrEMA=w640-h298&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Creating Dashboard Using Data Explorer&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;i&gt;Select the Data Explorer menu available on the left-hand side.&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;Select the Bucket, which in this case is &quot;HomeBucket&quot;&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;The next step is to select the measurement, which in this case is &quot;Sensor_Data&quot;&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;The next step is to select the &quot;fields&quot; either RSSI, Humidity, or Temperature, we can select each field individually also, and place them on the Dashboard.&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;The next step is to select the &quot;device&quot; which in our case is &quot;&lt;a href=&quot;https://amzn.to/3HPGhQ4&quot; target=&quot;_blank&quot;&gt;ESP32&lt;/a&gt;&quot;&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;The next step is to select the data duration, here I have specified that I wanted to view the past 12 hours of data.&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;The next step is to select the &quot;Aggregate Function&quot; here I selected &quot;last&quot;&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;The next step is to click on the &quot;Submit&quot; button, this will generate a graph.&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;And if you like this graph, you can click on the &quot;Save As Graph&quot; button, if you want to play with some other types of graphs, then you can play around with the &quot;Customize&quot; button and &quot;Graph&quot; drop-down menu to see various options.&lt;/i&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I hope you like this post of mine, in case you have any queries or questions feel free to contact me using the comments section.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I will also update the links to the video tutorial and the link to the next related post, which displays the dashboard using Grafana.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

  
&lt;script type=&quot;text/javascript&quot;&gt;
  function open_links()
  {
    window.open(&#39;https://amzn.to/3TkjlL3&#39;);
    return true;
  }
&lt;/script&gt;</description><link>http://embeddedlaboratory.blogspot.com/2022/12/weather-monitoring-using-esp32-and.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/LatI7kNxGmc/default.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-4990127836717000117</guid><pubDate>Fri, 16 Dec 2022 13:39:00 +0000</pubDate><atom:updated>2022-12-16T05:40:48.070-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ARM</category><title>LVGL with STM32F4 and STM32F7</title><description>&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;LVGL stands for Light and Versatile Graphics Library. LVGL is an open-source graphics library providing everything we need to create an embedded GUI with easy-to-use graphical elements, beautiful visual effects, and a low-memory footprint.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this post, I will show you how to use LVGL with STM32 micro-controller in two different environments, the first example is based on the S&lt;a href=&quot;https://amzn.to/3HrpBhx&quot; target=&quot;_blank&quot;&gt;TM32F429 Discovery Board&lt;/a&gt;, and the second example is based on the &lt;a href=&quot;https://amzn.to/3Br96i1&quot; target=&quot;_blank&quot;&gt;STM32F769I Discovery board &lt;/a&gt;&lt;strike&gt;and the third example is based on the Labcenter Electronics based STM32F4 and ILI9341 Simulation.&lt;/strike&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM75cqJx06m6oW6ebtSNOsvV9aj6E4A0xZUOgwSAOaLII6_D5IOBCjyo0O8Rxh9bxAEQ-L-OqvKM4d5li4gOqcRl8qqwt3tafn7UbdxRINYUaN4tYb8Rdqzstod1ESC9VH4hhnDivLPDzqFkjNJCUktRWp1oEVbtxz0rxrnRuLmwuxx_e7ZjfsoWKDUg/s3152/STM32F7_LM35DZ.jpg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1892&quot; data-original-width=&quot;3152&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM75cqJx06m6oW6ebtSNOsvV9aj6E4A0xZUOgwSAOaLII6_D5IOBCjyo0O8Rxh9bxAEQ-L-OqvKM4d5li4gOqcRl8qqwt3tafn7UbdxRINYUaN4tYb8Rdqzstod1ESC9VH4hhnDivLPDzqFkjNJCUktRWp1oEVbtxz0rxrnRuLmwuxx_e7ZjfsoWKDUg/w400-h240/STM32F7_LM35DZ.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;STM32F7 using LVGL to display Temperature Graph&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I had a third plan also which is based on Labcenter Electronics Proteus simulation also, it is working, but it had a lot of issues, if someone wants to refer to that then they can use the project at the following location.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/STM32F4/tree/master/03-ILI9341&quot; target=&quot;_blank&quot;&gt;Proteus-Based LVGL and STM32 Project&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Some of the issues with the Proteus are as follows:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;UART with Virtual Terminal doesn&#39;t work when PLL is enabled in the clock configuration&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;SPI DMA mode crashing the Proteus Simulation&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;When using SPI 16-Bit data transfer mode, the ILI9341 display module crashes.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;SPI debugger can&#39;t use when there is a lot of data, the system hangs completely.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The simulation runs really slow, making it almost unusable.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This LVGL-based program does the following things.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;First VIBGYOR colors are displayed on display for 4 seconds.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Red-Green-Blue Color Mixer is shown on display.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The chart containing the temperature data from the &lt;a href=&quot;https://amzn.to/3hfzvbs&quot; target=&quot;_blank&quot;&gt;LM35DZ &lt;/a&gt;sensor is displayed.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;STM32F429 Discovery Board&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The STM32F429ZI Discovery board kit leverages the capabilities of the STM32F429 high-performance microcontrollers, to allow users to develop rich applications easily with advanced graphical user interfaces. This board consists of a 2.4-inch QVGA TFT LCD based on the ILI9341 display controller.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this board, the microcontroller uses the SPI module to send the commands to the display module based on the ILI9341 display controller.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgdbqWE9B7J0rCXKtXd90Lysi0NnwTXu-m9c9ZONZIFRXgI77B92BbLReKWzA5fzMnIItY-QG0CqnaybLgr9Yqi8ermchyqEdIi9oZZi812ZRm0OLq5bA-xF0YEww4LI_RqN_OKBpghjouopOB1_h3O67IWltr6tC9XXaOzBuxSJKfEC8zE9uzHyq7JEw&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;STM32F4 and ILI9341 Programming Interface&quot; data-original-height=&quot;1011&quot; data-original-width=&quot;1010&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgdbqWE9B7J0rCXKtXd90Lysi0NnwTXu-m9c9ZONZIFRXgI77B92BbLReKWzA5fzMnIItY-QG0CqnaybLgr9Yqi8ermchyqEdIi9oZZi812ZRm0OLq5bA-xF0YEww4LI_RqN_OKBpghjouopOB1_h3O67IWltr6tC9XXaOzBuxSJKfEC8zE9uzHyq7JEw=w400-h400&quot; title=&quot;STM32F4 and ILI9341 Programming Interface&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;STM32F4 and ILI9341 Programming Interface&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;This can be seen in the above programming interface image block diagram, the blue lines represent the SPI lines, where PF7 is the SPI clock and PF8 is the Data Line which can be used as MISO and MOSI also, as this is a bi-directional data line of the SPI communication (This is SPI5 and it can be used in Half-Duplex mode). In this board, the LTDC is used to send the RGB data to the ILI9341 display controller.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The goal of this post is not to tell how to configure LTDC, SPI, and External SDRAM, because the ports are easily available on GitHub.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The following is the link to the official LVGL port on GitHub for the STM32F429 Discovery Board.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://github.com/lvgl/lv_port_stm32f429_disco&quot; target=&quot;_blank&quot;&gt;LVGL Official Port for STM32F429&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;I used this port, mainly the driver&#39;s files, and created a new project using CubeMX, the benefit of CubeMX I can update the other modules whenever needed.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following is the demo of the project, I will explain the LVGL project at the bottom of this post.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/ekUZjqaVGUQ&quot; width=&quot;320&quot; youtube-src-id=&quot;ekUZjqaVGUQ&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;color: #990000; font-family: verdana;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/STM32F4/tree/master/Without_Cube/LVGL_Sample2&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;GitHub Link to the STM32F4 DISCO&amp;nbsp;&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This project is inside my STM32F4 repository, so it&#39;s better to clone the whole repository using the following commands.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;git clone https://github.com/xpress-embedo/STM32F4.git&lt;/div&gt;&lt;div&gt;cd STM32F4&lt;/div&gt;&lt;div&gt;git submodule update --init --recursive&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Then the project is available under the following path.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;STM32F4/Without_Cube/LVGL_Sample2&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;STM32F769I Discovery Board&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div&gt;This discovery board is based on the STM32F769NIH6 microcontroller which has&amp;nbsp;&lt;/div&gt;&lt;div&gt;2 Mbytes of Flash memory and 512+16+4 Kbytes of RAM, in the BGA216 package. With the onboard ST-LINK/V2-1 supporting USB and can also be used as a virtual COM port.&lt;/div&gt;&lt;div&gt;This discovery kit also has a 4&quot; capacitive touch LCD display with a MIPI® DSI connector (on STM32F769I-DISCO only).&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;The goal of this post is not to tell how to configure LTDC, MIPI DSI Internal, and External SDRAM, because the ports are easily available on GitHub.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;The following is the link to the official LVGL port on GitHub for the STM32F769 Discovery Board.&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;a href=&quot;https://github.com/lvgl/lv_port_stm32f769_disco&quot; target=&quot;_blank&quot;&gt;LVGL Official Port for STM32F769&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I used this port, mainly the driver&#39;s files, and created a new project using CubeMX, the benefit of CubeMX I can update the other modules whenever needed.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following is the demo of the project, I will explain the LVGL project at the bottom of this post.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/rmKx-_Fwu1I&quot; width=&quot;320&quot; youtube-src-id=&quot;rmKx-_Fwu1I&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;color: #990000; font-family: verdana;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/STM32F7/tree/master/LVGL_Sample2&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;GitHub Link to the STM32F769I Disco Project&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This project is inside my STM32F7 repository, so it&#39;s better to clone the whole repository using the following commands.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;&lt;div&gt;git clone https://github.com/xpress-embedo/STM32F7.git&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;cd&lt;/span&gt; STM32F7&lt;/div&gt;&lt;div&gt;git submodule update --init --recursive&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Then the project is available under the following path.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 16px; line-height: 22px; white-space: pre;&quot;&gt;STM32F7/LVGL_Sample2&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Source Code Understanding&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;As I mentioned previously also, I used references from the officially provided LVGL ports for both of these discovery boards and modified them to use the CubeMX tool which can be useful for future configurations if some other peripheral is needed.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following are some of the activity diagrams which will help in understanding the overall flow of the project.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwoyJn_d7qkB6U8AhG7RTL8EezRCfwozfHi8zUB0ziXTICKLXkwLdoBqeW_DCnDZWhA5W8TBOufKQzivrVt2uDO5qM9eqyxnxTqT0XqmVzFEi8WtS8BrapB0jUCT4HecUKI-ZonZmu7JiTx3xle_CgcXQLdqrcuH76EfWZn9Ain5_mgoOLfFziPdWnCg/s1356/Project%20Overview.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;761&quot; data-original-width=&quot;1356&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwoyJn_d7qkB6U8AhG7RTL8EezRCfwozfHi8zUB0ziXTICKLXkwLdoBqeW_DCnDZWhA5W8TBOufKQzivrVt2uDO5qM9eqyxnxTqT0XqmVzFEi8WtS8BrapB0jUCT4HecUKI-ZonZmu7JiTx3xle_CgcXQLdqrcuH76EfWZn9Ain5_mgoOLfFziPdWnCg/w640-h360/Project%20Overview.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Project Overview&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWG6IxCKjO-FKrguU6zBgPtugdFWWbn-crhx94RpzUWjAK8MtZCIPQr0LzI-Ui64X0mjgAI6KYuXLrBct4QDIeZpC9mVdPR9pick2qkmV9uFfTzwBiavCJKivQr_OQy2vPEpP2CYS2XRST4NYmOHbtf6hlTBEI5QJHsZ45NaO0yvfCCTHlR_vVgJU07Q/s827/Interrupts.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;351&quot; data-original-width=&quot;827&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWG6IxCKjO-FKrguU6zBgPtugdFWWbn-crhx94RpzUWjAK8MtZCIPQr0LzI-Ui64X0mjgAI6KYuXLrBct4QDIeZpC9mVdPR9pick2qkmV9uFfTzwBiavCJKivQr_OQy2vPEpP2CYS2XRST4NYmOHbtf6hlTBEI5QJHsZ45NaO0yvfCCTHlR_vVgJU07Q/w640-h272/Interrupts.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Project Interrupt Routines&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwUobYPQhGcEkswdVKCq9Ld5kk5K_2qtlkshNDVRvnvLfc30M5hPhTOv1EljTOGcYl5VUcBwYfVQR9sK0zoK7OWy2aUptkHbRAMsFJjYKPkQ81j-vRe8SVp4U92Xfn97X1FiIez0N58BdJ8yyCQm58IvLq8bxaX4MNX7xKovz6pTwhy7-UBcdiFUSaAw/s1236/Display%20Manager.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;651&quot; data-original-width=&quot;1236&quot; height=&quot;338&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwUobYPQhGcEkswdVKCq9Ld5kk5K_2qtlkshNDVRvnvLfc30M5hPhTOv1EljTOGcYl5VUcBwYfVQR9sK0zoK7OWy2aUptkHbRAMsFJjYKPkQ81j-vRe8SVp4U92Xfn97X1FiIez0N58BdJ8yyCQm58IvLq8bxaX4MNX7xKovz6pTwhy7-UBcdiFUSaAw/w640-h338/Display%20Manager.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Display Manager (LVGL)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In this project the main function is &quot;Display_Mng&quot;, this function calls all sub-functions which uses different-different LVGL widgets to display different display screens on the TFT. The &quot;Display_Mng&quot; function calls three important functions, and they are as below.&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Display VIBGYOR&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This function displays the VIBGYOR color on the TFT screen and is like this.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;NOTE: If you don&#39;t have STM32 Discovery Boards, then you can use LVGL Simulator also for learning and Development.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Display_Vibgyor&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_style_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_coord_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_coord_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; * V_rectangle;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; * I_rectangle;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; * B_rectangle;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; * G_rectangle;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; * Y_rectangle;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; * O_rectangle;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; * R_rectangle;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; *act_scr = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_scr_act&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Get the active screen object&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; R_rectangle = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_create&lt;/span&gt;( act_scr );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; // Create Rectangle Object&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; O_rectangle = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_create&lt;/span&gt;( act_scr );&lt;/div&gt;&lt;div&gt;&amp;nbsp; Y_rectangle = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_create&lt;/span&gt;( act_scr );&lt;/div&gt;&lt;div&gt;&amp;nbsp; G_rectangle = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_create&lt;/span&gt;( act_scr );&lt;/div&gt;&lt;div&gt;&amp;nbsp; B_rectangle = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_create&lt;/span&gt;( act_scr );&lt;/div&gt;&lt;div&gt;&amp;nbsp; I_rectangle = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_create&lt;/span&gt;( act_scr );&lt;/div&gt;&lt;div&gt;&amp;nbsp; V_rectangle = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_create&lt;/span&gt;( act_scr );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_style_init&lt;/span&gt;(&amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// set the radius to zero&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_style_set_radius&lt;/span&gt;(&amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// by default the object which we created for rectangle has some radius component&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// and it looks bad for this particular example, hence updating style for all&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// created objects&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;(R_rectangle, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;(O_rectangle, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;(Y_rectangle, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;(G_rectangle, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;(B_rectangle, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;(I_rectangle, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;(V_rectangle, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_disp_get_hor_res&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// VIBGYOR are seven colors&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_disp_get_physical_ver_res&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;)/&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;(R_rectangle, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;(R_rectangle, LV_ALIGN_TOP_LEFT, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_color&lt;/span&gt;(R_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_RED), LV_PART_MAIN );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( R_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_RED), LV_PART_MAIN );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;(O_rectangle, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_align_to(O_rectangle, R_rectangle, LV_ALIGN_BOTTOM_MID, 0, 0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;(O_rectangle, LV_ALIGN_TOP_LEFT, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_color&lt;/span&gt;(O_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_ORANGE), LV_PART_MAIN );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( O_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_ORANGE), LV_PART_MAIN );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;(Y_rectangle, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_align_to(Y_rectangle, O_rectangle, LV_ALIGN_TOP_LEFT, 0, 0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;(Y_rectangle, LV_ALIGN_TOP_LEFT, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;2u&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_color&lt;/span&gt;(Y_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_YELLOW), LV_PART_MAIN );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( Y_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_YELLOW), LV_PART_MAIN );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;(G_rectangle, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_align_to(G_rectangle, Y_rectangle, LV_ALIGN_TOP_LEFT, 0, 0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;(G_rectangle, LV_ALIGN_TOP_LEFT, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;3u&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_color&lt;/span&gt;(G_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_GREEN), LV_PART_MAIN );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( G_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_GREEN), LV_PART_MAIN );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;(B_rectangle, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_align_to(B_rectangle, G_rectangle, LV_ALIGN_TOP_LEFT, 0, 0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;(B_rectangle, LV_ALIGN_TOP_LEFT, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;4u&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_color&lt;/span&gt;(B_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_BLUE), LV_PART_MAIN );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( B_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_BLUE), LV_PART_MAIN );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;(I_rectangle, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_align_to(Y_rectangle, B_rectangle, LV_ALIGN_TOP_LEFT, 0, 0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;(I_rectangle, LV_ALIGN_TOP_LEFT, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;5u&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_color&lt;/span&gt;(I_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_INDIGO), LV_PART_MAIN );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( I_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_INDIGO), LV_PART_MAIN );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;(V_rectangle, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_align_to(V_rectangle, I_rectangle, LV_ALIGN_TOP_LEFT, 0, 0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;(V_rectangle, LV_ALIGN_TOP_LEFT, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;width&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;6u&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_color&lt;/span&gt;(V_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_DEEP_PURPLE), LV_PART_MAIN );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( V_rectangle, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_DEEP_PURPLE), LV_PART_MAIN );&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Display RGB Mixer&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This function has two main parts one is the function which displays the RGB Mixer on the TFT screen and the other is the Slider Callback function, this function is called whenever their is some changes on the slider.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Display_RGBMixer&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; *act_scr = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_scr_act&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Get the active screen object&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_clean&lt;/span&gt;( act_scr );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Clear the screen&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// intialize the styles&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_style_init&lt;/span&gt;(&amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// we have to enable other font sizes in menuconfig&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_style_set_text_font&lt;/span&gt;(&amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &amp;amp;lv_font_montserrat_32);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// RED, Green and Blue Slider Configuration&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; *slider_r = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_slider_create&lt;/span&gt;( act_scr );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; // create a red slider base object&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; *slider_g = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_slider_create&lt;/span&gt;( act_scr );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; // create a green slider base object&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; *slider_b = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_slider_create&lt;/span&gt;( act_scr );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; // create a blue slider base object&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Setting Sliders Width&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_width&lt;/span&gt;( slider_r, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_width&lt;/span&gt;( slider_g, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_width&lt;/span&gt;( slider_b, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;80&lt;/span&gt;) );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Setting Sliders Height&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_height&lt;/span&gt;( slider_r, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_height&lt;/span&gt;( slider_g, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_height&lt;/span&gt;( slider_b, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;) );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Align Sliders with Each Other&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;( slider_r, LV_ALIGN_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;20&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align_to&lt;/span&gt;( slider_g, slider_r, LV_ALIGN_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;70u&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align_to&lt;/span&gt;( slider_b, slider_g, LV_ALIGN_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;70u&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// set slider range also (by default it is 0 to 100 but we want till 255)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_slider_set_range&lt;/span&gt;( slider_r, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;255&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_slider_set_range&lt;/span&gt;( slider_g, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;255&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_slider_set_range&lt;/span&gt;( slider_b, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;255&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Coloring Sliders, Slider has three parts Main, Indicator and Knob&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// apply red color to the indicator part&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( slider_r, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_RED), LV_PART_INDICATOR );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// apply red color to the knob part&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( slider_r, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_RED), LV_PART_KNOB );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// apply green color to the indicator part&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( slider_g, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_GREEN), LV_PART_INDICATOR );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// apply green color to the knob part&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( slider_g, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_GREEN), LV_PART_KNOB );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// apply blue color to the indicator part&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( slider_b, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_BLUE), LV_PART_INDICATOR );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// apply blue color to the knob part&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( slider_b, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_BLUE), LV_PART_KNOB );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;rectangle&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_create&lt;/span&gt;(act_scr);&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Creates a base object Rectangle to display color&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;rectangle&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;93&lt;/span&gt;), &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;33&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align_to&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;rectangle&lt;/span&gt;, slider_b, LV_ALIGN_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;50u&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_color&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;rectangle&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_color_black&lt;/span&gt;(), LV_PART_MAIN );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; // add black border to rectangle&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_border_width&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;rectangle&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;, LV_PART_MAIN );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// increase the width of the border by 2px&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;rectangle&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_color_make&lt;/span&gt;( &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;), LV_PART_MAIN);&lt;span style=&quot;color: #6a9955;&quot;&gt; // all sliders are at zero, so background color should be black&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Create Main Heading Label&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; *heading = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_create&lt;/span&gt;(act_scr);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_set_text&lt;/span&gt;( heading, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;RGB Mixer&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;( heading, LV_ALIGN_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;) );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;( heading, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Creating labels for individual slider current values&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_type&lt;/span&gt; = &lt;span style=&quot;color: #4fc1ff;&quot;&gt;SLIDER_TYPE_RED&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_create&lt;/span&gt;(act_scr);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_set_text&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;0&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_align_to( red.label, slider_r, LV_ALIGN_TOP_MID, 0u, 0u ); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // this will display inside slider&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align_to&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;, slider_r, LV_ALIGN_OUT_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt; );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp;// this will display outside slider&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_type&lt;/span&gt; = &lt;span style=&quot;color: #4fc1ff;&quot;&gt;SLIDER_TYPE_GREEN&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_create&lt;/span&gt;(act_scr);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_set_text&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;0&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align_to&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;, slider_g, LV_ALIGN_OUT_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_type&lt;/span&gt; = &lt;span style=&quot;color: #4fc1ff;&quot;&gt;SLIDER_TYPE_BLUE&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_create&lt;/span&gt;(act_scr);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_set_text&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;0&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align_to&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;, slider_b, LV_ALIGN_OUT_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// add event callbacks for sliders&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_event_cb&lt;/span&gt;( slider_r, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Slider_Callback&lt;/span&gt;, LV_EVENT_VALUE_CHANGED, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_event_cb&lt;/span&gt;( slider_g, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Slider_Callback&lt;/span&gt;, LV_EVENT_VALUE_CHANGED, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_event_cb&lt;/span&gt;( slider_b, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Slider_Callback&lt;/span&gt;, LV_EVENT_VALUE_CHANGED, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And the below is the &quot;Slider_Callback&quot; function, this function updates the rectangle color based on the values of Slider.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Slider_Callback&lt;/span&gt;( &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_event_t&lt;/span&gt; *&lt;span style=&quot;color: #9cdcfe;&quot;&gt;e&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int32_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int32_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_value&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// get the object (slider) for which the we received the event&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; *slider = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_event_get_target&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;e&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// extract the object (slider) user data&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;RGB_Mixer_s&lt;/span&gt; *&lt;span style=&quot;color: #9cdcfe;&quot;&gt;user_data&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_event_get_user_data&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;e&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// get the current slider value&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_value&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_slider_get_value&lt;/span&gt;(slider);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// now we have to update the slider labels&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_set_text_fmt&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;user_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%ld&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_value&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// now we have to update the color of the rectangle object based on the current&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// selected values of the color&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;user_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_type&lt;/span&gt; == &lt;span style=&quot;color: #4fc1ff;&quot;&gt;SLIDER_TYPE_RED&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_value&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;user_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_type&lt;/span&gt; == &lt;span style=&quot;color: #4fc1ff;&quot;&gt;SLIDER_TYPE_GREEN&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_value&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;user_data&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_type&lt;/span&gt; == &lt;span style=&quot;color: #4fc1ff;&quot;&gt;SLIDER_TYPE_BLUE&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;slider_value&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// now we have the color information, update the rectangle color&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// NOTE: rectangle object must be file global else we will not be able to&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// update it from here&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_bg_color&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;rectangle&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_color_make&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt;), LV_PART_MAIN);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// the function `lv_color_make` can form colors if red, green and blue color&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// are specified&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;( (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;red&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;255&lt;/span&gt;) &amp;amp;&amp;amp; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;green&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;255&lt;/span&gt;) &amp;amp;&amp;amp; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;blue&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;255&lt;/span&gt;) )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;disp_state&lt;/span&gt; = &lt;span style=&quot;color: #4fc1ff;&quot;&gt;DISP_STATE_TEMP_SENSOR&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And the last part is displaying the Temperature data as line chart on the graph, and it&#39;s content is as below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This is main function, and there is an another function also, which is called periodically at the rate of 1 second to update the latest temperature data on the graph.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Display_TemperatureChart&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// this should match with the temperature buffer length&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart_hor_res&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;260&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart_ver_res&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_disp_get_ver_res&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;) - &lt;span style=&quot;color: #b5cea8;&quot;&gt;100&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; *data = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Display_GetTempData&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_clean&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_scr_act&lt;/span&gt;() );&lt;span style=&quot;color: #6a9955;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Clean the screen&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Create a chart object&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_create&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_scr_act&lt;/span&gt;() );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Create a label for Title text&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_obj_t&lt;/span&gt; * lbl_title = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_create&lt;/span&gt;( &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_scr_act&lt;/span&gt;() );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_label_set_text&lt;/span&gt;( lbl_title, &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Temperature Graph&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_style_text_align&lt;/span&gt;( lbl_title, LV_TEXT_ALIGN_CENTER, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;( lbl_title, LV_ALIGN_TOP_MID, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_add_style&lt;/span&gt;( lbl_title, &amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;style&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; );&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Set the chart size (Size should be set properly because we wanted to display&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// chart title and some data on y-axis also)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// display is 320x240&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_set_size&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;, (&lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_disp_get_hor_res&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;NULL&lt;/span&gt;) - &lt;span style=&quot;color: #b5cea8;&quot;&gt;100&lt;/span&gt;), &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart_ver_res&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// TODO: XS I don&#39;t want to center it, will check later&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_center( chart );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_obj_align&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;, LV_ALIGN_CENTER, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;LV_PCT&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;), &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// lv_obj_align( chart, LV_ALIGN_BOTTOM_RIGHT, 0, 0 );&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Set Chart Type to Line Chart&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_set_type&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;, LV_CHART_TYPE_LINE );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// By Default the number of points are 10, update it to chart width&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_set_point_count&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart_hor_res&lt;/span&gt; );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Update mode shift or circular, here shift is selected&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_set_update_mode&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;, LV_CHART_UPDATE_MODE_SHIFT );&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Specify Vertical Range&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_set_range&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;, LV_CHART_AXIS_PRIMARY_Y, &lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;60&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Tick Marks and Labels&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// 2nd argument is axis, 3rd argument is major tick length, 4th is minor tick length&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// 5th is number of major ticks on the axis&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// 6th is number of minor ticks between two major ticks&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// 7th is enable label drawing on major ticks&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// 8th is extra size required to draw labels and ticks&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_set_axis_tick&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;, LV_CHART_AXIS_PRIMARY_Y, &lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;50&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// Add Data Series&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp_series&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_add_series&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;, &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_palette_main&lt;/span&gt;(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;=&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart_hor_res&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;++ )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp_series&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y_points&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;] = (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_coord_t&lt;/span&gt;)*(data+&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_refresh&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;);&lt;span style=&quot;color: #6a9955;&quot;&gt; /*Required after direct set*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Below is the chart refresh function.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Display_TemperatureChartRefresh&lt;/span&gt;( &lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; )&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0u&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint8_t&lt;/span&gt; *data = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Display_GetTempData&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// this should match with the temperature buffer length&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart_hor_res&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;260&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;( &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;=&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart_hor_res&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;++ )&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp_series&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y_points&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;] = (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;lv_coord_t&lt;/span&gt;)*(data+&lt;span style=&quot;color: #9cdcfe;&quot;&gt;idx&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lv_chart_refresh&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;chart&lt;/span&gt;);&lt;span style=&quot;color: #6a9955;&quot;&gt; /*Required after direct set*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</description><link>http://embeddedlaboratory.blogspot.com/2022/12/lvgl-with-stm32f4-and-stm32f7.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM75cqJx06m6oW6ebtSNOsvV9aj6E4A0xZUOgwSAOaLII6_D5IOBCjyo0O8Rxh9bxAEQ-L-OqvKM4d5li4gOqcRl8qqwt3tafn7UbdxRINYUaN4tYb8Rdqzstod1ESC9VH4hhnDivLPDzqFkjNJCUktRWp1oEVbtxz0rxrnRuLmwuxx_e7ZjfsoWKDUg/s72-w400-h240-c/STM32F7_LM35DZ.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-2255411733360412856</guid><pubDate>Mon, 14 Nov 2022 17:38:00 +0000</pubDate><atom:updated>2022-11-14T09:53:35.904-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ARM</category><title>Fatal Simulation Error while Debugging Embedded Projects in Proteus</title><description>&lt;p&gt;&amp;nbsp;&lt;span style=&quot;font-family: verdana;&quot;&gt;Hello Everyone, in this post I would like to share a problem that I am getting when I am trying to debug my STM32 micro-controller-based project in &quot;Labcenter Electronics Proteus&quot;.&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The Proteus Design Suite is a proprietary software tool used primarily for electronic design automation. The software is used mainly by electronic design engineers and technicians to create schematics and electronic prints for manufacturing printed circuit boards.&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;So, I am using the Proteus to simulate a simple project based on an STM32F4 microcontroller, and when running the simulation it was working fine also, but when I tried to debug this project with Proteus, I get a &quot;Fatal Simulation&quot; Error message.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here by debugging I mean to say that I wanted to put breakpoints inside the code and do single-step debugging but it failed with the &quot;Fatal Simulation&quot; Error message, which is also shown in the image below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhIx9Yt-oR6MgPmYfsRlzJkDEeHt_dJzlFV35c537iB_lviNVuVrgp6sl1M1dx5ZXgokKDCVFBSOEx6h3JrrZ1drxAzamTzSSTcFQE1v_i3MWC02q8d9awwxIbcxNy81KglLfpZBvCiSQmd_vERKw1tcbJuoESZORzGsXrteP1f10XQrMUlIfpJ5mMszQ&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;752&quot; data-original-width=&quot;883&quot; height=&quot;340&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhIx9Yt-oR6MgPmYfsRlzJkDEeHt_dJzlFV35c537iB_lviNVuVrgp6sl1M1dx5ZXgokKDCVFBSOEx6h3JrrZ1drxAzamTzSSTcFQE1v_i3MWC02q8d9awwxIbcxNy81KglLfpZBvCiSQmd_vERKw1tcbJuoESZORzGsXrteP1f10XQrMUlIfpJ5mMszQ=w400-h340&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Fatal Simulation Error in Proteus&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhyTtZROMXTvHFsilG4aon76G-jE6-bRjYWLwmD7zfH6cctOj94AxvPKT2tWlmDfBAUpCgyf2cQ69kHgu4SU5xb58Ywg5U0matid7PdKWtaR_zJFwpk85bVP9VR9zDjPR7wT0GLL492nm1GVxYCgcqePqcF2EavzgLPp5guX0xS9vpWWBHIAMgFoiqC2g&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;210&quot; data-original-width=&quot;698&quot; height=&quot;120&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhyTtZROMXTvHFsilG4aon76G-jE6-bRjYWLwmD7zfH6cctOj94AxvPKT2tWlmDfBAUpCgyf2cQ69kHgu4SU5xb58Ywg5U0matid7PdKWtaR_zJFwpk85bVP9VR9zDjPR7wT0GLL492nm1GVxYCgcqePqcF2EavzgLPp5guX0xS9vpWWBHIAMgFoiqC2g=w400-h120&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Fatal Simulation Error in Proteus&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The normal *.hex file was working fine, but when I wanted to do debugging using the debug files, such as the *.elf file or *.out file, it fails with the above message.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The development environment which I am using is IAR Embedded Workbench (IAR Compiler), and I also tested with STM32CubeIDE (GNU Compiler), so the debug files generated by both of these compilers failed to run on the Proteus.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I investigated and found the root cause of the problem that why this is not working and how to fix this problem.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Root Cause of the Problem&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The default debug output files generated by the IAR Compiler and GNU GCC Compiler is in dwarf4 format, while the Proteus can handle or work with dwarf2 format only as of now, so due to this reason whenever I tried to debug the program with these files, I get &quot;Fatal Simulation&quot; error as for Proteus the file format is not acceptable.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Solution to the Problem&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The solution to the problem is simple, we just need to change the format of the debug file generated by these compilers from dwarf4 to dwarf2. I will show you this can be done in STM32CubeIDE and also in IAR Embedded Workbench project settings.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;First, let&#39;s start with STM32CubeIDE, here we have to open the &lt;b&gt;&quot;Project Properties&quot;&lt;/b&gt; and then go to &lt;b&gt;&quot;C/C++ Build&quot;&lt;/b&gt; and then go to &lt;b&gt;&quot;MCU GCC Compiler&quot;&lt;/b&gt; and then Select &lt;b&gt;&quot;Miscellaneous&quot;&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhAw_bovkuDXhf7H9SxTU-hXdVvjAhgBFAZ2JJRtFplhe5MsAEM3bfDIOFsQP_HLAxb6JOCEKYlpsj6N9_RzJ4vVEuwCiwtASqXSaR19jT5BgN9Gz9HipZMLnOYQ05tjCb69xsP5s6hs5W26jGtgVQGyk_H3BHbJ8Ll0u0h5VSJyl2MxtzIC_clTM3wgg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;761&quot; data-original-width=&quot;916&quot; height=&quot;332&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhAw_bovkuDXhf7H9SxTU-hXdVvjAhgBFAZ2JJRtFplhe5MsAEM3bfDIOFsQP_HLAxb6JOCEKYlpsj6N9_RzJ4vVEuwCiwtASqXSaR19jT5BgN9Gz9HipZMLnOYQ05tjCb69xsP5s6hs5W26jGtgVQGyk_H3BHbJ8Ll0u0h5VSJyl2MxtzIC_clTM3wgg=w400-h332&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Adding Compiler Flag Setting&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And then click on the &lt;b&gt;&quot;+&quot;&lt;/b&gt; button to add a compiler flag &lt;b&gt;&quot;-gdwarf-2&quot; &lt;/b&gt;and by doing so the output file generated will be in dwarf2 format.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjd5YhZEj0TQEm7LrEjdUsDQB9tMvkZCLKZOTu8aWIZ3sNKC_Vy8jdjWut0Lw_2Wtu3EML73YRg7AsoRJHJQwYye9__dKogmXHCOI1nMuaZDwB8VwhEZ4-s_bf9wP_cIAZWQQcISQ0NJWI70nYVPJNPa8ZNV43PLb90W6L3RgBfR_-fa1Kf_mYMugPrvg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;706&quot; data-original-width=&quot;837&quot; height=&quot;337&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjd5YhZEj0TQEm7LrEjdUsDQB9tMvkZCLKZOTu8aWIZ3sNKC_Vy8jdjWut0Lw_2Wtu3EML73YRg7AsoRJHJQwYye9__dKogmXHCOI1nMuaZDwB8VwhEZ4-s_bf9wP_cIAZWQQcISQ0NJWI70nYVPJNPa8ZNV43PLb90W6L3RgBfR_-fa1Kf_mYMugPrvg=w400-h337&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Updating Compiler Flag to generate dwarf2 format in STM32CubeIDE&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;The second step is to show you how to achieve the same thing with IAR Compiler, so here also the process is really straightforward, first, go to &lt;b&gt;&quot;Project Option&quot;&lt;/b&gt;, then go to the &lt;b&gt;&quot;C/C++ Compiler&quot; &lt;/b&gt;and then select the &lt;b&gt;&quot;Extra Options&quot;&lt;/b&gt;, here check the &lt;b&gt;&quot;Use Command Line Options&quot; &lt;/b&gt;and then in the command line option, add the command &lt;b&gt;&quot;--no_dwarf4&quot;&lt;/b&gt;, this will instruct the compiler to not generate the dwarf4 format.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiTAqA2e7S8PNO0pxktjcJ35wJP6mofZVmpLWpuDDLsyl_bhl6htCWKZMx--Y-mBUyTqwrTSOyJ0kG_iW4DxJR_omgJ8Z8kOGaH9rG2y7hE-XOpKgchmWFA1AsaXz1ttOv_YcKM6w6DGKNKVtu8ZHMUnmSM_ypMpNv_5SjLnFJXOPo_eXFUZR4egF5_wg&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;536&quot; data-original-width=&quot;904&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiTAqA2e7S8PNO0pxktjcJ35wJP6mofZVmpLWpuDDLsyl_bhl6htCWKZMx--Y-mBUyTqwrTSOyJ0kG_iW4DxJR_omgJ8Z8kOGaH9rG2y7hE-XOpKgchmWFA1AsaXz1ttOv_YcKM6w6DGKNKVtu8ZHMUnmSM_ypMpNv_5SjLnFJXOPo_eXFUZR4egF5_wg=w400-h238&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Updating Compiler Flag to generate dwarf2 format in IAR&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;Apart from this in IAR, we have to do one additional change, and this is changing the debug output file name from &lt;b&gt;*.out &lt;/b&gt;to &lt;b&gt;*.elf&lt;/b&gt;&amp;nbsp;as shown below. This can be done by going into the &lt;b&gt;&quot;Linker&quot;&lt;/b&gt; setting and then selecting &lt;b&gt;&quot;Output&quot;&lt;/b&gt;, also make sure the checkbox &lt;b&gt;&quot;Include debug information in output&quot;&lt;/b&gt; is checked.&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgUWNu5g5HrxdnfSKzWWiTHlOMhRIhBIlKSVMHBKLc08gr70afd9TANBk8WObLzw8zzoGWen0LzUIzOoPXy6PxCz8tP53RVCk5QkXpq7IdoCOGViSenpuiPWaFbLjwJb4ir3Edbwn6CUI5zDQqScUjTsbC33ruva0nMr71LLkMjLjJlL5IabLc11zG8KQ&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;546&quot; data-original-width=&quot;579&quot; height=&quot;376&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgUWNu5g5HrxdnfSKzWWiTHlOMhRIhBIlKSVMHBKLc08gr70afd9TANBk8WObLzw8zzoGWen0LzUIzOoPXy6PxCz8tP53RVCk5QkXpq7IdoCOGViSenpuiPWaFbLjwJb4ir3Edbwn6CUI5zDQqScUjTsbC33ruva0nMr71LLkMjLjJlL5IabLc11zG8KQ=w400-h376&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Generating *.elf file in IAR&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Once this is done, the output *.elf file generated can be used to debug in Proteus, the following images demonstrate this.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjWQlpw4FCQonrF-kQ2kWE6Jr0PFL4wS-t2IG2XLkZfIpRek5eIT7M_BNeFWVUNWbKtYl1uVLq6-cY-Fy3EgrXOmjzOtFzT7ihKlJ72NhOpoBN3WsjYzxQJNh0gZQONFXxAG8EkUPgznVfmJu0mIvJamaKbf8NScn86QbLzh3p5fJgBWV47SNzrDqwZUA&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;951&quot; data-original-width=&quot;1419&quot; height=&quot;268&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjWQlpw4FCQonrF-kQ2kWE6Jr0PFL4wS-t2IG2XLkZfIpRek5eIT7M_BNeFWVUNWbKtYl1uVLq6-cY-Fy3EgrXOmjzOtFzT7ihKlJ72NhOpoBN3WsjYzxQJNh0gZQONFXxAG8EkUPgznVfmJu0mIvJamaKbf8NScn86QbLzh3p5fJgBWV47SNzrDqwZUA=w400-h268&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Debugging in Proteus&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;I am documenting this here because I was facing this problem from last so many days, and I think this post of mine will help you fix this issue.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;If you like this post also check my &lt;a href=&quot;https://www.youtube.com/channel/UCDBlAXL5NVb7HCgpTzC8vbg&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;YouTube&lt;/b&gt; &lt;/a&gt;channel for more such interesting topics.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;

&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a auxonclick=&quot;open_links()&quot; href=&quot;https://github.com/xpress-embedo&quot; onclick=&quot;open_links()&quot;&gt;Also, have a look at&lt;b&gt;&amp;nbsp;GitHub &lt;/b&gt;Account for some cool projects.&lt;/a&gt;&lt;/span&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
  function open_links()
  {
    window.open(&#39;https://amzn.to/3TkjlL3&#39;);
    return true;
  }
&lt;/script&gt;</description><link>http://embeddedlaboratory.blogspot.com/2022/11/fatal-simulation-error-while-debugging.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhIx9Yt-oR6MgPmYfsRlzJkDEeHt_dJzlFV35c537iB_lviNVuVrgp6sl1M1dx5ZXgokKDCVFBSOEx6h3JrrZ1drxAzamTzSSTcFQE1v_i3MWC02q8d9awwxIbcxNy81KglLfpZBvCiSQmd_vERKw1tcbJuoESZORzGsXrteP1f10XQrMUlIfpJ5mMszQ=s72-w400-h340-c" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-5810518197214703621</guid><pubDate>Sun, 31 Jul 2022 11:35:00 +0000</pubDate><atom:updated>2022-11-08T06:55:07.423-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">FFMPEG</category><category domain="http://www.blogger.com/atom/ns#">Others</category><title>FFMPEG Command Line Audio and Video Processing Tool</title><description>&lt;span style=&quot;font-family: verdana;&quot;&gt;Sometimes we need to post some videos of our setups, some issues, some behavior
on some forums, emails, etc., but the videos recorded from our mobile are too
big, so can&#39;t be attached to forums and also can&#39;t be sent over email, so to
overcome this situation, we have found a tool, which is open source and can be
used without installing, and this tool can be used to process audio and video
files. Not only just size reduction but this can also be used for several other audio
and video processing things.&amp;nbsp;&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;FFMPEG is a command line tool, below are some of the important commands which are useful for our needs.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjlEOtreyikbdj8Y3f5nGK38WmNM5IBo7zYryBeaJOYIX4PFYEC9gmkkX0KIL-8SQWb529fAt21HzW8PRbGtU1sJXL14krCcad1Nm_XcKEj_j58yazeKF_jiav4G9HoMEWvQQJMwR4pwzIHS7QtjTCOXi5v5Mp6HKqnSQz3_nQ-KKwfQsDX3Su04ezgZQ&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;116&quot; data-original-width=&quot;434&quot; height=&quot;86&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjlEOtreyikbdj8Y3f5nGK38WmNM5IBo7zYryBeaJOYIX4PFYEC9gmkkX0KIL-8SQWb529fAt21HzW8PRbGtU1sJXL14krCcad1Nm_XcKEj_j58yazeKF_jiav4G9HoMEWvQQJMwR4pwzIHS7QtjTCOXi5v5Mp6HKqnSQz3_nQ-KKwfQsDX3Su04ezgZQ&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href=&quot;https://ffmpeg.org/download.html&quot; target=&quot;_blank&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;a href=&quot;https://ffmpeg.org/download.html&quot; target=&quot;_blank&quot;&gt;Download Link for Windows User.&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Convert File Format&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;With FFMPEG we can convert the video file format, like in the below example we are changing a *.avi file into *.mp4 format.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; font-size: 14px; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i input.avi output.mp4&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Split a File&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; font-size: 14px; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.5rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;&lt;span style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; font-size: 9.75pt;&quot;&gt;&lt;span style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; font-family: Consolas;&quot;&gt;ffmpeg -i source.m4v -ss 0 -t 593.3 -c copy part1.m4v
ffmpeg -i source.m4v -ss 593.3 -t 551.64 -c copy part2.m4v
ffmpeg -i source.m4v -ss 1144.94 -t 581.25 -c copy part3.m4v&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; line-height: 1.4286; margin: 0.3rem 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana; font-size: medium;&quot;&gt;Reduce the Size by Changing Quantizer Value&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This method is applicable only for *.mp4 and *.avi files. There is a factor in image compression called quantizer that actually affects the file quality and it is linked to how it should choose the bit-rate when it comes to variable bit-encoding, for details check on the web.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The important point is smaller the quantizer higher the quality and the higher the quantizer lower is the quality. Higher quality means higher file size and lower quality means lower file size, so by changing this parameter, we can reduce the file size.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i input.mp4 -q 20 output_q20.mp4&lt;/pre&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;With the above command, we are setting the value of quantizer or quality to 20, I did an experiment where 40MB Full HD video is reduced to 6MB (video quality was still very good).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Note: If the input file is *.avi and the output required is *.mp4 then use -crf factor instead of -q, an example is given below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i input.avi -crf 18 output.mp4&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; line-height: 1.4286; margin: 0.3rem 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana; font-size: medium;&quot;&gt;Reduce the Size by Changing the Bitrate&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The above method works well, but if our requirement is to have finer control in setting the bitrate, then we can also do this with FFmpeg. And this works for both audio and videos, the following are the commands.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; font-size: 14px; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i in_file.mp3 -b:a 320k outputfile.mp3
ffmpeg -i in_file.mp4 -b:v 1000k outputfile.mp4&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;See the difference between -&lt;span style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; font-weight: 700;&quot;&gt;b:a&amp;nbsp;&lt;/span&gt;and -&lt;span style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; font-weight: 700;&quot;&gt;b:v&lt;/span&gt;, here&amp;nbsp;&lt;span style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; font-weight: 700;&quot;&gt;a&amp;nbsp;&lt;/span&gt;is for audio and&amp;nbsp;&lt;span style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; font-weight: 700;&quot;&gt;v&amp;nbsp;&lt;/span&gt;is for video.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;And with the following command, we can adjust the bitrate in a single command.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i in_file.mp4 -b:v 1000k -b:a 128k outputfile.mp4&lt;/pre&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;There are some filters also available with FFmpeg, check its documentation to have in-depth details, the few most commonly used filters are as below.&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px; margin-bottom: 10px; margin-top: 0px;&quot;&gt;&lt;li style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Audio: Volume&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Audio: Channel Map&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Video: Cropping&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Video: Scale&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Video: Rotate&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;background-color: white; color: #252423; font-size: 14px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Audio: Volume&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;With this filter we can increase or decrease the volume, the following is the command to double the volume.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i inputFile -filter:a &quot;volume=2&quot; outputfile&lt;/pre&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEguFI2vlpWrvFMCG0iaLNzEsf_J_Yqr1bmz3EjU4U_O7ebdjgvYM13MfiMmedADFfzVG2ricCLer8rvAzaskgCLRbp40hOF76mQunK2W6d1DN3Sz4d4Do3bp7LcaLZ3RcsJN8yYZpF1ZBz058AM2XH9HDULJZwJ5LcCrb4fzov1LbU1lC5ukPkfi3-Vew&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;326&quot; data-original-width=&quot;800&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEguFI2vlpWrvFMCG0iaLNzEsf_J_Yqr1bmz3EjU4U_O7ebdjgvYM13MfiMmedADFfzVG2ricCLer8rvAzaskgCLRbp40hOF76mQunK2W6d1DN3Sz4d4Do3bp7LcaLZ3RcsJN8yYZpF1ZBz058AM2XH9HDULJZwJ5LcCrb4fzov1LbU1lC5ukPkfi3-Vew=w320-h130&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This filter can be used to reduce external noise.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;h3&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Audio: Channel Mapping&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This is not so important for us, but still for documentation purposes adding it here.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i inputFile -filter:a &quot;channelmap=0-0|0-1&quot; outputFile&lt;/pre&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Here with the line&amp;nbsp;&lt;span style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;em style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box; font-weight: 700;&quot;&gt;&quot;channelmap=0-0|0-1&quot;&lt;/span&gt;&lt;/em&gt;&amp;nbsp;&lt;/span&gt;in the above command, we mean that we are mapping the Input Left to Output Left and Input Left to Output Right channel.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Video: Cropping&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This is an important filter and with this, we can remove the redundant information from our videos and this also reduces the file size. The following is the example command.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i inFile -filter:v &quot;crop=w:output_width:h:output_height:x:y&quot; outFile&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;4-parameters can be specified, i.e output width, output height, and top left corner parameters.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Top Left corner parameters are optional and if not specified, cropping is centered in the frame.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; box-sizing: border-box;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;We can also use arithmetic also in these parameters like the following.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i inFile -filter:v &quot;crop=w=2/3*in_w:h=2/3*in_h&quot; outFile&lt;/pre&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The variables in_w and in_h are supplied and they stand for input width and input height.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 1.4rem; line-height: 1.4286; margin: 0.3rem 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Video: Scaling&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; line-height: 1.25; margin: 0.3rem 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Syntax&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; font-size: 14px; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i inFile -filter:v &quot;scale=w=640:h=480&quot; outFile&lt;/pre&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Scaling with arithmetic and variables&lt;/span&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; font-size: 14px; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i inFile -filter:v &quot;scale=w=2/3*in_w:h=2/3*in_h&quot; outFile&lt;/pre&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Proportional Scaling&lt;/span&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; font-size: 14px; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i inFile -filter:v &quot;scale=w=640:h=-1&quot; outFile
&lt;/pre&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Put -1 for any of the inputs to get the proportional scaling and its value will be calculated based on the input.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 1.4rem; line-height: 1.4286; margin: 0.3rem 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Video: Rotate&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Syntax:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;-webkit-font-smoothing: antialiased; background: rgba(37, 36, 35, 0.05); border-radius: 0.2rem; border: none; box-sizing: border-box; color: #484644; font-family: &amp;quot;Cascadia Code&amp;quot;, Consolas, ui-monospace, Menlo, Monaco, monospace; font-size: 14px; line-height: 2rem; margin-bottom: 0.7rem; margin-top: 0.7rem; overflow-wrap: break-word; overflow: auto; padding: 0.7rem 1.6rem 0.6rem; word-break: break-all;&quot;&gt;ffmpeg -i inFile -filter:v &quot;rotate=45*PI/180&quot; outFile&lt;/pre&gt;&lt;div style=&quot;-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; color: #252423; font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This is also important for us, as sometimes when videos are recorded from mobiles, the orientation is not proper and with the above command we can change the orientation so that it can be viewed properly.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</description><link>http://embeddedlaboratory.blogspot.com/2022/07/ffmpeg-command-line-audio-and-video.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjlEOtreyikbdj8Y3f5nGK38WmNM5IBo7zYryBeaJOYIX4PFYEC9gmkkX0KIL-8SQWb529fAt21HzW8PRbGtU1sJXL14krCcad1Nm_XcKEj_j58yazeKF_jiav4G9HoMEWvQQJMwR4pwzIHS7QtjTCOXi5v5Mp6HKqnSQz3_nQ-KKwfQsDX3Su04ezgZQ=s72-c" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-4407915971739362225</guid><pubDate>Sat, 20 Feb 2021 09:53:00 +0000</pubDate><atom:updated>2022-11-08T06:34:59.093-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">IOT</category><title>Weather Station using Arduino and ESP8266 with Open Weather API using AT Command</title><description>&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Hello Everyone, in the last post I have shown you how to update your ESP8266 firmware and I have also shown you guys some of the important AT commands related to ESP8266 firmware which works with the new/latest firmware.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In today&#39;s post, I will share my Weather Station software with you guys, with which you can easily communicate with your &lt;a href=&quot;https://amzn.to/3ujLTsD&quot; target=&quot;_blank&quot;&gt;ESP8266 WiFi&lt;/a&gt; Module with Arduino and do the following things with the module.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Check whether the module is connected and working properly.&lt;br /&gt;- Connect to a Network (Need SSID and Password)&lt;br /&gt;- Get the MAC Address of the WiFi Module&lt;br /&gt;- Get the Assigned IP Address to the module&lt;br /&gt;- Connect with &quot;OpenWeather&quot; website&lt;br /&gt;- Get temperature, real feel temperature, minimum temperature, and maximum temperature of any city and display this information on OLED display&lt;br /&gt;OR&lt;br /&gt;- Get temperature, real feel temperature, minimum temperature, maximum temperature, pressure, humidity and wind speed of any city and display this information on TFT display.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;So, there are two projects, in one display is OLED and in another one display in TFT (ILI9341) based.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Instead of using an actual &lt;a href=&quot;https://amzn.to/3qPLGLy&quot; target=&quot;_blank&quot;&gt;Arduino&lt;/a&gt;, I am using Arduino Simulation Module in Proteus software, while the ESP8266 module is real, and is connected to my Laptop, and Proteus can access it using COMPIM.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmes6zNkzEFXkFo_tNTOdDAfuIqOkG-T-aouBNdKBZiuwx9SCWBbTfkBOGYuJaYpz8euPd0OzqaWQW9b1cE7KSIeyY1JTDe1-6ycCaHF_fVi6aCyNpQsg8K10AsfxN3VOkBnKO8Uec4_s/s1920/WeatherStation.gif&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmes6zNkzEFXkFo_tNTOdDAfuIqOkG-T-aouBNdKBZiuwx9SCWBbTfkBOGYuJaYpz8euPd0OzqaWQW9b1cE7KSIeyY1JTDe1-6ycCaHF_fVi6aCyNpQsg8K10AsfxN3VOkBnKO8Uec4_s/s320/WeatherStation.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Weather Station Simulation (TFT Based)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDQ5w6omSc3ss1axG0KMpY0ySfyNr5kmo1pf6S5TS2nXdPVdu04NixcDT2l3BCzy1xK4_ScUj-rvvICrXVZl8nKUlXKEq-B67_eADlCOvXqU2qEyyHRXPtHBtovBTwoLGrktMoV8YumVY/s1920/WeatherStation.gif&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1920&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDQ5w6omSc3ss1axG0KMpY0ySfyNr5kmo1pf6S5TS2nXdPVdu04NixcDT2l3BCzy1xK4_ScUj-rvvICrXVZl8nKUlXKEq-B67_eADlCOvXqU2qEyyHRXPtHBtovBTwoLGrktMoV8YumVY/s320/WeatherStation.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Weather Station Simulation (OLED Based)&lt;br /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/2BqeEwCSjyM&quot; width=&quot;320&quot; youtube-src-id=&quot;2BqeEwCSjyM&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/gWQxuI-oCUU&quot; width=&quot;320&quot; youtube-src-id=&quot;gWQxuI-oCUU&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;OLED Based&lt;/span&gt;&lt;/h4&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following are the software libraries needed for this project.&lt;br /&gt;- Standard Arduino Libraries&lt;br /&gt;- &lt;a href=&quot;http://www.rinkydinkelectronics.com/library.php?id=79&quot; target=&quot;_blank&quot;&gt;OLED_I2C Library from Rinky-Dink Electronics&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: #cc0000; font-family: verdana;&quot;&gt;&lt;a _blank=&quot;&quot; href=&quot;https://github.com/xpress-embedo/ArduinoWeatherStation&quot; onclick=&quot;window.open(&#39;https://amzn.to/3DGl1bR&#39;); return true;&quot;&gt;&lt;b&gt;Download the code from the GitHub Repository&lt;/b&gt;.&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This consist of software and simulation file.&lt;/span&gt;&lt;/p&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;ILI9341 TFT Based&lt;/span&gt;&lt;/h4&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following are the software libraries needed for this project.&lt;br /&gt;- Standard Arduino Libraries&lt;br /&gt;- Adafruit GFX Library&lt;br /&gt;- Adafruit ILI9341 Library&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/ArduinoWeatherStationTFT&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Download the code from the GitHub Repository&lt;/b&gt;.&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This consist of software and simulation file.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The Software Flow is as below,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I will try to prepare a diagram to help in understanding in a better way, but for now, I am writing the text description.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- At Power-Up SW initializes the OLED/TFT Library and Serial Communication.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Note: BaudRate of the module is changed to 9600 from 115200 because Proteus COMPIM doesn&#39;t support higher baud rates.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Here the ESP8266 module is connected to the main Arduino UART, you can change it to your choice and update the SW accordingly.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- OLED/TFT is cleared and some default information is displayed.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Arduino sends the &quot;echo off&quot; command to the module, this is done to prevent turning off the echoing of the characters transmitted by Arduino.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Arduino sends the &quot;AT&quot; command and checks for the **OK** response, if the response comes from the module, then SW will move further, else it will stay in the same state retrying until the valid response comes from the ESP8266 module.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Arduino sends the command to change the mode to &quot;Station Mode&quot;, here also the response from the module is checked, and if valid SW will move further else remain in the same state.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Arduino will then send the command to join with the access point, and if connected SW will move further, else it will keep on retrying.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Arduino will now send the command to get the assigned IP address and MAC address of the module, and if the response is valid, Arduino SW will display this information on the OLED/TFT screen. Till this stage, our setup and initialization of the module are done.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Now here comes the repetitive part, where we get the data of one city and display it on the OLED/TFT, and then move to the next city.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Arduino SW will connect with the &quot;open weather&quot; server, and once the connection is successful it will proceed further else keeps on retrying.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Now Arduino SW will send the number of bytes command followed by the &quot;GET&quot; request for the selected city.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Arduino will receive the data from the ESP8266 module, parse it, and display it on the OLED/TFT screen if it is valid.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Other Important Topics related to this topic.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/wXXXgaePZX8&quot; width=&quot;320&quot; youtube-src-id=&quot;wXXXgaePZX8&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/hP4YxjG9t3g&quot; width=&quot;320&quot; youtube-src-id=&quot;hP4YxjG9t3g&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2021/02/weather-station-using-arduino-and.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmes6zNkzEFXkFo_tNTOdDAfuIqOkG-T-aouBNdKBZiuwx9SCWBbTfkBOGYuJaYpz8euPd0OzqaWQW9b1cE7KSIeyY1JTDe1-6ycCaHF_fVi6aCyNpQsg8K10AsfxN3VOkBnKO8Uec4_s/s72-c/WeatherStation.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-9102543770661303427</guid><pubDate>Sat, 06 Feb 2021 11:11:00 +0000</pubDate><atom:updated>2021-02-20T02:28:33.809-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">IOT</category><title>Update the AT Firmware in Your ESP8266 WiFi Module</title><description>&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Hello Everyone,&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;In today&#39;s post, I will show you how one can update the AT firmware in your ESP8266 module. Now, there might be questions in your mind that why we wanted to update the ESP8266 WiFi firmware when the current one is already working fine.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEjAevdkHnvK4x6vsb014A2_liFhDKkNEad4JoGsxwLh2DG0HXhBtl11MWRFmQUZG6j0QvhEIMQmPVMXmhr8ORZtQQ6UDKMQ-j0qi4awANdNsavobEk5Rlw4uJ8laQKBM3RKDyl_7XdZQ/s960/71-Update+ESP8266+Firmware-GIF.gif&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;960&quot; data-original-width=&quot;540&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEjAevdkHnvK4x6vsb014A2_liFhDKkNEad4JoGsxwLh2DG0HXhBtl11MWRFmQUZG6j0QvhEIMQmPVMXmhr8ORZtQQ6UDKMQ-j0qi4awANdNsavobEk5Rlw4uJ8laQKBM3RKDyl_7XdZQ/s320/71-Update+ESP8266+Firmware-GIF.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;So, in my case, the reason is that the WiFi module which I received has the firmware from 2016 which is pretty old and some of the AT commands are not working, since during 2016 those commands were not available. There are always the benefits of updating the firmware to the latest version. Below are some of the benefits which I can think of as of now.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- New Firmware has more features.&lt;br /&gt;- New Firmware has bug fixes and hence is more stable.&lt;br /&gt;- Sometimes we messed up &amp;amp; put some wrong SW &amp;amp; hence wanted to restore everything to normal.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Updating the firmware in ESP8266 is a really painful process if you don&#39;t know the correct steps, in this post and the video I embedded in this post is the latest as of in 2021, and I tried to cover all the steps so that you don&#39;t face any problem in updating the firmware, so let&#39;s get started.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The video is as below.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/wXXXgaePZX8&quot; width=&quot;320&quot; youtube-src-id=&quot;wXXXgaePZX8&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I recommend watching the video as compared to reading this text, as I think watching the video is more helpful.&lt;/span&gt;&lt;/p&gt;The following is the pin-out of the ESP8266 WiFi module.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8mdbopzzzXoYYEQjVbPWSzH_pEvt4hmfo3Xh_Q4xqQwQVozX_DCV75uGF4nOau-1DT-2AASgLe7QycqZY9qRUzwdKUhdUu2y4VZmcuxupdKzzGym6nRIhc6Tum5duzW2rVThBPhGTzJE/s764/ESP8266+WiFiModule+PinOut-Blogger.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Pin-Out of ESP8266 Module&quot; border=&quot;0&quot; data-original-height=&quot;411&quot; data-original-width=&quot;764&quot; height=&quot;172&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8mdbopzzzXoYYEQjVbPWSzH_pEvt4hmfo3Xh_Q4xqQwQVozX_DCV75uGF4nOau-1DT-2AASgLe7QycqZY9qRUzwdKUhdUu2y4VZmcuxupdKzzGym6nRIhc6Tum5duzW2rVThBPhGTzJE/w320-h172/ESP8266+WiFiModule+PinOut-Blogger.png&quot; title=&quot;Pin-Out of ESP8266 Module&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: times;&quot;&gt;Pin-Out of ESP8266 Module&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following are the components required to update the firmware in the ESP8266 WiFi Module.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- ESP8266 WiFi Module (Of course you need this :-) )&lt;br /&gt;- USB to Serial Converter&lt;br /&gt;- Male to Female Cables&lt;br /&gt;- Mechanical Switches&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;ESP8266 WiFi module firmware is updated over UART so that&#39;s why we need USB to UART converter, and cables or mechanical switches are needed to short the FLASH and RST pin to ground pin, this can be done neatly with the mechanical switches and cables, so it&#39;s up to you, how you wanted to do it.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The following are the connection, which you have to do.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg6y3NgInzdJX1EtEyu2KwY-0kks9S1F1bzHN66JmJ82Ot56IeaS_KStWYmlx3Wiwii6fWQH8wBARUqWT_jkjgTYfQLFm_ioaxuUHPN3UTnDENTqwKw60h9jPplpLw_JXc80LnxWW7YyI/s1128/Update+ESP8266+Firmware.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;363&quot; data-original-width=&quot;1128&quot; height=&quot;129&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg6y3NgInzdJX1EtEyu2KwY-0kks9S1F1bzHN66JmJ82Ot56IeaS_KStWYmlx3Wiwii6fWQH8wBARUqWT_jkjgTYfQLFm_ioaxuUHPN3UTnDENTqwKw60h9jPplpLw_JXc80LnxWW7YyI/w400-h129/Update+ESP8266+Firmware.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: times;&quot;&gt;Connection for Updating Firmware&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The idea is simple, you need to short your RST pin and FLASH pin of the WiFi module with the Ground Pin, and then only you can enter the programming mode.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Once the connections are done, as a next step download the required tools and firmware from the ESPRESSIF website.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Download Link:&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;https://www.espressif.com/en/support/download/all&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Download the &quot;Flash Download Tool&quot; current version is v3.8.5&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Download the AT Command Firmware which is &quot;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;ESP8266_NonOS_AT_Bin_V1.7.4&quot;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Once this downloading of software is done, as a next step, we have to determine which SPI flash is present on our module, whether it is 4Mbit or 8Mbit or 16Mbit , etc.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This we can do easily with the help of &quot;Flash Download Tool&quot;, the following are the steps to determine the SPI flash present on your module.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Connect RST and FLASH pin with the ground and connect the module with USB to UART module with the USB port&lt;br /&gt;- Open the &quot;Flash Download Tool&quot;, make sure the &quot;SPIDownload&quot; tab is selected and all the check-boxes are unchecked.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfgveclIvjOPEw5bAPieS9U8wDorS3muJDHYGDsAW9L97Ai2EW5QLYcxDFL_WHald1suoEOmZNRi3wpa8bauh2MVujjYVJcU3YDXqaH7KRhaRqcfGBwUjRKDo63f0Eq8NlmARdV6RCs4o/&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;823&quot; data-original-width=&quot;522&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfgveclIvjOPEw5bAPieS9U8wDorS3muJDHYGDsAW9L97Ai2EW5QLYcxDFL_WHald1suoEOmZNRi3wpa8bauh2MVujjYVJcU3YDXqaH7KRhaRqcfGBwUjRKDo63f0Eq8NlmARdV6RCs4o/&quot; width=&quot;152&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: times;&quot;&gt;Flash Download Tool&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;- Now, press the start button, and on the command prompt, you see some dots and dashed lines, now disconnect the RST pin from the ground.&lt;br /&gt;- Once you do the above step, you will see that the &quot;Flash Download Tool&quot; has fetched some important information from your module, which includes, Flash Size, Crystal Frequency, Access Point MAC address, and Station Mode MAC Address, as can be seen in the below image.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWCHtWFbhb_tuX8AlKYfMkzE7dTAmA_H6HjS0MDBvKuHdXJt-LoGS6hPAUecnqa3cpRp0MvRlrNT4-jdwUkpjgo5TTncojVIgMjh86Ryz0WPl8DfhBOxcMuMTOZxpemSMnzcNbNQ6cbcI/&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;917&quot; data-original-width=&quot;825&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWCHtWFbhb_tuX8AlKYfMkzE7dTAmA_H6HjS0MDBvKuHdXJt-LoGS6hPAUecnqa3cpRp0MvRlrNT4-jdwUkpjgo5TTncojVIgMjh86Ryz0WPl8DfhBOxcMuMTOZxpemSMnzcNbNQ6cbcI/&quot; width=&quot;216&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: times;&quot;&gt;Module Information&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;- Now, with the help of this information we can update our firmware since as per the above image we can see the Flash Size is 8Mbit, and then in ESPRESSIF AT Documentation, section &quot;Downloading AT firmware into the Flash&quot;, I will open the 8Mbit section while depending on what you get, you will open that particular section.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbFqmCy_nW1ert3sn5CYu-VBJtwOISWYDfcdOD0xnE2DK6KmNc-qwd5TX1nMCeSoJ7Pm8snMqnGuIY9ShZXwBwe_JZV2d3z6rKWSoeIDGNNYfImOT6oYQgHAjsvF60U9KSrGXhCEh7n-c/&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;643&quot; data-original-width=&quot;1492&quot; height=&quot;138&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbFqmCy_nW1ert3sn5CYu-VBJtwOISWYDfcdOD0xnE2DK6KmNc-qwd5TX1nMCeSoJ7Pm8snMqnGuIY9ShZXwBwe_JZV2d3z6rKWSoeIDGNNYfImOT6oYQgHAjsvF60U9KSrGXhCEh7n-c/&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: times;&quot;&gt;ESP8266 AT Command Document&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;- Now, we will copy these addresses and the binaries downloaded from the ESPRESSIF website into our &quot;Flash Download Tool&quot; as shown in the below image.&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhluyS1uizbYonzej7hhKr-bPH27HaKnqv_5EOTxvBzoQtvOrQHsYjeGmnsr2bdZ5JaiBVZ6EYrHh_Ls7YUkSYNoKWQdp-PuxyQjvZn9NRhaDssl_1yVnfbcU6hZCOLrPqa8gSYGGc091s/&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;846&quot; data-original-width=&quot;1452&quot; height=&quot;233&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhluyS1uizbYonzej7hhKr-bPH27HaKnqv_5EOTxvBzoQtvOrQHsYjeGmnsr2bdZ5JaiBVZ6EYrHh_Ls7YUkSYNoKWQdp-PuxyQjvZn9NRhaDssl_1yVnfbcU6hZCOLrPqa8gSYGGc091s/w400-h233/image.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: times;&quot;&gt;Copy Address from Documents to Flash Tool&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;- Once this is done, select the correct Flash settings, and now we are ready for programming the new firmware.&lt;br /&gt;- Make sure your RST and Flash Pins are connected with Ground, and now press the start key.&lt;br /&gt;- On Command Prompt you will see some dots and dashes, and now you can disconnect the RST pin from the Ground, and after doing this your programming is completed.&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisoKQxLRcIpTAbLRAi3kh1iqzBXtwWM8fPqB0PqNBy40wQsGM-GvO-Oce0dDew7nGgSJv85C7Li3wsPnPp_vabXaQPyulxTuhnaoYyxZPKPtXerniahobT3t48ucgK1cEEBy0uiusRh0g/s960/71-Update+ESP8266+Firmware-GIF.gif&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;960&quot; data-original-width=&quot;540&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisoKQxLRcIpTAbLRAi3kh1iqzBXtwWM8fPqB0PqNBy40wQsGM-GvO-Oce0dDew7nGgSJv85C7Li3wsPnPp_vabXaQPyulxTuhnaoYyxZPKPtXerniahobT3t48ucgK1cEEBy0uiusRh0g/s320/71-Update+ESP8266+Firmware-GIF.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;The firmware update is done, and now you can disconnect the RST and Flash Pin from the ground (RST is already disconnected), remove the USB to Serial Converter module from the USB port, and connect it back again.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Now with the help of serial terminal utility like HW Hercules test whether the firmware is updated correctly or not, this can be done with the help of AT+GMR command, as can be seen in the below screenshot, we are getting version 1.7.4.0, this is the same as what is programmed into the module.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJPOQcU-WqwS4dQhAe9DvOSL8bvQUa7nuARMvkyRJhYMnH5IjXXWO3Opa49-zHth7tvlbrKp9osowVBaVh1NNbzTgKREdJ5u7p1dgA8jDtBec0fItBWvndVY-6NwciJkRkOynInknys-k/&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img data-original-height=&quot;558&quot; data-original-width=&quot;813&quot; height=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJPOQcU-WqwS4dQhAe9DvOSL8bvQUa7nuARMvkyRJhYMnH5IjXXWO3Opa49-zHth7tvlbrKp9osowVBaVh1NNbzTgKREdJ5u7p1dgA8jDtBec0fItBWvndVY-6NwciJkRkOynInknys-k/w400-h275/image.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: times;&quot;&gt;Testing Updated Firmware&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;That&#39;s all in this post, I would still recommend watching the video rather than reading this text. if you have any questions let me know in the comment section here or on the YouTube channel. If you want me to do some other video related to the ESP8266 module, let me know.&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red; font-family: verdana;&quot;&gt;&lt;b&gt;Update: 17-Feb-2021&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I have prepared one video, where I mentioned some of the important AT commands related to the ESP8266 WiFi module, and with the help of AT commands, I have connected to the &quot;OpenWeatherMap&quot; website to fetch the weather information of some cities.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/hP4YxjG9t3g&quot; width=&quot;320&quot; youtube-src-id=&quot;hP4YxjG9t3g&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;b style=&quot;color: red; font-family: verdana;&quot;&gt;Update: 17-Feb-2021&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;As mentioned earlier, I have used Arduino Mega and ESP8266 module, and using these two I have connected with the Open Weather Map website to get the data of some cities and display them on an OLED screen.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;GitHub:&amp;nbsp;https://github.com/xpress-embedo/ArduinoWeatherStation&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;Blog:&amp;nbsp;https://embeddedlaboratory.blogspot.com/2021/02/weather-station-using-arduino-and.html&lt;br /&gt;Youtube:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/gWQxuI-oCUU&quot; width=&quot;320&quot; youtube-src-id=&quot;gWQxuI-oCUU&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://embeddedlaboratory.blogspot.com/2021/02/update-at-firmware-in-your-esp8266-wifi.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEjAevdkHnvK4x6vsb014A2_liFhDKkNEad4JoGsxwLh2DG0HXhBtl11MWRFmQUZG6j0QvhEIMQmPVMXmhr8ORZtQQ6UDKMQ-j0qi4awANdNsavobEk5Rlw4uJ8laQKBM3RKDyl_7XdZQ/s72-c/71-Update+ESP8266+Firmware-GIF.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-131875671995439959</guid><pubDate>Wed, 27 May 2020 16:59:00 +0000</pubDate><atom:updated>2020-05-27T11:55:36.812-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Microchip</category><title>Analog Clock using OLED and PIC Microcontroller</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Hello Everyone, in this blog post I will show you guys how to make an analog clock on OLED SSD1306, this is a simple and cool project to display some basic animations on the OLED display.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0aGjdXHlA-luzT2jbgDo55le9eDTc_52a3QaiX69S70WQuHXOYJi_bREjDUwEnyvac0koE4SQHXB7-sj3kbP668lvusNFo383_2HDGtaLuW3AumwX5R6qLwiGrfHKXUDnQNaaa_AD9zw/s1600/Digital_and_Analog_Clock.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;468&quot; data-original-width=&quot;588&quot; height=&quot;254&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0aGjdXHlA-luzT2jbgDo55le9eDTc_52a3QaiX69S70WQuHXOYJi_bREjDUwEnyvac0koE4SQHXB7-sj3kbP668lvusNFo383_2HDGtaLuW3AumwX5R6qLwiGrfHKXUDnQNaaa_AD9zw/s320/Digital_and_Analog_Clock.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;We are going to build this project in the proteus simulation environment and use the PIC18F microcontroller. In terms of the software components, we need I2C Library, OLED Library, and DS1307 RTC Library.&lt;br /&gt;If you are following my blogs you might be aware that these three libraries are already available and tested well, the following are the links to the previous posts, you can refer if you want.&lt;br /&gt;&lt;b&gt;&lt;a href=&quot;http://embeddedlaboratory.blogspot.com/2018/02/oled-i2c-display-using-microchip-pic.html&quot; target=&quot;_blank&quot;&gt;OLED I2C Display Using Microchip PIC Microcontroller&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;a href=&quot;http://embeddedlaboratory.blogspot.com/2020/02/real-time-clock-ds1307-interfacing-with.html&quot; target=&quot;_blank&quot;&gt;Real Time Clock (DS1307) Interfacing with PIC Microcontroller&lt;/a&gt;&lt;br /&gt;(&lt;i&gt;My all new projects will be on GitHub and I am also trying to port all previous projects on GitHub so that these can be maintained well.&lt;/i&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The following are the steps to make an Analog Clock.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Make a small circle with a very small radius such as 1&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Make a big circle with a big radius but make sure to not exceed the screen size.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;i&gt;Make Hour Ticks&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;We have 12 Hours and 360 degrees, which means 1 Hour equals 30 degrees.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;We will use a for loop incremented by 30 degrees, to draw small lines representing ticks for each hour position. This is done by &lt;i&gt;draw_clock_face&lt;/i&gt;&amp;nbsp;function.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;draw_clock_face&lt;/i&gt; function uses sine and cosine formulas to draw 12 marks of length 5 at each hour position.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Displaying Hour, Minute and Second Hands&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Displaying timing using clock hands is very similar to displaying marks.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Hour Hand should be very small, while minute being medium and second hand should be longest of all.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Data from RTC is read and converted to decimal format from BCD format, and this is data is faced to the display_time function.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Executing this function per second will have an animation effect of moving the second hand of the clock.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In the project, we have called this per 500ms, the reason for this is the digital clock as we wanted to display the colon blinking, which is done half a second.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The following is the code and this can be downloaded or cloned from my GitHub page (&lt;a href=&quot;https://github.com/xpress-embedo/AnalogClockOLED&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;&lt;i&gt;click here&lt;/i&gt;&lt;/b&gt;&lt;/a&gt;).&lt;/span&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/b79f8f0e0434bcd2ad08a51acb212b93.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The following is the simulation video link.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe width=&quot;320&quot; height=&quot;266&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/HlswG76Q9Us/0.jpg&quot; src=&quot;https://www.youtube.com/embed/HlswG76Q9Us?feature=player_embedded&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In case of any doubt, feel free to contact us.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;border: 0px; color: inherit; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; color: inherit; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://embeddedlaboratory.blogspot.com/2020/05/analog-clock-using-oled-and-pic.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0aGjdXHlA-luzT2jbgDo55le9eDTc_52a3QaiX69S70WQuHXOYJi_bREjDUwEnyvac0koE4SQHXB7-sj3kbP668lvusNFo383_2HDGtaLuW3AumwX5R6qLwiGrfHKXUDnQNaaa_AD9zw/s72-c/Digital_and_Analog_Clock.gif" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-7190747901080639299</guid><pubDate>Sat, 23 May 2020 23:25:00 +0000</pubDate><atom:updated>2020-05-30T13:46:25.609-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Others</category><title>Displaying Basic 2D Shapes Using emWin</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Hello Everyone, In the last two posts, we have learned how to display text and display images using the emWin framework under a simulated environment using Code::Blocks. If you have not seen those blog posts, I would recommend you first have a look at them.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2020/03/getting-started-with-emwin-using.html&quot; target=&quot;_blank&quot;&gt;Getting Started with emWin using Code::Blocks&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2020/05/draw-bitmap-images-using-emwin.html&quot; target=&quot;_blank&quot;&gt;Draw Bitmap Images using emWin&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now in this blog post, I will show you to use some other basic 2D APIs to draw some basic 2D shapes, such as rectangle, triangle, polygon, ellipse, pie chart, etc.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Basic 2D Shapes&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;- Draw horizontal and vertical Gradients&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;- Draw rectangles&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;- Change Pen Size&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;- Draw Pixel and Points&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6YB6dC4_D-0-hpaXmKZyeRPs_lkC6OahBtS_2-0ncqYLaoohj-d-tkHk2kEifNcSP9fZ8wDE6IeoYPKXj9y0MfVi6tgmTBwYpnBmSmVK3IRXbk7avS0OiXtoprsIyqzFQjBPwGVcccwI/s1600/Display+2D+Shapes+using+emWin.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;532&quot; data-original-width=&quot;684&quot; height=&quot;310&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6YB6dC4_D-0-hpaXmKZyeRPs_lkC6OahBtS_2-0ncqYLaoohj-d-tkHk2kEifNcSP9fZ8wDE6IeoYPKXj9y0MfVi6tgmTBwYpnBmSmVK3IRXbk7avS0OiXtoprsIyqzFQjBPwGVcccwI/s400/Display+2D+Shapes+using+emWin.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Basic 2D Shapes&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/5dbed86dc6c8934cce0c7ba455462f5d.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;b style=&quot;font-family: verdana, sans-serif;&quot;&gt;&lt;br /&gt;Draw Lines&lt;/b&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/79cf85c8aaf1c36f062637f847b777ba.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy8vN969tCbwGz-wd20X2A5cGv1oBvb-O1UHNbwnJv6HC3XGXM2V9lNZOiWfVzKJmEUGR46S6U_fFNXgEiWj6171ThjGcVDZxsz50n4DCcCVeqky14DhE6uC0pASDCLHApgB9hk0ySwf4/s1600/069-Display+Basic+Shapes+Lines.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;481&quot; data-original-width=&quot;558&quot; height=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy8vN969tCbwGz-wd20X2A5cGv1oBvb-O1UHNbwnJv6HC3XGXM2V9lNZOiWfVzKJmEUGR46S6U_fFNXgEiWj6171ThjGcVDZxsz50n4DCcCVeqky14DhE6uC0pASDCLHApgB9hk0ySwf4/s320/069-Display+Basic+Shapes+Lines.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-family: verdana, sans-serif;&quot;&gt;Draw Circles&lt;/b&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/2e1adfb02850ecbd96cb420a191671ec.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb7QkBof8uOAbyi7HtxfBmCxSdbJIfeSc95-v0FPwt7HkQGmvN_6PiO6ctMUWt1tfQfUbmMmrwkzq2GKioqozNzdmR-LnfRfzICEFcYnLFcCPobp-HvyD30dYL1TtFzWA1X4ZaLy3noDE/s1600/069-Display+Basic+Shapes+Circle.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;486&quot; data-original-width=&quot;557&quot; height=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb7QkBof8uOAbyi7HtxfBmCxSdbJIfeSc95-v0FPwt7HkQGmvN_6PiO6ctMUWt1tfQfUbmMmrwkzq2GKioqozNzdmR-LnfRfzICEFcYnLFcCPobp-HvyD30dYL1TtFzWA1X4ZaLy3noDE/s320/069-Display+Basic+Shapes+Circle.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-family: verdana, sans-serif;&quot;&gt;Draw Ellipses&lt;/b&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/640ef5106e36790e000a1cd3fb3c935d.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwcQqLvQfBscYBRE7VZIIMEn-US6LhCrsbOMbaOumzLWSN4uBrQp4meDZKBMWUvFHy7_EtJi2zPmx6LqWjbKqIUJtabygCZMHqehf0f0nl4y66RHHyBv6Q68Cj1luT09MxNB4UmVLa7ag/s1600/069-Display+Basic+Shapes+Ellipses.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;478&quot; data-original-width=&quot;559&quot; height=&quot;273&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwcQqLvQfBscYBRE7VZIIMEn-US6LhCrsbOMbaOumzLWSN4uBrQp4meDZKBMWUvFHy7_EtJi2zPmx6LqWjbKqIUJtabygCZMHqehf0f0nl4y66RHHyBv6Q68Cj1luT09MxNB4UmVLa7ag/s320/069-Display+Basic+Shapes+Ellipses.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-family: verdana, sans-serif;&quot;&gt;Draw Polygon&lt;/b&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/fca537e507aa301ac865c0275bc61968.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm_H7qKqqze0mxw9J-flseqknxmgroPdQbWLBHqfntwqfCnUcZC4g1CRb3FU58Ukr3779x5GTTWS2WguzrsBLejXve3KZFt_m1q9iUAQ0lLELUd67OuvUq23GNpDSLP4sQQJAEHHUpEgg/s1600/069-Display+Basic+Shapes+Polygon.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;472&quot; data-original-width=&quot;557&quot; height=&quot;271&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm_H7qKqqze0mxw9J-flseqknxmgroPdQbWLBHqfntwqfCnUcZC4g1CRb3FU58Ukr3779x5GTTWS2WguzrsBLejXve3KZFt_m1q9iUAQ0lLELUd67OuvUq23GNpDSLP4sQQJAEHHUpEgg/s320/069-Display+Basic+Shapes+Polygon.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-family: verdana, sans-serif;&quot;&gt;Draw Pie Chart&lt;/b&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/14a5ba7bf90366f7c3ff552a821731f4.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXWuxBlW5wiISAA6rtvGFY4yWQbWyIBZD7eh01Et8FsuAQQ5Unn3UZU7ol7-v1GRQp_379G3ggCojVOk2O725wI2lm4AtJdlUENZYb9awm3JMytwKN6wF700-83jaIbc9BqpXmYqOpFxk/s1600/069-Display+Basic+Shapes+Pie+Chart.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;481&quot; data-original-width=&quot;569&quot; height=&quot;269&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXWuxBlW5wiISAA6rtvGFY4yWQbWyIBZD7eh01Et8FsuAQQ5Unn3UZU7ol7-v1GRQp_379G3ggCojVOk2O725wI2lm4AtJdlUENZYb9awm3JMytwKN6wF700-83jaIbc9BqpXmYqOpFxk/s320/069-Display+Basic+Shapes+Pie+Chart.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-family: verdana, sans-serif;&quot;&gt;Draw Line Graph&lt;/b&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/d5f752a7e7a619d266c213f857b46473.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHzynw_8ApZibCZ9urDTqeHkXDXhAX3enDAoUhLQL1vf8RM9Y6CQaF6mMsWbrXNMmqf-0KPAbnNDgonlbBRHZwI_9La-6Q24WB0krZRK0OGYuuLxdhqHK00p9tnqdjwuH-3xXAMYKxOAw/s1600/069-Display+Basic+Shapes+Line+Graph.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;483&quot; data-original-width=&quot;554&quot; height=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHzynw_8ApZibCZ9urDTqeHkXDXhAX3enDAoUhLQL1vf8RM9Y6CQaF6mMsWbrXNMmqf-0KPAbnNDgonlbBRHZwI_9La-6Q24WB0krZRK0OGYuuLxdhqHK00p9tnqdjwuH-3xXAMYKxOAw/s320/069-Display+Basic+Shapes+Line+Graph.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-family: verdana, sans-serif;&quot;&gt;Draw Bitmap Images&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;There is a separate blog post to draw bitmap images on the display,&amp;nbsp;&lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2020/05/draw-bitmap-images-using-emwin.html&quot; target=&quot;_blank&quot;&gt;click here&lt;/a&gt;&amp;nbsp;to read the blog post link.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The following is the complete Code::Blocks program, also watch the video given below to view how the complete program runs.&lt;/span&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/a786326048880f5c30f8740f1d236e92.js&quot;&gt;&lt;/script&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/BejF-vyzsbA/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/BejF-vyzsbA?feature=player_embedded&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
</description><link>http://embeddedlaboratory.blogspot.com/2020/05/displaying-basic-2d-shapes-using-emwin.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6YB6dC4_D-0-hpaXmKZyeRPs_lkC6OahBtS_2-0ncqYLaoohj-d-tkHk2kEifNcSP9fZ8wDE6IeoYPKXj9y0MfVi6tgmTBwYpnBmSmVK3IRXbk7avS0OiXtoprsIyqzFQjBPwGVcccwI/s72-c/Display+2D+Shapes+using+emWin.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-8549065005983068841</guid><pubDate>Sat, 23 May 2020 14:41:00 +0000</pubDate><atom:updated>2020-05-23T09:02:53.598-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Others</category><title>Draw Bitmap Images using emWin</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Hello Everyone, in this blog post, I will show you the step by step instructions to display a simple bitmap image on the display. I hope you guys have already read the first tutorial of this series, if not &lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2020/03/getting-started-with-emwin-using.html&quot; target=&quot;_blank&quot;&gt;click here&lt;/a&gt; to read that post.&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWvEFY0kwKmot1Y_ORw7Z2RZH4sQgG83BzBOD5Nz0DUj6kn2mOmpr9XkrttjP4z630pCwnmL7IffNOemHYy8LETTCmYlm37Td3m6AtilNBeBpxkRBExhDrpflgKziPnOCkMInCn77dQBs/s1600/068-Displaying+Bitmap+Images+Using+emWin-3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;438&quot; data-original-width=&quot;563&quot; height=&quot;248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWvEFY0kwKmot1Y_ORw7Z2RZH4sQgG83BzBOD5Nz0DUj6kn2mOmpr9XkrttjP4z630pCwnmL7IffNOemHYy8LETTCmYlm37Td3m6AtilNBeBpxkRBExhDrpflgKziPnOCkMInCn77dQBs/s320/068-Displaying+Bitmap+Images+Using+emWin-3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Bitmap Displayed on emWin simulation&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;There are three steps which we need to follow:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Select the bitmap images based on the display type.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Convert the bitmap images into *.c source code using emWin Bitmap converter tool.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Use emWin API&#39;s to display Bitmap images on the Graphical displays.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Please have a look at the following video.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/NXi9px5g6fM/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/NXi9px5g6fM?feature=player_embedded&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Once the images are selected, use the &quot;Bitmap Converter Tool&quot; provided by Segger (available with emWin simulation for free), to load the image, and then save the file with extension as *.c filetype.&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyqv8wpEo8OsGrGgiL5qnTJ1DAq1tTmGPPseloBbJ4M4h1k0fO95W0xHAzgINQWU59pLf-bilexPmraLBo1umaSX-sWOKi1NQs7BXfiIeH4mm55R4GQaAA5r0TEhL8UGdqbKMPRUkwKd0/s1600/068-Bitmap+Converter+Tool.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;549&quot; data-original-width=&quot;1085&quot; height=&quot;161&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyqv8wpEo8OsGrGgiL5qnTJ1DAq1tTmGPPseloBbJ4M4h1k0fO95W0xHAzgINQWU59pLf-bilexPmraLBo1umaSX-sWOKi1NQs7BXfiIeH4mm55R4GQaAA5r0TEhL8UGdqbKMPRUkwKd0/s320/068-Bitmap+Converter+Tool.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Bitmap Converter Tool&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Add these generated *.c files into the Code::Blocks project, as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnRExjCWukCWzxfRqToBOO0XGGf_3CKs7OBERJXrhD3pPm-G4ltDDRzw4fnKjj2_W0ZUREnSBJOQfrYDFlTc3SHOxGWTs_dsaB1nExlqOi-vqAeqPlmEaR9QPBmuFhK8zmNcgYtYdLN9g/s1600/068-Generated+Files+Added.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;615&quot; data-original-width=&quot;462&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnRExjCWukCWzxfRqToBOO0XGGf_3CKs7OBERJXrhD3pPm-G4ltDDRzw4fnKjj2_W0ZUREnSBJOQfrYDFlTc3SHOxGWTs_dsaB1nExlqOi-vqAeqPlmEaR9QPBmuFhK8zmNcgYtYdLN9g/s320/068-Generated+Files+Added.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Add image files into the Code::Block Projects&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now, use the emWin API &quot;GUI_DrawBitmap&quot;, to display the bitmaps on the Graphical Display. In our example we have generate the *.c code for three images and there names are &quot;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;bmimage01&quot;, &quot;bmimage04&quot; and &quot;bmSTLogo&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Use the following piece of code to update the display.&lt;/span&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/b943a5fbff4f2902eb7e977ab3e395fd.js&quot;&gt;&lt;/script&gt;

&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Thanks for reading this blog post, in case you have some question please post your comment here. This is just a starting and my target is to use the STM32F7 display and emWin to do some cool projects.&lt;/span&gt;&lt;/div&gt;
</description><link>http://embeddedlaboratory.blogspot.com/2020/05/draw-bitmap-images-using-emwin.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWvEFY0kwKmot1Y_ORw7Z2RZH4sQgG83BzBOD5Nz0DUj6kn2mOmpr9XkrttjP4z630pCwnmL7IffNOemHYy8LETTCmYlm37Td3m6AtilNBeBpxkRBExhDrpflgKziPnOCkMInCn77dQBs/s72-c/068-Displaying+Bitmap+Images+Using+emWin-3.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-2221594173450191623</guid><pubDate>Sun, 01 Mar 2020 11:36:00 +0000</pubDate><atom:updated>2020-03-01T07:33:03.468-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Others</category><title>Getting Started with emWin using Code::Blocks</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Hello Everyone, In this blog post, I will show how to use the emWin simulation using CodeBlocks.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;emWin is a professional embedded GUI. emWin enables the creation of highly efficient, and high-quality graphical user interfaces on any embedded system. emWin empowers even resource-constrained microcontroller-based systems to run stunning interactive interfaces. emWin is independent of any target, and display.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Create stunning graphics with a powerful and easy to use API.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Use any display and any microcontroller.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Use any ANSI C/C++ development environment.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Experience the reliability of a proven graphics solution.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Embedded graphical user interface solution.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;emWin license is very costly, but they are offering a free simulation version, which is good for learning emWin framework purposes. Apart from this, we will be using the STM32F769i-DISCO board for the real demonstration of the emWin framework. And we should thank the ST and Segger partnership because they are offering a compiled library version of the emWin library for ST microcontrollers known as STemWin. So, in any case, we don&#39;t have to spend money on the license cost for emWin.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;To get started we need to have emWin simulation and CodeBlocks, as a first step download the emWin simulation package from the following link.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;a href=&quot;https://www.segger.com/downloads/emwin/&quot; target=&quot;_blank&quot;&gt;emWin Simulation Package&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;And next, we have to download the CodeBlocks for windows along with the compiler, there is a lot of version of CodeBlocks but we will use the one which is having the C/C++ (MinGW) compiler, and I will use the non-setup version, as I don&#39;t want to install any software. &lt;a href=&quot;http://www.codeblocks.org/downloads/26&quot; target=&quot;_blank&quot;&gt;CodeBlock can be downloaded by clicking on the following link&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The emWin sample project contains Visual Studio project files and CodeBlocks project files, we aren&#39;t using Visual Studio project file and will use only CodeBlocks, so, we have to open the *.cbp format file.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;After running the sample project, we will get the following output, this is the sample project from Segger emWin, which demonstrates all the Segger products on this virtual screen.&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbDoS76N4v9fti1P4hUnYgvq8G0FaQ-tRvPW_0WpPL5Nk-euhyphenhyphenzTKnCSIRgLlz8ulLwtBDDveIkgeEX-jxt6PT1OUtVG-z5exyRwS7xIu9qG6lXjI934gr8zw9AZVuikLPq0Xtzp04paU/s1600/emWin+Simulation.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;431&quot; data-original-width=&quot;567&quot; height=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbDoS76N4v9fti1P4hUnYgvq8G0FaQ-tRvPW_0WpPL5Nk-euhyphenhyphenzTKnCSIRgLlz8ulLwtBDDveIkgeEX-jxt6PT1OUtVG-z5exyRwS7xIu9qG6lXjI934gr8zw9AZVuikLPq0Xtzp04paU/s320/emWin+Simulation.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;emWin sample demo project&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This project is a little complex to start, as a starting point, we will remove all the project files from the &quot;Application&quot; folder and a new file with a simple code to just display some text on multi-line on this display, as shown on the image below.&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrwrqTelfNY_S3740iPYNJODjz-W9_jzycqA5KwNkR7q7b-Ndx8J5oZWAJjK6r_F20sgW6M28L02HbZxsa50ZwIsSqUtqcbSBcmEAmB1noQsbfX5lzQMEq8G-koqUHFrmEdgvDf8bnH2U/s1600/emWin+Custom+Program.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;439&quot; data-original-width=&quot;573&quot; height=&quot;244&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrwrqTelfNY_S3740iPYNJODjz-W9_jzycqA5KwNkR7q7b-Ndx8J5oZWAJjK6r_F20sgW6M28L02HbZxsa50ZwIsSqUtqcbSBcmEAmB1noQsbfX5lzQMEq8G-koqUHFrmEdgvDf8bnH2U/s320/emWin+Custom+Program.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Simple Program to display text&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The following program is used to display some simple text of the display.&lt;/span&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/84d3e4cc7eb89b67d3a408a0d238e4b2.js&quot;&gt;&lt;/script&gt;

&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Have a look at this video, to see the above steps.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/o8hN7a9fKbk/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/o8hN7a9fKbk?feature=player_embedded&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now as a next step, we will use some other APIs to display decimal values and change the text color and background color. The following program demonstrates the usage of these APIs.&lt;/span&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/xpress-embedo/6aa5fba7f14792c96df02eccf34f65f8.js&quot;&gt;&lt;/script&gt;

&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The following figure shows the output of the simulator.&lt;/span&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimnM8hPPeZ1mVor4A5OXmJjdmAswISn0iXRJ4uP-poxMwMb9_O8_OTsX8nZbXBgVQpRgwn2xDRQXSUu4A0pvJrXh-YOLWQHJCH3fN20mkesqlOlTKUVFnACahzUiXcWOqUXgCIhXDF0PQ/s1600/emWin+BASIC_NumDisplay.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;433&quot; data-original-width=&quot;552&quot; height=&quot;250&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimnM8hPPeZ1mVor4A5OXmJjdmAswISn0iXRJ4uP-poxMwMb9_O8_OTsX8nZbXBgVQpRgwn2xDRQXSUu4A0pvJrXh-YOLWQHJCH3fN20mkesqlOlTKUVFnACahzUiXcWOqUXgCIhXDF0PQ/s320/emWin+BASIC_NumDisplay.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Display Decimal Value with different color&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
</description><link>http://embeddedlaboratory.blogspot.com/2020/03/getting-started-with-emwin-using.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbDoS76N4v9fti1P4hUnYgvq8G0FaQ-tRvPW_0WpPL5Nk-euhyphenhyphenzTKnCSIRgLlz8ulLwtBDDveIkgeEX-jxt6PT1OUtVG-z5exyRwS7xIu9qG6lXjI934gr8zw9AZVuikLPq0Xtzp04paU/s72-c/emWin+Simulation.PNG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-875139489384552049</guid><pubDate>Sat, 01 Feb 2020 22:45:00 +0000</pubDate><atom:updated>2020-05-30T13:39:45.171-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DS1307</category><category domain="http://www.blogger.com/atom/ns#">Microchip</category><title>Real Time Clock (DS1307) Interfacing with PIC Microcontroller</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Hello Guys, first of all, I am really very sorry that I am not able to post anything for approximately 2 years. I was totally occupied with some other stuff and that&#39;s why I didn&#39;t get time to post anything, but during this time I have worked on a lot of different projects and learned a lot of tools and new technologies, which includes UML, Sparx EA, emWin, STM32, Git, etc.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In this post, I will start with a very simple and one of the most common topics in the field of Embedded System and is interfacing a real-time clock integrated circuit with the most common pic micro-controller.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In the past I have faced a lot of problems in handling the software (source code) written by me, every time I started a new project, I have to re-write the libraries again or copying pasting the libraries from one place to another. So, this time I will be more professional and will keep my all libraries on GitHub, and use these libraries into the project as a submodule. This will help in maintaining and updating the libraries and also issue fixing and feature enhancement all at the same place.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In this project, I am going to use RTC &lt;a href=&quot;https://amzn.to/2RRgxsq&quot; target=&quot;_blank&quot;&gt;DS1307&lt;/a&gt; and interface it with &lt;a href=&quot;https://amzn.to/37QNWJh&quot; target=&quot;_blank&quot;&gt;PIC18F4550&lt;/a&gt; microcontroller, and display the time and date fetched from the RTC.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;For this project, I have created three libraries and they are as follow:&lt;/span&gt;&lt;br /&gt;
*&amp;nbsp;&lt;a href=&quot;https://github.com/xpress-embedo/LCD16x2&quot; style=&quot;font-family: Verdana, sans-serif;&quot; target=&quot;_blank&quot;&gt;LCD Library&lt;/a&gt;&lt;br /&gt;
*&amp;nbsp;&lt;a href=&quot;https://github.com/xpress-embedo/I2C&quot; style=&quot;font-family: Verdana, sans-serif;&quot; target=&quot;_blank&quot;&gt;I2C Library&lt;/a&gt;&lt;br /&gt;
*&amp;nbsp;&lt;a href=&quot;https://github.com/xpress-embedo/DS1307&quot; style=&quot;font-family: Verdana, sans-serif;&quot; target=&quot;_blank&quot;&gt;DS1307 Library&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtG0b4HoBLG08Td6VGOi0y50Uk-Vsi_eaKUeauOn9NjYWxYWOV-sTC_jrXpATINIq4bHRX183qJkwh17UlbTkc18ssA6K6HsYqC9_i3a2TTe6eRbykxpO24kfsY3H_wDkAOc3ZIYGKGPU/s1600/DS1307_PIC.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;412&quot; data-original-width=&quot;596&quot; height=&quot;221&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtG0b4HoBLG08Td6VGOi0y50Uk-Vsi_eaKUeauOn9NjYWxYWOV-sTC_jrXpATINIq4bHRX183qJkwh17UlbTkc18ssA6K6HsYqC9_i3a2TTe6eRbykxpO24kfsY3H_wDkAOc3ZIYGKGPU/s320/DS1307_PIC.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The complete project can be downloaded or clones by &lt;a href=&quot;https://github.com/xpress-embedo/DS1307_PIC&quot; target=&quot;_blank&quot;&gt;clicking here&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;I have also done this similar type of task in the past and you can have a look at that by &lt;a href=&quot;https://embeddedlaboratory.blogspot.com/2016/07/ds1307pcf8523-interfacing-with.html&quot; target=&quot;_blank&quot;&gt;clicking here&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The software written in the older post is working but it is not maintainable, now I will try to move everything to GitHub, this will give the flexibility to maintain the software.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Please have a look at the video for the post and please subscribe to my YouTube channel also.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/YXwXs3ow4ls/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/YXwXs3ow4ls?feature=player_embedded&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The following is the snippet from the code from main.c file.&lt;/span&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #75715e;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * @file i2.c&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * @author xpress_embedo&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * @date 1 Feb, 2020&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * &lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * @brief Main File of the Project&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;#include &quot;main.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt;#include &quot;lcd_16x2.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt;#include &quot;ds1307.h&quot;&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;/* Local Variables */&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;uint32_t&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;millisecond&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;/* Local Function */&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;timer0_init&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;system_init&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;/* Start From Here*/&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt; 
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;lcd_msg[LCD_BUFFER_LEN]&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;};&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;uint32_t&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;timestamp&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;system_init();&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sprintf(lcd_msg,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;Embedded&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;LCD_Print_Line&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;lcd_msg);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sprintf(lcd_msg,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;      Laboratory&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;LCD_Print_Line&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;lcd_msg);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;LCD_Update();&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;Delay_ms(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
    &lt;span style=&quot;color: #75715e;&quot;&gt;// Task-1 (500ms)&lt;/span&gt;
    &lt;span style=&quot;color: #66d9ef;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;millis()&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;timestamp&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;500ul&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
      &lt;span style=&quot;color: #66d9ef;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;year,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;month,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;date,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;hour,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;minute,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;second;&lt;/span&gt;
      &lt;span style=&quot;color: #66d9ef;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sec_blink;&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;timestamp&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;millis();&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;second&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;DS1307_Read&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(DS1307_SEC);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;minute&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;DS1307_Read&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(DS1307_MIN);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;hour&lt;/span&gt;   &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;DS1307_Read&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(DS1307_HOUR);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;date&lt;/span&gt;   &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;DS1307_Read&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(DS1307_DATE);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;month&lt;/span&gt;  &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;DS1307_Read&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(DS1307_MONTH);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;year&lt;/span&gt;   &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;DS1307_Read&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(DS1307_YEAR);&lt;/span&gt;
      &lt;span style=&quot;color: #75715e;&quot;&gt;// The value Read are in BCD Format, which needs to be converted into char&lt;/span&gt;
      &lt;span style=&quot;color: #66d9ef;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sec_blink&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sec_blink&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;FALSE;&lt;/span&gt;
        &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sprintf&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(lcd_msg,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;TIME: %c%c:%c%c:%c%c&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; \
                 &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(hour),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(hour),&lt;/span&gt; \
                 &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(minute),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(minute),&lt;/span&gt; \
                 &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(second),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(second)&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
      &lt;span style=&quot;color: #66d9ef;&quot;&gt;else&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sec_blink&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;TRUE;&lt;/span&gt;
        &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sprintf&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(lcd_msg,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;TIME: %c%c:%c%c %c%c&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; \
                 &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(hour),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(hour),&lt;/span&gt; \
                 &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(minute),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(minute),&lt;/span&gt; \
                 &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(second),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(second)&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;LCD_Print_Line&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;lcd_msg);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sprintf&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(lcd_msg,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;DATE: %c%c/%c%c/%c%c&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; \
               &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(date),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(date),&lt;/span&gt; \
               &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(month),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(month),&lt;/span&gt; \
               &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2UpperCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(year),&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;BCD2LowerCh&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(year)&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;LCD_Print_Line&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;lcd_msg);&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;LCD_Update&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;();&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;/* Function Definitions */&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * @breif Initialize the system&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; */&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;system_init&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #75715e;&quot;&gt;// Initialize 1ms Timer&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;timer0_init&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;();&lt;/span&gt;
  &lt;span style=&quot;color: #75715e;&quot;&gt;// Initialize DS1307 and Start Time&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;DS1307_Init&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;();&lt;/span&gt;
  &lt;span style=&quot;color: #75715e;&quot;&gt;// Initialize LCD&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;LCD_Init();&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;Delay_ms(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * @brief Counts milliseconds till startup&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * @return This function returns the number of milliseconds elapsed till the &lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * system is powered up.&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; */&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;uint32_t&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;millis&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;uint32_t&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;time&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;GIE&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;time&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;millisecond;&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;GIE&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;time;&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * @brief Initialize Timer0 Module to generate 1ms interrupt&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; */&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;timer0_init&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #75715e;&quot;&gt;// Code Generated Using mikroC Timer Calculator&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;T0CON&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0x88&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;TMR0H&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0xD1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;TMR0L&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0x20&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;ENABLE_INT();&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;TMR0IE&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; * PIC18F Interrupt Service Routine&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt; */&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;__interrupt&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;ISR_ROUTINE(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;TMR0IF&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;TMR0IF&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;TMR0H&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0xD1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;TMR0L&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0x20&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;millisecond&lt;/span&gt;&lt;span style=&quot;color: #f92672;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;I am still working on improvements and with the use of a version control system like Git, hosting services like GitHub, I can keep my source code updated.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The Proteus simulation file is also updated in the &lt;b&gt;SIM &lt;/b&gt;folder and can be found under the GitHub project.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_tkwoSMHPVGvnaPGr-RfqEdxq8Gk34y1QYIH4hGy2iAggwgEOPQmGSB7FZil4it7AUMgmTzmXnJyJUNU1WD5KVB6B4AvjWv9moRfm3194OWKoW9vs5mluzAVvZACVipgGhyzSCj61iQw/s1600/065-RTC+Interfacing+with+PIC.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;726&quot; data-original-width=&quot;1280&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_tkwoSMHPVGvnaPGr-RfqEdxq8Gk34y1QYIH4hGy2iAggwgEOPQmGSB7FZil4it7AUMgmTzmXnJyJUNU1WD5KVB6B4AvjWv9moRfm3194OWKoW9vs5mluzAVvZACVipgGhyzSCj61iQw/s400/065-RTC+Interfacing+with+PIC.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Working Simulation Snapshot&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The above image illustrates the working of the simulation.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Thank You guys, in case of any question, please feel free to contact me.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://embeddedlaboratory.blogspot.com/2020/02/real-time-clock-ds1307-interfacing-with.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtG0b4HoBLG08Td6VGOi0y50Uk-Vsi_eaKUeauOn9NjYWxYWOV-sTC_jrXpATINIq4bHRX183qJkwh17UlbTkc18ssA6K6HsYqC9_i3a2TTe6eRbykxpO24kfsY3H_wDkAOc3ZIYGKGPU/s72-c/DS1307_PIC.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-1631271337060110561</guid><pubDate>Sun, 06 May 2018 18:56:00 +0000</pubDate><atom:updated>2018-05-06T12:22:45.917-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Microchip</category><title>Simulate USB Keyboard Keypress Using PIC Micro-controller</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Hello Everyone, today I am back with one exciting project of simulating key-press just using PIC micro-controller, the best thing is that, we are going to make a device similar to USB keyboard (USB HID Class Device).&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Project Idea&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Actually few of my friends works in a company, where they have started tracking the daily activities of employees using some dedicated software&#39;s. They track everything, like for how much time, they have spend on Skype chatting with friends, how much time they spend on actual work related tools like that.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;And based on the tracking details, the software calculates the actual amount of work done by employee and this information is also shared with their managers.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;They don&#39;t have any idea how to handle this situation, and from here I got an idea to make a simple device which looks like a USB keyboard to PC and sends some random commands pre-programmed in it, by this the tracking software&#39;s will think that the employee is doing their&amp;nbsp;work, but actually it&#39;s the device which is automatically sending the key-press to PC.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Video&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Watch the following video or read the post given below.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/8Z71UZuREjQ/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/8Z71UZuREjQ?feature=player_embedded&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;I am using the StartUSB Board for this purpose, which already have PIC18F2550 micro-controller and it also comes with USB HID Bootloader to upload the program without any programmer.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Having this board is not mandatory and you can use any PIC board of your choice having in-built USB support.&lt;br /&gt;With this StartUSB board and the program written in mikroC, I will simulate the key presses just like our USB Keyboard.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Follow the following steps.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;1) Open mikroC for PIC Micro-controller and create a blank project by selecting PIC18F2550 micro-controller.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;2) Once the project is created edit the configuration settings of the project as shown below.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCZDFiGRY2AaANaet_VJytrf7AI058ACamrNw4h6hUOVZxTG8A2AVX83RxQnZRcCxQDJUN7zscW4pNj3-03Fl3teBt6bA4JiJbZD26aeSBfsG26JK2YnliQVqqquqUbd8IiYxIKPoi9cQ/s1600/Config_1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;479&quot; data-original-width=&quot;811&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCZDFiGRY2AaANaet_VJytrf7AI058ACamrNw4h6hUOVZxTG8A2AVX83RxQnZRcCxQDJUN7zscW4pNj3-03Fl3teBt6bA4JiJbZD26aeSBfsG26JK2YnliQVqqquqUbd8IiYxIKPoi9cQ/s320/Config_1.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhibUaEdCwQpsQzSdUH-lmGIKx5WjHLCE1-1XQAcfCtvUSxk-pAS6OccylpCF-KtMNBilhRPWEPyZbU02VuEqtknkyUnnIZKYyCkwVQpgwmnXNXbBsE8gEQJwcg2F8UBdwmuVR6fEuUdbI/s1600/Config_2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;480&quot; data-original-width=&quot;811&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhibUaEdCwQpsQzSdUH-lmGIKx5WjHLCE1-1XQAcfCtvUSxk-pAS6OccylpCF-KtMNBilhRPWEPyZbU02VuEqtknkyUnnIZKYyCkwVQpgwmnXNXbBsE8gEQJwcg2F8UBdwmuVR6fEuUdbI/s320/Config_2.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The following things can be observed from the above set of configuration.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* PLL Prescalar Selection is set to Divide By 2, reason for this is that, PLL used 4MHz input, and StartUSB Board has 8MHz External Oscillator, that&#39;s why to feed it to input of PLL, it is divided by 2.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* USB Clock Source is selected from the Output of PLL divided by 2, which means 48MHz.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* Oscillator Mode is HC with PLL Enabled.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* USB Voltage Regulator is Enabled.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;3) mikroC for PIC comes with in-built USB HID and also has a tool to generate USB descriptor file. Tools -&amp;gt; HID Terminal&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb1s80Ww_389r2UVZDnTo6wKAQV9dSLY8qk46JAlsPsMNlAGIrWwePJ_saszRwFhB1iNqjRaTFiY4YcdbI1xGwNWneUs2__yZzT2wGRD2rNoDpjqvnHDf1Vp-W9-u9Cs7jgpZ8sedVhd4/s1600/USB+Descriptor.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;509&quot; data-original-width=&quot;490&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb1s80Ww_389r2UVZDnTo6wKAQV9dSLY8qk46JAlsPsMNlAGIrWwePJ_saszRwFhB1iNqjRaTFiY4YcdbI1xGwNWneUs2__yZzT2wGRD2rNoDpjqvnHDf1Vp-W9-u9Cs7jgpZ8sedVhd4/s320/USB+Descriptor.PNG&quot; width=&quot;307&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Use the above GUI based tool to change the settings or you can go ahead with the default settings also, just don&#39;t forget to enter/change the Vendor and Product Name, s&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ave the Descriptor file, this will automatically generate the *c code.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;4) N&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ext step you have to add this automatically generated descriptor file into your mikroC project. T&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;he Descriptor file generated is very basic in nature and is used for simple HID project. This file can&#39;t be used for USB Keyboard, so as a next step, we have&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;to modify the descriptor file to make the system work like the USB HID Keyboard.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;5) Download the USB HID Tool by clicking on this &lt;a href=&quot;http://www.usb.org/developers/hidpage/dt2_4.zip&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;6) Open the tool and then click on File -&amp;gt; Open and open the keyboard.hid file.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3AFIdhMmJ46Dx1EydT_MmF3BxFFN7_1IekJTlaxN3Wz99HwSOxA5ieGFjwZs-NF55OClQG7Z-srcFqkiawcuLA6q_rKX_DBvhmGP1lRDEBxRK31dMnDuxEwFY1CiXXKtdmxeHRFgalWo/s1600/USB+Keyboard+Report+Descriptor.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;469&quot; data-original-width=&quot;1024&quot; height=&quot;145&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3AFIdhMmJ46Dx1EydT_MmF3BxFFN7_1IekJTlaxN3Wz99HwSOxA5ieGFjwZs-NF55OClQG7Z-srcFqkiawcuLA6q_rKX_DBvhmGP1lRDEBxRK31dMnDuxEwFY1CiXXKtdmxeHRFgalWo/s320/USB+Keyboard+Report+Descriptor.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The above image clearly shows the &quot;Report Descriptors&quot; to be used for USB HID Keyboard, now we have to modify the mikroC automatically generated descriptor file with the above values. (This is a easy task, just double check that you have entered all values correctly)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;7) The basic setup is&amp;nbsp;done, now it&#39;s time to copy and the library which I have written to send the key press to PC using the StartUSB board.&lt;br /&gt;The library only consist of the following three functions.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #272822; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.1em 0.1em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #75715e;&quot;&gt;// Function Prototypes&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;key_emulator_init&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;key_emulator_send&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;key_emulator_text&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #66d9ef;&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;color: #f92672;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;text&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;key_emulator_init: This function initializes HID Communication Library.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;key_emulator_send: This function sends single key-press to the PC.&lt;br /&gt;key_emulator_text: This function is to send multiple key-press to PC, at the bottom level this function uses the above function.&lt;br /&gt;The following is the main program.&lt;/span&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #272822; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.1em 0.1em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #75715e;&quot;&gt;#include &quot;keypress_emul.h&quot;&lt;/span&gt;

&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;interrupt&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;()&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #75715e;&quot;&gt;// USB Servicing is done inside the interrupt&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;USB_Interrupt_Proc();&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;

&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;()&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #75715e;&quot;&gt;// Initialize USB for Keypress Emulation&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_init();&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;/*&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;Keyboard Emulator Program&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;abcdefghijklmnopqrstuvwxyz&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZ&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;0123456789&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;`~!@#$%^&amp;amp;*()_+-=,./;&#39;[]&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&amp;lt;&amp;gt;?:&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;{}|&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;################################n&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;*/&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #75715e;&quot;&gt;// Write a Simple Program&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;void main()&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;{&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;printf(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;Hello World&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;key_emulator_text(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;}&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;\r&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;)&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;After flashing the above program in the StartUSB board, i quickly opened the Notepad, to check what keys are pressed, and the output of the program is as follow.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEp9Dzh3WOuBoFCySIHpCMiSykHZpVBmCm0GcLEJrAFhwUajVT1FOvQuA4gzKf0riJ3l2SKc_1QQFpum8IbUPhl4v3wcjUQLGUUBQvGuvaQWr4iTVAzWSSAvqDaYhyphenhyphenRpTIc8E2D3-cXec/s1600/Output.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;384&quot; data-original-width=&quot;757&quot; height=&quot;161&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEp9Dzh3WOuBoFCySIHpCMiSykHZpVBmCm0GcLEJrAFhwUajVT1FOvQuA4gzKf0riJ3l2SKc_1QQFpum8IbUPhl4v3wcjUQLGUUBQvGuvaQWr4iTVAzWSSAvqDaYhyphenhyphenRpTIc8E2D3-cXec/s320/Output.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;You can also check the device information in the device manager, it will be listed as HID Input Device, the following image was taken from HID Terminal Information Setting, and as can be seen clearly that the same values are appearing which we have specified in HID Descriptor tool.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcvPJqKJ8jDBA-HE2AVIzJCz_ObZ4w-Kdji4W3P9WQ9lCDln8hhxZge3AwXCB22_utcI9pTIAnBsknguxaJf5YBiIdfsAlF37z6TjbAOBqAsYf9HVFwcbZ4NwXXKiJWabms_hU-gUh6oA/s1600/Device+Information.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;602&quot; data-original-width=&quot;508&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcvPJqKJ8jDBA-HE2AVIzJCz_ObZ4w-Kdji4W3P9WQ9lCDln8hhxZge3AwXCB22_utcI9pTIAnBsknguxaJf5YBiIdfsAlF37z6TjbAOBqAsYf9HVFwcbZ4NwXXKiJWabms_hU-gUh6oA/s320/Device+Information.PNG&quot; width=&quot;268&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Note:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;You have already read why I worked on this project, but it&#39;s not like, that I want to help my friends to cheat the Software Tracking tool, but the ultimate aim of mine is to check if the Tracking Tool will be able to detect such kind of devices or not, right now it&#39;s not able to detect this device and treating like that employee is working continuously.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This project can be used in the other areas such as:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;&lt;b&gt;Automation:&lt;/b&gt;&lt;/i&gt; Certain repetitive things can be automated by this project and that will help someone to execute their day to day task effortlessly.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;i style=&quot;font-weight: bold;&quot;&gt;USB Keyboard: &lt;/i&gt;If keys are connected to this device then a customized USB keyboard can also be created using this simple project as base project.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;And now comes the most important thing, :-) the complete source code.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;a href=&quot;https://github.com/xpress-embedo/Keypress_Emulator&quot; target=&quot;_blank&quot;&gt;Click Here&lt;/a&gt; to get the complete source code from GitHub.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://embeddedlaboratory.blogspot.com/2018/05/simulate-usb-keyboard-keypress-using.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/8Z71UZuREjQ/default.jpg" height="72" width="72"/><thr:total>9</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6802523224595585339.post-2878381826416122849</guid><pubDate>Sun, 29 Apr 2018 11:07:00 +0000</pubDate><atom:updated>2018-04-29T04:07:24.253-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><title>Displaying Images on 3.2 Inch TFT using Arduino</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In this post, I will show you guys how to display images on 3.2 Inch TFT Using Arduino Mega as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh28vsn2ac-vuqWQ4HB1Iw3xo2cOg5XPQJVWSOZ2k9r4EAs-IGtmlQw_qpBBF2cJlqVRV7luRLtfLSHZOajd4Ju-4do0fmL9N8pBtCWpEHuG3vqXTVKxvxLy7Pumwvcc7HQCdiw8cNgH0Y/s1600/WIN_20180429_12_25_12_Pro.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;900&quot; data-original-width=&quot;1600&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh28vsn2ac-vuqWQ4HB1Iw3xo2cOg5XPQJVWSOZ2k9r4EAs-IGtmlQw_qpBBF2cJlqVRV7luRLtfLSHZOajd4Ju-4do0fmL9N8pBtCWpEHuG3vqXTVKxvxLy7Pumwvcc7HQCdiw8cNgH0Y/s320/WIN_20180429_12_25_12_Pro.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Avengers Image Display on TFT&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;You have two choices either watch the following video tutorial or read the post given below.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/SecSP_2p1LM/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/SecSP_2p1LM?feature=player_embedded&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Prerequisite&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Download the following three libraries which are required for this project.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* UTFT or Universal TFT Library&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* SdFAT Library&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;* UTFT_SdRaw Library&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;UTFT Library&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This library contains all the API&#39;s to initialize the TFT controller and display data on the TFT screen, this library also comes with a tool which is used to convert the images into *.c code and *.raw file. This tool can also resize the images according to the size of the TFT.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Reason for choosing *.raw image file format as compared to other *.bmp, *.jpeg, *.png etc format is to speed-up the process of displaying images, as other formats requires converter or decoder which increases the code size and processing time on Arduino devices.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This tool is available&amp;nbsp;under the following path.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #351c75; font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;\Arduino\libraries\UTFT\Tools\ImageConverter565.exe&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;a href=&quot;http://www.rinkydinkelectronics.com/library.php?id=51&quot; target=&quot;_blank&quot;&gt;Click Here to download the library.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;SdFat Library&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This library is used to read and write data/files on the Sd Card.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;UTFT_SdRaw&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This library is used to display raw format images from Sd Card on&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;TFT.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;NOTE:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;One more important thing i want to tell you guys, that do not use tinyFAT library, it is really good but only&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;for FAT16 formatted SD card, and in today&#39;s world we usually have 8GB/16GB/32GB/64GB/128GB memory cards, and this is the reason it doesn&#39;t work on Sd card cards above 2GB size.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;I have downloaded posters of most of the characters from the movie Avengers:Infinity War and as a first step these all images will be converted into *.raw format using the tool described above. The size I am going to use is 320X240 as the TFT I have with me is of 3.2 Inch.&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp7JnQyWTFqq9qmNyz-OacQnZyvmowJNUTTzeeSe4SlsN5txpsuwdTpL-h_pS6XSDWX2DKtwletQW4DhW_lwBSyChR2EUUF-wUWvuAr50UpxRGA8W4l99ipRPyjK2dYRpCA_q-ZyLVacU/s1600/Tool.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;726&quot; data-original-width=&quot;1024&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp7JnQyWTFqq9qmNyz-OacQnZyvmowJNUTTzeeSe4SlsN5txpsuwdTpL-h_pS6XSDWX2DKtwletQW4DhW_lwBSyChR2EUUF-wUWvuAr50UpxRGA8W4l99ipRPyjK2dYRpCA_q-ZyLVacU/s320/Tool.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Image to RAW File&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Once all the files are converted, copy all the *.raw format files onto your memory card, and now it&#39;s time to start writing the Arduino code to display images on 3.2 Inch TFT.&lt;/span&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #272822; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #75715e;&quot;&gt;#include &amp;lt;SPI.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt;#include &amp;lt;SdFat.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt;#include &amp;lt;UTFT.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #75715e;&quot;&gt;#include &amp;lt;UTFT_SdRaw.h&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #75715e;&quot;&gt;#define SD_CHIP_SELECT  53  // SD chip select pin(Arduino Mega)&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;SdFat&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;sd;&lt;/span&gt;

&lt;span style=&quot;color: #f8f8f2;&quot;&gt;UTFT&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;myGLCD&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(ILI9341_16,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;38&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;41&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;UTFT_SdRaw&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;myFiles&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f92672;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;myGLCD);&lt;/span&gt;

&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;setup&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;()&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;Serial.begin(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;115200&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;mysd&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f92672;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;mysd)&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
    &lt;span style=&quot;color: #66d9ef;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f92672;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;sd.begin(SD_CHIP_SELECT,&lt;/span&gt; &lt;span style=&quot;color: #f8f8f2;&quot;&gt;SPI_FULL_SPEED))&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;Serial.println(F(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;Card failed, or not present&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;));&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;Serial.println(F(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;Retrying....&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;));&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
    &lt;span style=&quot;color: #66d9ef;&quot;&gt;else&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;mysd&lt;/span&gt; &lt;span style=&quot;color: #f92672;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;;&lt;/span&gt;
      &lt;span style=&quot;color: #f8f8f2;&quot;&gt;Serial.println(F(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;Card initialised.&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;));&lt;/span&gt;
    &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;Serial.println(F(&lt;/span&gt;&lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;Initialising LCD.&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;));&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myGLCD.InitLCD();&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myGLCD.clrScr();&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;

&lt;span style=&quot;color: #66d9ef;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #a6e22e;&quot;&gt;loop&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;()&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;inifinity_war.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #66d9ef;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;black_panther.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;black_widow.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;bucky.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;captain_america.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;doctor_strange.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;drax.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;falcon.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;gamora.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;groot_rocket.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;hulk.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;iron_man.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;mantis.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;scarlet_witch.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;shuri.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;spider_man.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;star_lord.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;thor.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;vision.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;myFiles.load(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;320&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #e6db74;&quot;&gt;&quot;war_machine.RAW&quot;&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ae81ff;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #f8f8f2;&quot;&gt;delay(&lt;/span&gt;&lt;span style=&quot;color: #ae81ff;&quot;&gt;4000&lt;/span&gt;&lt;span style=&quot;color: #f8f8f2;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #f8f8f2;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The above program is really simple and is divided into three main parts.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;* SD Card Initialization&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;* TFT Initialization (TFT I am using is based on ILI9341 controller and is operated using 16-bit mode, this is the reason I used&amp;nbsp;&lt;/span&gt;ILI9341_16&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;while creating object for TFT, make sure to update it as per your TFT controller).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;* The last step is to display the images from SD card using function load.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After running the following program, we see the following output on TFT display.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_1FPsmwUEBQ-5JHxNVhgNU06ftK8D2OTK6XJV-9JmDt4tez5psk5mByDJuBJ9wVOk1WnV2_0zHrC3FeDFQhT7HVMqIBk8OISPEL1TW8rP-dtUwpOl_HnN_3wB9yHTeTbxfNt1uObLnvs/s1600/vlcsnap-error007.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;900&quot; data-original-width=&quot;628&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_1FPsmwUEBQ-5JHxNVhgNU06ftK8D2OTK6XJV-9JmDt4tez5psk5mByDJuBJ9wVOk1WnV2_0zHrC3FeDFQhT7HVMqIBk8OISPEL1TW8rP-dtUwpOl_HnN_3wB9yHTeTbxfNt1uObLnvs/s320/vlcsnap-error007.png&quot; width=&quot;222&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjScMUmkpt2vLGn3nABdLYf3lNoeiTCmHi4Z78jMDS9gk6JYzEAhOa5u5ZX1jk-yeas6lV1a9wmYD162D3eT73QyNPGRYoZGfWkX82X0chsHDJn3FPRPJYrOstZd0Dp7YLtp-kHFJSR8js/s1600/vlcsnap-error112.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;896&quot; data-original-width=&quot;626&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjScMUmkpt2vLGn3nABdLYf3lNoeiTCmHi4Z78jMDS9gk6JYzEAhOa5u5ZX1jk-yeas6lV1a9wmYD162D3eT73QyNPGRYoZGfWkX82X0chsHDJn3FPRPJYrOstZd0Dp7YLtp-kHFJSR8js/s320/vlcsnap-error112.png&quot; width=&quot;223&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXPfJzCEQ9WjRvpi1Q3_yQ2l7M6BRZBRhmtpbKXckyI0azyiXzBZVAPozs0ZtUjr8M5dzOjlRXO_UWYM-7Gl8e4NRzj3pVGIZvjwvwWBjiFj4U7deB6p7PNepWq63sNPxsiFfi1EwUjHA/s1600/vlcsnap-error244.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;894&quot; data-original-width=&quot;630&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXPfJzCEQ9WjRvpi1Q3_yQ2l7M6BRZBRhmtpbKXckyI0azyiXzBZVAPozs0ZtUjr8M5dzOjlRXO_UWYM-7Gl8e4NRzj3pVGIZvjwvwWBjiFj4U7deB6p7PNepWq63sNPxsiFfi1EwUjHA/s320/vlcsnap-error244.png&quot; width=&quot;225&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGiUcHq9jtgd6ZJ1uU9Sz8lS9MSDfk1DxasHHTHol98WdL_7N2iACNzXqtSKYg_WV4HM6pkWjn-q5ULD0VWGglcxibuuDC3AF_oHOoc3Si0f5VLph0FTDcPfXnQ3i-gmMmCS3kh0sQT2U/s1600/vlcsnap-error412.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;904&quot; data-original-width=&quot;630&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGiUcHq9jtgd6ZJ1uU9Sz8lS9MSDfk1DxasHHTHol98WdL_7N2iACNzXqtSKYg_WV4HM6pkWjn-q5ULD0VWGglcxibuuDC3AF_oHOoc3Si0f5VLph0FTDcPfXnQ3i-gmMmCS3kh0sQT2U/s320/vlcsnap-error412.png&quot; width=&quot;223&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUXTMuOu7WFMsJvTyMDQz5mNV5RRya34hdf6ueJxzeuSGhcBgyWirhILizwdsCXCDpi-_JlJrpHcN5urD-JeSQKFYfrewa356u6XRs-pf7G_7sRoQivFXrazGQOWC12NOdnOUy4QP_nsU/s1600/vlcsnap-error507.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;912&quot; data-original-width=&quot;646&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUXTMuOu7WFMsJvTyMDQz5mNV5RRya34hdf6ueJxzeuSGhcBgyWirhILizwdsCXCDpi-_JlJrpHcN5urD-JeSQKFYfrewa356u6XRs-pf7G_7sRoQivFXrazGQOWC12NOdnOUy4QP_nsU/s320/vlcsnap-error507.png&quot; width=&quot;225&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm6XvSj-obGIWZCZokkXnG-xnfhYeLsE3s7ie90mzbSb4xGLxLtjqfuRiwNXvD6xwP1xuwrvZqExB9zreJbb0FSW9dlL1vZvl1Liz5r3Jr2QVXZzM5m_8xZCaF2ksN9m-0dH3HgzdSW5w/s1600/vlcsnap-error857.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;892&quot; data-original-width=&quot;622&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm6XvSj-obGIWZCZokkXnG-xnfhYeLsE3s7ie90mzbSb4xGLxLtjqfuRiwNXvD6xwP1xuwrvZqExB9zreJbb0FSW9dlL1vZvl1Liz5r3Jr2QVXZzM5m_8xZCaF2ksN9m-0dH3HgzdSW5w/s320/vlcsnap-error857.png&quot; width=&quot;223&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6j97HUXN218kBlFLKPO25hOJtrJz1wvyrGFkmF7kFNJr2jkb9SmiM06vIJbtJPlRJUI17bK6AHrHG73ylETiGgkfqUohP0dVTBTY_-y9Qa8cMEEyWLOepKTgqaT8p5XEzgTgNZr1GuI0/s1600/vlcsnap-error991.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;896&quot; data-original-width=&quot;620&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6j97HUXN218kBlFLKPO25hOJtrJz1wvyrGFkmF7kFNJr2jkb9SmiM06vIJbtJPlRJUI17bK6AHrHG73ylETiGgkfqUohP0dVTBTY_-y9Qa8cMEEyWLOepKTgqaT8p5XEzgTgNZr1GuI0/s320/vlcsnap-error991.png&quot; width=&quot;221&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;a href=&quot;https://www.youtube.com/redirect?redir_token=in8aB9Bof0k2IIuDgnQfSV_bzAZ8MTUyNTA4NTUzNUAxNTI0OTk5MTM1&amp;amp;q=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D10CYaEh836Z2VFlFQ67YBCVWhr2NSC5Zx&amp;amp;v=SecSP_2p1LM&amp;amp;event=video_description&quot; target=&quot;_blank&quot;&gt;Click Here&lt;/a&gt; to download the complete image set and Arduino Program.&lt;/span&gt;&lt;/div&gt;
</description><link>http://embeddedlaboratory.blogspot.com/2018/04/displaying-images-on-32-inch-tft-using.html</link><author>noreply@blogger.com (Embedded Laboratory)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh28vsn2ac-vuqWQ4HB1Iw3xo2cOg5XPQJVWSOZ2k9r4EAs-IGtmlQw_qpBBF2cJlqVRV7luRLtfLSHZOajd4Ju-4do0fmL9N8pBtCWpEHuG3vqXTVKxvxLy7Pumwvcc7HQCdiw8cNgH0Y/s72-c/WIN_20180429_12_25_12_Pro.jpg" height="72" width="72"/><thr:total>3</thr:total></item></channel></rss>