
This tutorial should take approximately 30 minutes.
To facilitate easy navigation of the code, it is essential to keep it organised from the outset. We will achieve this by utilising the Arduino tabs. In the Arduino software, there is no need to code additional links to the various tabs (files) as they automatically connect. However, this functionality does not necessarily apply to other IDEs such as Visual Studio.
The first tab on the left side is always the main program tab. This tab will be used to store libraries, global variables, the startup loop, and the main program loop. In the future, we will create several tabs that each highlight a different feature of the program. This organisation will become clearer as we begin structuring the code and in subsequent tutorials.
Save the existing ElegantOTA example
Go to File → Save As and choose a secure saving location, such as OneDrive. Save the file as “LaserTag_0.1”.

Delete code that is not needed
Delete the following comments as they are no longer needed:

Remove unwanted Code
Since this code will only be used for the ESP32, we can eliminate any library calls for the ESP8266.



Create a new tab for OTA
Select the meatball menu and choose “New Tab.” Name the new tab “OTA,” and the “.ino” extension will appear automatically.


Move OTA functions to OTA tab
Ensure that you do not duplicate these functions. They must be moved, not copied, from the LaserTag tab to the OTA tab.

Create an setupOTA() Function
Move the code from the LaserTag tab to the OTA and incorporate it into the setupOTA() function.

Call the setupOTA() Function from the setup loop
Add “setupOTA();” to the setup loop

Test to see if it compiles
Optimise Code
The current code requires a WiFi connection to be established in the setup loop before executing any other code. While this is suitable for devices that should operate only when connected to WiFi, the laser taggers need to function regardless of WiFi access. Below, you can see how the code enters a continuous loop until a connection is established.

To address this issue, we will shift from waiting for a connection to monitoring changes in the connection status. The previous connection state will be stored as a boolean variable named “connected,” with a default value of “false.” Additionally, we will create a function called checkWiFi() within the main loop.


The checkWiFi() function will be located in the OTA tab, as all WiFi functions are housed there.

Upload the software to the ESP32 using either the elegantOTA method or a USB cable.
Christian Content
In our digital age, we’ve become accustomed to the convenience of “Over The Air” updates. Our devices receive new features, improvements, and corrections to flaws we might not have even known existed. But as you may be aware, it’s not always smooth sailing, as those using Windows operating systems are aware of the dreaded windows update, that requires us to reboot our computers at the worst of times. This process of renewal offers a beautiful parallel to how God works in our lives, transforming us to become more like his son.
The apostle Paul writes in Romans 12:2, “Do not conform to the pattern of this world, but be transformed by the renewing of your mind. Then you will be able to test and approve what God’s will is—his good, pleasing and perfect will.” Like devices receiving OTA updates, we too are designed for continuous renewal and growth. Our spiritual “firmware” needs regular updates from the ultimate Developer.
Consider how an OTA update works: it requires connectivity, it happens in the background while we continue our daily activities, and we often only realize the full benefits after the update is complete. Similarly, our spiritual renewal requires:
Connection to the Source: “I am the vine; you are the branches. If you remain in me and I in you, you will bear much fruit; apart from me you can do nothing.” (John 15:5). Just as our devices need connectivity to receive updates, we need constant communion with God.
Background Processing: “for it is God who works in you to will and to act in order to fulfill his good purpose.” (Philippians 2:13). Even when we don’t perceive it, God is working in the background of our lives.
Patience During Installation: “But those who hope in the Lord will renew their strength. They will soar on wings like eagles; they will run and not grow weary, they will walk and not be faint.” (Isaiah 40:31). The update process requires patience, and trusting that God’s way is the best way, and this can be difficult, but the results are worth waiting for.
Enabling the Installation: “You were taught, with regard to your former way of life, to put off your old self, which is being corrupted by its deceitful desires; to be made new in the attitude of your minds; and to put on the new self, created to be like God in true righteousness and holiness.” (Ephesians 4:22-24). Enabling the installation can be painful, as it temporarily takes the device offline while the update occurs. Similarly, when we let go of the previous version of ourselves, we must relinquish our old desires and choose to live for God. It requires effort on our part to receive the awaited upgrade.
I wonder if you are ready for an update.