Laser Tag S01 – OTA

Love Jesus, Love Code

This should take about 1-2hours to complete

The components of the laser tag gun have been designed in a way that you don’t have to keep on opening up the gun to recharge the batteries or to change the code.

The code can be updated Over The Air (OTA). First we need the program to be installed on the NodeMCU chip, and then that program will need to remain within our programs to allow subsequent OTA upgrades.

I have used the OTA version built into the Arduino software, but have found it quite unreliable. I am using AsyncElegantOTA method for uploading software. I will be taking you through the bare bones to get our project working, but feel free to look over more detailed instructions at: https://randomnerdtutorials.com/esp8266-nodemcu-ota-over-the-air-arduino/

Step 1 – Install Arduino Software

Download the Arduino software from https://www.arduino.cc/en/software. Choose the correct version for your computer.

Step 2 – Intall AsyncElegantOTA Library

Install AsyncElegantOTA library using the Arduino Library Manager. In the Arduino software, go to Tools –> Manage Libraries. The Library Manager will appear. Start typing AsyncElegantOTA into the search bar. You may only need to type the first few letters before the library appears. Click on Install.

Step 3 – Install ESPAsyncWebServer & ESPAsyncTCP

Download the two files below:

In your Arduino software, go to Sketch –> Include Library –> Add .ZIP Library…

The upload will be very fast. You can check if it worked by going back to Sketch –> Include Library, and you will see it under the heading contributed libraries.

Step 4 – Install the esp8266 board

  • In the Arduino IDE, got to File –> Preferences
  • Add http://arduino.esp8266.com/stable/package_esp8266com_index.json to the Additional Boards Manager URLs: If you have additional URLs, they can be separated by a comma.
  • In the Arduino IDE go to Tools –> Board: ****** –> Boards Manager…
  • search for esp8266 (again, you might just need to enter the first few characters)
  • Install
  • Make sure you change the board you are using by going to tools –> Board –> ESP8266 –> NodeMCU 1.0

More information can be found at https://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/

Step 5 – Download and open the sketch

Download the file:

Open the sketch in the Arduino software, and change the ssid and password, both to “lasertag”.

Step 6 – Plug in and upload

  1. Check the ports currently available to the Arduino IDE by clicking on Tools –> Port (they will be under the heading serial ports).
  2. Plug your NodeMCU controller into your computer using a USB cable. You should notice an additional port appear. That additional port will be your NodeMCU.

3. Upload the sketch by clicking on the right arrow icon on the tool bar. It may take a few minutes to compile and update

Step 7 – Set up a wireless network

While you could get the NodeMCU board to connect to any WIFI network by changing the SSID and password, I will be providing you with a file later on in the tutorial that has fixed network settings. So to make things run smoothly, you will need to create a network with the following credentials:

  • SSID = lasertag
  • password = lasertag

The easiest way is to use a hotspot function on your computer. Windows 10 has a built-in hotspot function. Search for Mobile Hotspot in the Windows 10 Search bar and select Edit and change the credentials. Then, ensure Share my Internet connection with other devices is selected.

You will be able to see any devices such as your NodeMCU controller connect on this helpful windows screen.

Step 8 – Connect Wirelessly to your NodeMCU and update the firmware

  • If you are using Windows 10, you will see the IP address of the board on the Mobile Hotspot screen as above
  • Put the IP address of the board into a web browser with a trailing /update.

Identify your Arduino on the Network

You may have noticed that you access your Arduino has a device name which will be something like ESP-2E407F. This can be found once your device connects to your computer over wifi in the hotspot settings page. When you have lots of devices on the network it can be difficult to work out which device you are working on. You can allocate a name to it by using some additional code between WiFi.mode() and Wifi.begin().

Change “Prototype1” with your name or something that identifies your device.

  WiFi.mode(WIFI_STA);
  WiFi.hostname("Prototype1");
  WiFi.begin(ssid, password);

Try a demo game file

  • Download the lasertag file below, unzip and upload into the ElegantOTA screen
  • The file above is a taste of what is to come. It is a little buggy, but hopefully you will learn how to put together such a program by following along in this blog.
  • If you open a web browser with the IP address of the NodeMCU controller, you will be able to change your player ID and Team Id.

Christian Content

To get these laser tag guns working, we first took an old gun, replaced the insides, and then we needed to program those insides. To start with, we needed to physically transfer the program over to the controller. But once we had the OTA software installed, we could then update the devices Over The Air.

If you wanted to play laser tag with your guns, they would need to be made new. If the insides of the gun were not made new, if they still behaved like the original gun, then it does not belong in the laser tag game. It cannot shoot anyone or be shot itself. It is as if it were a dead gun. It needs to be reborn.

The Bible talks about people needing to be reborn as well. And just like a gun that is not reborn does not belong in the laser tag game, a person who is not reborn does not belong in God’s kingdom. The Bible says:

5 Jesus answered, “I assure you: Unless someone is born of water and the Spirit, he cannot enter the kingdom of God. 6 Whatever is born of the flesh is flesh, and whatever is born of the Spirit is spirit. 7 Do not be amazed that I told you that you must be born again. 8 The wind blows where it pleases, and you hear its sound, but you don’t know where it comes from or where it is going. So it is with everyone born of the Spirit.”

John 3:5–8 (HCSB)

To enter the kingdom of heaven, you must be made new. You must be “born again” of water and spirit. Everyone has been born or water, this is your natural birth. But not everyone is born of the spirit. Being born of the Spirit is the beginning of changing who you are – you are now someone who belongs to God, and belongs to his Kingdom.

When you hear the great news about Jesus, and believe this message, you are sealed with the Holy Spirit. This is your second birth, the birth of the Spirit. The Bible says:

13 When you heard the message of truth, the gospel of your salvation, and when you believed in Him, you were also sealed with the promised Holy Spirit.

Ephesians 1:13 (HCSB)

Furthermore, just like the laser tag guns can now be updated Over The Air (OTA), and we can keep on perfecting the software to make them perform increasingly better. Christians who have the Spirit to are being changed by the Holy Spirit, to become more like the perfect person (Jesus). The Bible talks about this as being transformed into the same image of the Lord Jesus with increasing glory.

18 We all, with unveiled faces, are looking as in a mirror at the glory of the Lord and are being transformed into the same image from glory to glory; this is from the Lord who is the Spirit.

2 Corinthians 3:18 (HCSB)

Our laser tag guns do not keep updating themselves automatically with the OTA updates. We have to do the hard work of coding, or using written instructions, in order to perform the OTA. God also uses written instruction to help perform OTA updates on Christians. Put another way, God uses his Bible in conjunction with the Holy Spirit to change and transform us. You can see the importance of the Bible (or Scriptures) as quoted below:

16 All Scripture is inspired by God and is profitable for teaching, for rebuking, for correcting, for training in righteousness, 17 so that the man of God may be complete, equipped for every good work.

2 Timothy 3:16–17 (HCSB)

Pray that we would accept God’s word, and keep reading his word, and that the Holy Spirit would do it’s work in transforming us to become more like Jesus.

Leave a Reply