Video, part two, implementing Wi Fi manager and ot update in projects. In this video, we will continue with the weather station project and add the OT update feature on top of the Wi Fi manager. Finally, we will show an example auto update to change the functionality of the weather station. Let's get right into it. Open the final code of the last video, where we incorporated the Wi Fi manager to our weather station. Here we will implement the second OTA update method, which is the web server based ot update.
So open the Enable web server rta.io no code on a side by side window with the previous code. Just like in the last video, we will incorporate the web server ot update feature to the weather station project. We have already discussed the web server ot update code in detail in this section. Thus, let us start combining both these codes together. First, we have to copy these instructions to import the libraries for the web server ot a to our project. The import WiFi dot h library is already inputted in our project.
So except that we will copy all these libraries to our project. Next, we will take all these instructions till the setup loop, exit the SSID and password variables and paste it in our project code. As we are using the Wi Fi manager, we will be configuring our own SSID and password. This is why we removed those instructions. Next, we will clone the necessary instructions from this setup loop to the setup loop of our project code. We will be copying the instructions that handle the mdns and HTTP based OTA update to our project code like shown here.
Don't forget to add Add the server dot begin function to the end of the setup loop. Finally, we need to add the server dot handle client as the first instruction inside the void loop. If you don't want to copy across codes, I have provided the complete code in the resources section with the name, weather station factory code dot i n o. Now upload this factory code to your boat. After flashing the factory code, there is no need for the USB connection. Instead, let's connect a battery.
We typically use a 3.7 volt single cell LiPo battery for the sparkfun ESP 32. If your battery supports jst connector, then you can directly connect it to the jst connector on the boat. If you have just a compatible battery without the connector, please connect the positive lead of the battery to the V back pin of the sparkfun ESP 32 thing and negatively to the ground. Remember that if your LiPo battery runs out of juice, you can charge it by connecting the USB cable from a USB power source, internal battery charger I see called MCP 73831 uses the USB power to charge the LiPo battery. Now imagine that this breadboard prototype is the final product you intend to deliver to customer. The first time the customer boots up the project, he or she would want to connect the board to their WiFi network to receive constant OTA updates.
The Wi Fi manager kicks in and the ESP config AP access point is created. Now the user will connect to this network to enter in his or her wife for network credentials. After that, the project will auto connect to the Wi Fi network. And on the OLED the SSID of the network to which it is connected to is shown Once connected, the board will create a web server for the OTA update to be commenced. First, let us create a useful OTA update for our current weather station project. Download the weather station OTA update dot INR code from the resources and load it in the Arduino ID scroll down to the void loop.
And you can see that we have added a new instruction here. To calculate the heat index and save it in a variable of data type float, just like we did in for the humidity and temperature values, we converted the float to a string and at the end, added these instructions to display the heat index on the OLED display. The heat index is a measure of how hot it really feels when relative humidity is factored with the actual air temperature. Now, let's export the compiled binary file for sending it to the user. The user on receiving This file will log into the OTA update web server and upload the update over the air just like we did in the web server auto update video of the section. Once the update reaches hundred percent, you can see that the OLED displays the heat index as well.
Now I will give you an activity to try, you have to implement the cloud based OTA update with Wi Fi manager to this project. If you successfully complete this activity, it would allow you to remotely do an OTA update with zero end user interaction. I hope you will be able to implement this successfully. We have come to the end of this video summary. In this video, we have covered the following topics, adding OTA update feature to weather station project demo of the weifare manager and OTA update implementation in the weather station project. Section summary In this section, we have covered the following topics, what is ot a programming, how to ot updates happen in the ESP 32 how to implement basic ot programming in the sparkfun ESP 32 thing implementing ot updates through a web server in the sparkfun ESP 32.
Implementing cloud based ot updates in a sparkfun ESP 32 thing. Implementing the Wi Fi manager library in the sparkfun ESP 32 thing, but one implementing weifare manager and ot update in projects, part two, implementing Wi Fi manager and OTA update in projects. In the next section we will learn about free arctos on the ESP 32