14.2 Wifi - ESP8266
Last updated
Last updated
As in 14.1 Serial, an ESP8266 Wifi module has been connected to the virtual serial pin 10 and pin 11 on Arduino UNO. In this section, we'll talk about how to use this ESP8266 Wifi module a bit more.
Note: A lot of pictures in this section are directly cited from https://www.geekstips.com/esp8266-arduino-tutorial-iot-code-example/.
An ESP8266 wifi module is provided in our Arduino course on-site, which looks like:
And its pins are defined as:
We still use the same hardware wiring way as in 14.1 Serial to wire the Arduino UNO and ESP8266.
The same sketch in 14.1 Serial is also adopted here.
It is also possible to run the sketch on the ESP8266 program without using an Arduino UNO board, for ESP8266 comes with a MCU inside the module itself.
http://www.arduinesp.com/ detailedly explained how to do that step by step. Three cannonical examples are given on http://www.arduinesp.com/examples:
Students are encouraged to finish all examples after class.
You can also refer to https://www.geekstips.com/esp8266-arduino-tutorial-iot-code-example/.
Both websites adopt Arduino IDE to implement/verify/compile the sketch, and flash/download the binary code onto an ESP8266 via Arduino UNO R3 board. Let's just see how it goes.
Note: You do need a FD232RS as a proxy/bridge, which looks as follows:
In order to flash sketch onto ESP8266 via an Arduino board, we need to follow the steps on https://github.com/esp8266/Arduino.
Note: Make sure you enabled python2, instead of python3.
Start Arduino IDE, then click File->Preferences->Settings, fill http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Boards Manager URLs, as:
Then, restart Arduino IDE. Click Tools->Board->Board Manager, then we search esp, make sure Arduino AVR Boards and esp8266 are installed. Please refer to the following image:
Note: Without the installed Arduino AVR Boards, you will possibly meet the following ERROR message:
SPIFFS Not Supported on avr
What is SPIFFS? For short, it is SPI Flash Filing System. For details, please refer to http://www.instructables.com/id/Using-ESP8266-SPIFFS/.
Afterwards, we select Tools->Board->Generic ESP8266 Module.
After we selected Board: "Generic ESP8266 Module", we are now trying to upload (after verify/compile) any sketch (here, the default EMPTY sketch for testing) to Arduino board with ESP8266 connected. You will see the following ERROR messages:
By clicking Tools->ESP8266 Sketch Data Upload, you will see the following dialog:
By clicking Yes, the same ERROR messages will be given as:
So, it seems we failed to flash our ESP8266 Wifi module. But, we have to do something. This website https://www.forward.com.au/pfod/ESP8266/GPIOpins/index.html is just to solve this problem.
In fact, 4 different methods have been summarized in https://www.diyhobi.com/flash-program-esp-01-using-usb-serial-adapter/ to fulfill the task how to flash ESP8266.
Flash Mode: “DIO”
Flash Frequency: “40MHz”
CPU Frequency: “80 MHz”
Flash Size: “1M (64K SPIFFS)”
Debug Port: “Disabled”
Debug Level: “None”
Reset Method: “ck”
Upload Speed: “115200”
You can also purchase an Arduino Wifi Shield recommended by official Arduino website(s), and accomplish Wifi communication. Please refer to the following official Arduino webpages: