You are here

Using the ESP8266 with a PIC to create your IoT device.

Recently I created a library with the name 'esp8266.jal' for connecting a PIC to your WiFi. The library is based on an ESP8266 ESP12-F and it based on version 2.0.0 of the ESP8266 AT command set.
The ESP8266 interfaces with the PIC using a UART.

Via some functions provided by the library you can make connection to your router, visit a website and send and receive data over WiFi. Various sample programs are available, some sample programs are made for a PIC16F19176 which has 2 UARTS on board, to make debugging easier. The other samples are based on a PIC16F1825 as to show that it also works on smaller PICs. Note that the latter only has one UART so when you have to know the IP address that is assigned to your module, you need to check your router. When you use the sample programs of the PIC16F19176, all required Wifi and status information is sent to the second UART.

With these sample programs you can control your PIC over WiFi in a simple way by just sending one letter as a command over the WiFi or you can use your browser to connect to your PIC where the sample program presents a simple website that shows the control options for that PIC.

There is an important note. The ESP8266 operates on a power supply of 3.3 Volt so you cannot connect your PIC to it directly if it is powered by 5 Volt. You have two options:
1) Both the ESP8266 and the PIC are powered by the same 3.3 Volt power supply.
2) The ESP8266 operates at 3.3 Volt and the PIC operates at 5 Volt but a level shifter is used between the UART connection of the ESP and the PIC to make the conversion 3.3 Volt <--> 5 Volt. I used this set-up for testing the PIC with the PIC16F1976 since the second UART had to communicate with the outside world.

The attached schematic diagram shows the design as mentioned in 1). When using the JAL sample program '16f1825_esp8266_web_server_led.jal' you can use your web browser to connect to the PIC and click on a web page the PIC creates to turn a led on or off. In the attached schematic diagram the green led will light up when a connection with the WiFi is established. The red led is the led you can control via the web browser. The same functionality is available with the sample program '16f1825_esp8266_tcp_server_led.jal' but with that program you can control the led using a Telnet session on your computer and control the led by typing H (High), L (Low) or T (Toggle). More info can be found in the sample programs.

In the attached picture you find the test setup that I used for testing all sample programs using the two different PICs. Here you also find the level shifter, a voltage regulator that makes the 3.3 Volt out of 5 Volt. the ESP8266 ESP-12F and a MAX232 IC for connection to the RS232 of a PC. Note that the ESP8266 has an unhandy format for making connections with so I used an extension board as to be able to connect it to the breadboard.

Have fun building your Internet of Things device.