Introduction: Getting Started With Wi-Fi
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.
Step 1: 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.
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
Step 2: 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_WeeESP82...
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. (Shown in Fig. 1 and 2)
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. ( Shown in Fig. 3)
Step 3: 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.
Step 4: HOW IT WORKS
1. 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. (Shown in Fig.1)
2. 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.(Shown in Fig.2)
3. Simply change the SSID and the PASSWORD to suit your router.(Shown in Fig.3)
Step 5: 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.
Step 6: Build
4Duino has an inbuilt ESP8266 Wi-Fi module. Hence, there is no external circuitry required for this project.
Step 7: 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.
1. Download the project code here.
2. Change the SSID and the PASSWORD to suit your router, in the program.34. Connect the 4Duino to the PC using µUSB cable.
3. Then navigate to the Comms tab and select the Comms port to which the 4Duino connected.
4. Finally, go back to “Home” tab and now click on the “Comp’nLoad” button.