Please note, I do not make any commission from you buying anything linked here.
I have included links to the source files for each piece of software needed, as well as copies that are held on my server. I did this so that if any of the links no longer work, the files are still available.
The first time you plug in the ESP8266, you will need to install the correct drivers. What you need is the P210x Universal Windows Driver from here.
Note the name of the drivers: P210x Universal Windows Driver. This is important because you will need to go into the device manager, look for the Ports (COM & LTP), and find the Silicon Labs CP210x USB to UART Bridge device. Here you will be able to find the COM Port being used by the development board.
I have noticed with my upgrade to Windows 11 that my connection to the ESP8266 stopped working. Turns out there was a com conflict and I had to disable the other device using that com port.
The first thing that needs to be done is to flash the firmware onto the ESP8266 development board. To do this, we need to have the firmware file! Above I have linked to a pre-built firmware that I am using for these examples as well as a link to the nodemcu build website that allows you to custom build your own firmware. If you choose to make your own, include the following modules: dht, file, gpio, http, node, tmr, uart, wifi.
My firmware file that I am using is named nodemcu-release-9-modules-2021-02-20-02-00-01-float.bin. You will notice that once you have completed a build, you are given the option of a float or integer file. What is the difference, you may ask?
I am using the float firmware since I am using temperature sensors and will not be doing much that requires a lot of processing power.
This is where we need to use the ESP8266 Flasher tool. The only time you should need to use this tool is for flashing a brand new board, upgrading the firmware, or if your device is stuck in an infinite loop.
The ESP8266 board has a micro USB port that you use to connect to the computer. Connect the board directly to your computer.
Installation is minimal, simply download the tool and place it into a folder of your choice. Organization can really save time, so put it in a place that makes sense to you.
Run the tool. You need to know a few things that we've already covered above:
Steps for flashing the firmware:
That's it. Just wait for the flash tool to finish, and your board should be ready to go. The next time the board boots, it will run an initilization. So after you have flashed the board, it is best to unplug it, then plug it back in. This way it is truely ready to go when you start adding your code.
Here I provide working code examples and some explanations of how things work. I recommend starting with the Lua file basics and Simple Lua program since the other sections build off the basics.
With these examples, you should be able to make your own code to achieve the goals you have.
Lua files are very basic. They are nothing more than text files with the .lua extension. You can use anything to edit them, but I recommend Notepad++ because it has Lua as a supported language option that will help with your syntax.
The most important thing to know is that once you've flashed your development board and completed the initialization, the board will first look for the init.lua file. This is the initial file that starts your program.
You have to be careful not to cause an endless loop or it will be more difficult to work with the development board. If the board experiences an error, it is possible that the board will reboot, and then error again, endlessly. To fix this, you will need to reflash the firmware again. I recommend setting your code in a function and manually calling that function during testing and development. This way, the board will not get stuck in any error loops.
All of this will be included in the Simple Lua program.
Lastly, if you need to know more about the Lua NodeMCU programming commands, you can view that info [here]