Connecting ESP8266 to Raspberry Pi

Today I just connected my ESP8266 (model:ESP-01) to Raspberry Pi (2)successfully. I just connected to check if the module is working or not. If your trying to do the same this blog may help you. According to documentation the ESP is not 5V tolerated. Thats why I used raspberry pi instead of Arduino UNO. Some people reported that they connected ESP8266 to UNO with out any level connector, and tested the ESP successfully. I haven’t tested it yet.

ESP8266 requires external 3.3V supply , Raspberry Pi 3.3V source can’t provide sufficient current you need to have a supply with 3.3V with at least 1A rating. The connections fairly simple.

Tx(pi)—Rx(ESP)

ESP8266
ESP8266 pin mapping

Rx(pi)—Tx(ESP)

Connect GND of both pi and ESP to your external power supply. Connect Vcc and CH_PD pins of ESP to 3.3V source of your power supply.

The default rate is 9600. I have used pySerial to communicate with serial port. You need to disable serial port from kernel ,if you haven’t done that check Disabling Serial port in Raspberry Pi


pi@pihorse01 ~ $ python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> ser=serial.Serial()
>>> ser.timeout=3
>>> ser.baudrate=9600
>>> ser.port='/dev/ttyAMA0'
>>> ser.open()
>>> ser.write('AT\r\n')
4
>>> ser.readline()
'AT\r\r\n'
>>> ser.readline()
'\r\n'
>>> ser.readline()
'OK\r\n'
>>> ser.readline()
''
>>> ser.write('AT+RST\r\n')
8
>>> ser.readline()
"'\x1c\xfe\x801\xf9\r\n"
>>> ser.readline()
'[Vendor:www.ai-thinker.com Version:0.9.2.4]\r\n'
>>> ser.readline()
'\r\n'
>>> ser.readline()
'ready\r\n'
>>> ser.readline()
''
>>> ser.write('AT+CWMODE=3\r\n')
13
>>> ser.readline()
'AT+CWMODE=3\r\r\n'
>>> ser.readline()
'\r\n'
>>> ser.readline()
'OK\r\n'
>>> ser.readline()
''
>>> ser.write('AT+CWLAP\r\n')
10
>>> ser.readline()
........available access points.......
>>> ser.close()

If you connected every thing correctly, you should get OK response for AT command. If that is not the case check your connection and power supply once again. AT+CWLAP will scan for the wireless access points.

 

Add a Comment

Your email address will not be published. Required fields are marked *