Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

Programming ESP8266 WiFi Module

Daksh Srivastava edited this page Nov 19, 2017 · 6 revisions

Programming

Note : Apparently, Arduino IDE 1.8.5 or below face problems while flashing the WiFi module on a Mac. You would repeatedly get below error message. After much troubleshooting, flashing the module from a Fedora machine worked for me. You could try from any linux machine though.

warning: espcomm cmd: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed

Prepare the IDE

Arduino IDE

You need to add the ESP8266 board in the Arduino BoardManager. To do that, go to preferences and add http://arduino.esp8266.com/stable/package_esp8266com_index.json in the space provided under Additional Board Manager URLs.

Now go to Tools > Board & select the Generic ESP8266 Module or any other ESP module depending on what you bought and keep all other configuration as default. If your Arduino is connected, go to Tools > Port & select your Arduino.

This project uses a publicly available ESP8266 library :

  • ESP8266HTTPClient by Markus Sattler;

To download them, head to Sketch > Include Library > Manage Libraries to see a horde of libraries available. Scroll or search to find the one mentioned above. That's it for the IDE setup - To continue now, you need to prepare the circuitry between your Arduino (in my case UNO) and ESP8266. There may be multiple ways to program the module - I programmed it via the Arduino. Using it as an intermediary to relay the program.

Circuit to program the ESP

The circuit is only for programming the module. Once the programming is completed, please refer to the final circuit diagram.

Arduino IDE
Arduino ESP8266
3.3v VCC
3.3v CH_PD
GND GND
GND GPIO_0
Tx Tx
Rx Rx

Now that the circuit is done, we can proceed with compiling the program and uploading it to the module. To do that, don't clone the project - download a latest release & open HomeAutomation_ESP8266 in the Arduino IDE.

To get the program working, you need to modify the following variables :

const char* ssid = "<SSID HERE>";
const char* password = "WiFi PASSWORD HERE"; 
const String serverUrl = "API SERVER URL";
const String getStatusAPI = "/getStatus"; //Need not modify unless you plan on changing the API endpoints under Node Services package.

Verify & upload.

To check if your module is receiving the responses, open the Serial Monitor and set baud rate to 115200. You should see some data being pushed to the console now. If you do, you have successfully configured your ESP8266 module and you can move on to the next step!