In this project, we will learn how to get started with the ESP8266, an inbuilt 4Duino Wi-Fi module and connect to a local access point. The 4Duino display is used to print the status of the connection for debugging purposes.

UNDERSTANDING THE SOFTWARE

The ESP8266 Wi-Fi Module is embedded in the 4Duino. ATmega32U4 communicates and controls the ESP8266 via Software Serial with a default baud rate of 115200 bps. For this purpose pins D8 and D9 are used. However, if the Wi-Fi modules is used in your project then the pins D8 and D9 cannot be utilised in your design.

understanding-the-software-pr5

Additionally, you can program or upgrade the firmware on the ESP8266 via the 5 way Header. For this you will need a 4D Systems’ programming cable or a PA5 Adaptor. For more information refer to the 4Duino datasheet at www.4duino.com

First step towards programming the ESP8266

The “ESP8266.h” header is incorporated in the skeleton code. This could be downloaded at:

https://github.com/itead/ITEADLIB_Arduino_WeeESP8266

In the skeleton code, there is a section commented to initialise the ESP8266 Wi-Fi Module. All you need to do is uncomment these lines of code and the initialisation is done for you. Now the Wi-Fi modules is ready to be controlled using AT Commands.

prog-1-pr5

prog-2-pr5

The default baud rate is set to 115200 bps, however the maximum baud rate at which Software serial actually works is 19200 bps. So in the code it requires changing the baud rate and this is done for you in the skeleton code.

prog-3-pr5

AT Commands

To communicate to the ESP8266 Wi-Fi module, AT Commands are used. You can use the library mentioned above and use its functions for convenience instead of using AT Commands directly. More information on the library functions can be obtained at:

http://docs.iteadstudio.com/ITEADLIB_Arduino_WeeESP8266/index.html

In this project, the library functions have been utilised to communicate to the ESP8266.

HOW IT WORKS

Firstly, the ESP8266 is set to station mode. This follows the initialization of the Wi-Fi module which is explained above. Setting the Wi-Fi module to station mode allows to connect to an AP. Else it could be set to AP mode or both, meaning it can act as an AP as well as a Station.

how-it-works-1-PR5

The program then commands the Wi-Fi module to join to the AP, which can be your home router. SSID and PASSWORD are defined in the code respectively.  After joining the AP it will print the Local IP address on the display.

how-it-works-2-PR5

Simply change the SSID and the PASSWORD to suit your router.

how-it-works-3-PR5

COMPONENTS

This projects only utilizes the internal circuitry of the 4Duino. Hence you do not require any components for this project. However, a micro USB cable is required to program the 4Duino.

IMPLEMENTATION

Step 1 : Build

4Duino has an inbuilt ESP8266 Wi-Fi module. Hence, there is no external circuitry required for this project.

Step 2: Program

Workshop 4 – 4Duino Basic Graphics environment is used to program this project. (The same could be implemented in the latest Arduino IDE)

This project requires the Arduino IDE to be installed as Workshop calls the Arduino IDE for compiling the Arduino sketches. The Arduino IDE however is not required to be opened or modified to program the 4Duino.

step-2-prog-PR5

Open this file using Workshop 4.

Change the SSID and the PASSWORD to suit your router, in the program.

step-2-2-prog-PR5

Note: Download the project here.

Step 3: Comms Port

Connect the 4Duino to the PC using µUSB cable.

Then navigate to the Comms tab and select the Comms port to which the 4Duino connected.

PR3-Comms

Step 4: Compile and Upload

Finally, go back to “Home” tab and now click on the “Comp’nLoad” button.

PR2-Compile

DEMONSTRATION

After uploading 4Duino connects to the local access point (AP) and prints status on the 4Duino display.

wifi-1

wifi-2