Testing of the ESP8266 Bluetooth module consisted of a number of stages. Initially, a USB-TTL converter was used to provide connection of the ESP8266 to a PC via USB cable. This enabled using a Windows PC terminal program to send AT commands to the ESP8266. Therefore, basic operation of the ESP8266 (i.e., did it power up correctly and return device ID etc) could be checked before moving on to custom circuitry and software. This is important as the quality of ESP8266 boards from ebay suppliers can sometimes be low (although I have experienced no trouble to date with the ESP8266's purchased).
Secondly, the ESP8266 is then tested within a circuit interfaced to a PIC18F248 (via USART hardware serial port) and the PIC18F248 in turn is connected to PC via a USB-TTL serial connection. The dual serial port connections with the PIC18F248 enable control of the ESP8266 while "debugging" and ongoing status information can be output to PC/terminal programme. The ESP8266 is connected to the hardware PIC18F248 USART serial port to enable the highest baud rate (115400) with the Wi-Fi module. Whereas, since the PIC18F248 only has a single hardware USART serial port, software emulation (baud rate 38400) was used for the serial connection via USB-TTL to the PC/terminal programme.
This enables testing of the firmware within the PIC18F248 that data can be sent and received via Wi-Fi to the PIC microcontroller, controlling the ESP8266 in the various modes available via AT commands.
Finally, custom designed and implemented web based apps (running in the Google Chrome browser) were produced to send and receive data from the PIC18F248 via Wi-Fi. This staged process allowed the development and testing to proceed smoother in that errors and bugs could be isolated to the current phase.
Initial Testing with USB-TTL converter
The ESP8266 accepts AT commands (when the AT command interpreter firmware is installed - which is the default when the module is purchased) which is useful to test if the module is powering up correctly in the first instance. A USB-TTL converter (I used a $2 converter purchased from ebay) makes it convenient to connect the ESP8266 to a PC via USB (see the Schematics Section for the simply wiring required). The USB-TTL converter takes power from the USB socket (no other power supply necessary), and the particular converter I had also output 3.3V which again is convenient to power-up the ESP8266.
The initial step with the USB-TTL converter is to downloaded the necessary USB drivers (if using Windows) which I sourced from the Prolific Technology Inc site (2) which at the time of download was a file titled "PL2303_Prolific_ DriverInstaller_v1.12.0.zip". Unzip the file, click the installer and follow the usual steps for installing the driver software. When the USB-TTL converter is then connected to the USB port of the PC, Windows should do the usual driver installation steps.
The next step is to use a suitable serial port (COM) terminal emulation program to send commands to the ESP8266 via the USB-TTL converter. I used "Terminal" which is very useful for debugging serial communication and is available for free (3) (download the zip file, unzip, and use the installer as usual for a Windows program).
The ESP8266 is connected to the USB-TTL converter as per the second schematic in the Schematics Section. This enables connection to a PC and the send/receipt of AT commands by the ESP8266. The ESP8266 is a 3V device, but if using a USB-TTL convertor that has 3V output,the USB-TTL converter can also be used for the power supply, otherwise would need a seperate 3V supply. Note that the RX pin on the ESP8266 is not 5V tolerant (expects 3V). Since using a USB-TTL with a 3V output this was not a problem, but if interfacing with non-3V device/bus, will need voltage conversion for the ESP8266 RX pin (voltage divider or similar). The steps for booting/powering-up the ESP8266 in AT command mode are as follows:
- Connect ESP8266 as per second schematic
- Use Terminal (or similar) as serial comms Application on PC
- COM port 3, baud rate 115200, 8 bits, no parity, 1 stop bit
- Connect USB-TTL to PC USB port with suitable cable
- Red LEDS on the ESP8266 and the USB-TTL both illuminate, showing power on
- There will be an initial flash from the blue LED on the ESP8266
- With Terminal (App on PC), click the CONNECT button, now should be in communications with ESP8266
- In the SEND command line, type AT (ensure CR+LF is selected) and then click SEND. The ESP8266 should respond with “OK” (which is displayed on the terminal window). The command AT tests the setup of the ESP8266 wireless module and connection via USB-TTL
- Now ready for sending AT commands to the ESP8266 from the PC
The following are some useful AT commands to test the ESP8266 module, a full list of AT commands is available here (4).
The command "AT+GMR" is used to return the version of the AT command ESP8266 firmware installed and SDK that is expected. The response I received for the ESP-07 version modules was:
The command "AT+CWMODE_CUR?" queries the ESP8266 for the current Wi-Fi mode. The response I received for the ESP-07 version modules was:
The response from the ESP8266 is a numeric code, 1 = station, 2=softAP, 3=station+softAP. The mode needs to be either 1 or 3 in order to enable retrieval of access point details. To change ESP8266 Wi-Fi mode, use the "AT+CWMODE_CUR=3" command.
The command "AT+CWLAP" will list the details about the various Wi-Fi access points currently in range. The response I received for the ESP-07 version modules was:
Using the above commands, this is sufficient to test that the ESP8266 is responding correctly via the USB-TTL/serial port (therefore the initial circuit is OK, and the ESP8266 module is OK) and that the Wi-Fi can see/access local access points (via local routers etc).
Testing PIC18F248/ESP8266 - PC terminal sending AT commands
When the ESP8266 has been checked to be operational (see previous section detailing testing with USB-TTL converter and serial port emulation program), the module can be interfaced to the PIC microcontroller and Wi-Fi communications checked.
The Schematics Section details the wiring connections necessary to interface the ESP8266 to the microcontroller USART I/O pins (use the hardware USART serial port to enable the highest baud rate to be used for the Wi-Fi communications). The firmware for the microcontroller (using CCS C compiler) is relatively straight forward as the ESP8266 "looks like" a normal RS-232 serial communications port. The following code snippet 1 demonstrates basic functionality for the PIC microcontroller to send and receive data (AT commands and the subsequent responses) and then echo the received data to PC via RS-232.
Code Snippet 1:
The above code snippet,
The following code snippet 2 demonstrates
Code Snippet 2:
The Downloads Section at the bottom of Testing/Experimental Results has the full CCS C source code used for communication with the PIC micrcontroller via the HC-05 bluetooth module to control LED's, speed of a DC fan motor and receive data from a LM35 temperature sensor (with a real time graph of the data on the Android phone app) as demonstrated working in the Video Section.
Custom Developed Web App's
Text
Downloads
Only Logged-In Members can add comments