Flashing the sketches - MetalWorkerTools/ESP8266Station GitHub Wiki

This document describes the flashing of the ESP8266 sketch to an Arduino UNO R3 or Mega with build in ESP8266 module as supplied by robotdyn and also available on eBay. The sketch can also be flashed to a “standard” ESP8266 module.

Configuring WiFi

The ESP8266Station firmware works in "Transparent Mode", It simply passes the data. Configuration is done by adjusting a few settings in the program before flashing. After flashing the firmware the module can be accessed by the HostName you set in the program.

USB to Serial adapter

To flash the firmware on a ESP8266 WiFi module, you need an USB to Serial adapter. I use a CP2102 or CH340 module that you can buy for less than 2$ on eBay. These modules come with a 3V3 power supply you can use to power the ESP8266 or HC-0X module for configuration (only). You can use 4 (Dupont) patch cables for the connection, but I also made a breakout board for the CP2101 module having an IDC6 (flat cable) connector that fits the breakout boards I made for the HC0X and ESP8266 modules.

Preparation of the board:

Set the all dip switches to off. Connect it to the PC using an USB cable. Install the CH340G driver if necessarily available from robotdyn, see the document section on the boards page.

Testing the Arduino part of the board:

Set the all dip switches to off and set dip switch 3 and 4 to on and press the reset button. The Arduino is now connected to the USB. Follow the instruction on Arduino getting started and flash the Arduino with the blink sketch.
When the Arduino and Arduino IDE are working (Blink sketch is running) continue with Installing the libraries.

Installing libraries:

To flash the sketch, first the ESP8266 library has to be installed. Follow the documentation on Arduino installing ESP8266 library to install the ESP8266 library.

Flashing the ESP8266Station sketch for testing:

  • Set the all dip switches on the board to off
  • Set dip switch 5 and 6 to on to connect the USB to the ESP8266 module.
  • Set dip switch 7 to on to enable the ESP8266 uploading mode.
  • Open the ESP8266Station sketch.
  • In the Arduino Tools Menu select Tools | Board and select the generic ESP8266 module.
  • In the Arduino Tools Menu select Tools | Upload-Speed and select the 115200 upload speed.
  • Flash the ESP8266Station sketch by pressing the Upload button
  • Remove the 2 slashes in the ESP8266 station sketch line to enable debugging output:
    //#define Trace
  • Set your WI-Fi router SSID in the ESP8266 station sketch line
    #define ssid "YourSSID"
  • Set your Wi-Fi router password in the ESP8266 station sketch line
    #define Password "YourPasswordr"
  • Set the listening port for the ESP8266 module in the ESP8266 station sketch line
    #define ServerPort 23
  • Set the host name for the ESP8266 module in the ESP8266 station sketch line
    #define HostName "YourHostname"
  • Start the Serial Monitor by pressing the Serial Monitor button in the Arduino IDE.
  • Press the Arduino reset button (this has to be done before every upload of an ESP8266 sketch).
  • Now flash the ESP8266 station sketch by pressing the upload button in the Arduino IDE.
  • After uploading is done, You can monitor the debug output of the sketch. It shows the settings it uses to connect to your WI-Fi router and the IP-address it receives from the WI-Fi router.

Testing the WI-Fi connection:

  • Open a CMD terminal on your computer and try to ping to the IP-address of the ESP8266 module by sending a ping command:
    example Ping 192.168.10.105
  • If you can ping the ESP8266 modules IP-address, try to ping it by its host name:
    example ping Lathe2

Flashing the ESP8266Station sketch:

  • Retype the 2 slashes in the ESP8266 station sketch line to disable debugging output:
    //#define Trace
  • Press the Arduino reset button (this has to be done before every upload of an ESP8266 sketch).
  • Now flash the ESP8266 station sketch (without debug output) by pressing the upload button in the Arduino IDE.
    After uploading is done, You can monitor the debug output of the sketch, should be nothing!

Flashing the Arduino sketch:

  • Set the all dip switches on the board to off
  • Set dip switch 3 and 4 to on to connect the USB to the Arduino.
  • Upload your Arduino sketch and check if it is working.

Connecting the Arduino serial to the ESP8266 serial:

  • Set the all dip switches on the board to off
  • Set dip switch 1 and 2 to on to connect the TX/RX pins of the ESP8266 to the RX/TX pins of the Arduino.
  • Now you can communicate to the Arduino using the host name (or IP-address) and port set in the ESP8266station sketch