I initially bought an ESP8266 module from Ebay in an attempt to add network connectivity to an arduino. It didn’t take me long to figure out that it wasn’t simply a case of connecting this module to an arduino and connecting to the network with it.
The ESP8266 module I bought was an AI-Thinker ESP-01 like the one pictured.
Initially I tried to connect to the ESP8266 using the arduino, I had read a few reports of this working but I could not get this to work. I think one of the problems was that I was trying to power it through the arduino. The ESP8266 module needs 3.3V and the arduino’s 3.3V output does not provide enough current. Another danger of connecting them directly is that the TX / RX of the arduino are rated at 5V, the ESP8266 is rated at 3.3V. Whatever the reason I could not get it to work.
To provide the correct power I bought a ranking breadboard power supply from Amazon. This has turned out to be really useful, all you need to do is push it into the breadboard and it provides power to the power rails. Note that this version has jumpers to determine whether each side gets 3.3V or 5V. The jumpers need to be between the voltage you want and OFF. Here is a datasheet for it.
I also got an FTD1232 serial adapter from Ebay to connect directly to the ESP8266 without the arduino.
To connect to the ESP8266 I wired it up like this:
(Note the serial adapter image has it’s pins reversed in the diagram.)
Serial adapter TX
Serial adapter RX
The reset and flash buttons also need to be connected to ground as does the Serial connector.
Once wired up you need a way of communicating with the ESP8266. There are a few options for this:
To connect to the device using putty use the following configuration:
Note that the speed needs to be set to 115200. Once connected if nothing shows up try pressing the reset button and you should see something like this:
To send AT commands type them in press enter and then press <CTRL + J>. A list of AT commands can be found here. If your ESP8266 module does not already have some firmware loaded onto it you may need to flash some on to it. Check out the instructions here.
Another way to connect is using Esplorer. If you don’t see anything in the port chooser press the refresh button and hopefully the port will show up. Click on Open and it should connect.
Esplorer has the advantage of having the AT commands listed and accessible.
Simply open up the arduino IDE and use the Serial Monitor to connect. AT commands can be typed sent via the input at the top of the screen.
Once you’ve got the ESP8266 working you can either use the firmware provided, or you can flash something else onto the ESP8266 chip.
I used the esptool for flashing Espressif firmware and NodeMCU (Available in the AUR for Arch users!) and the Arduino IDE for flashing Arduino programmes.
To put the device into flash mode you need to hold down the reset button and press the flash button, the device should blink.
Some of the options of firmware you can flash to the ESP8266 include:
The manufactureres of the ESP8266 chip Espressif provide firmware for the ESP8266. This may well be the firmware that your chip came with originally. Tracking it down and flashing it is not easy. In fact I found it the hardest firmware to get installed. The firmware can be found somewhere on the Espressif site. I found V1.5.2 here. Unzip the files and there should be a readme.txt file somewhere with the details of flashing the files. I found one in esp_iot_sdk_v1.5.2/bin/at/readme.txt
The binary files themselves are in the bin and bin/at folders. For example the readme.txt I had said:
Note that/dev/ttyUSB1 is the port my device is connected to and these commands are run from the folder containing the ESP SDK. The lights on the module should flash for a while and after a few messages it should finish and hopefully have successfully flashed the firmware.
I found this much easier to flash than the Espressif firmware. The project can be found on github and there is a really simple to use cloud builder, you can select which modules you want to include. Once it has run it will send you an email containing links to 2 files to download. One will have support for floating numbers and one has support for integers.
This is fairly easy to flash using esptool simply:
You will need to make sure the port is correct and change the filename as it won’t be the same as the one I downloaded. Remember to press reset and flash first!
The simplest way I found to flash the ESP8266 was using the Arduino IDE. It takes a bit of setting up but once it is done flashing new sketches is really simple.
To add the board to the IDE go to File > Preferences and enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Boards Manager URLs.
Next you need to install the board manager. Go to Tools > Board*** > Boards Manager and look for esp8266 by ESP8266 Community.
There should be some example sketches to run under File > Examples > ESP8266, if not you may need to install some ESP8266 libraries, Sketch > Include Library > Manage Libraries should have lots of options.
There are other options of firmware I haven’t tested yet including Micropython which I think I may try next.