Connect ESP8266 to Raspberry Pi
This small tutorial is meant to help you connect the ESP8266 wifi module to Raspberry Pi through serial port. It will show you how to run a simple AT command and how to connect the chip to your wireless router using these commands.
Before starting the wiring, I highly recommend you to use a breadboard.
You can use the following table as a wiring guide.
Ex: VCC and CH_PD from Wifi module are connected to Pin 1 from Raspberry.
|ESP8266||Raspberry Pi B|
|VCC and CH_PD||Pin 1 (3V3)|
|GND||Pin 9 (Ground)|
|TX||Pin 10 (GPIO 15)|
|RX||Pin 8 (GPIO 14)|
After you finish the wiring you can plug in the power into Raspberry.
Now we’ve reached to the phase where we want to access the ESP8266 module through serial port. For this we need a tool called minicom, but first we need to disable Serial Port Login and some Bootup info on Raspberry. You can do that by following the next short steps
Disable serial port login:
Open /etc/inittab and search for the following line:
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
You need to comment this line by adding # at the beginning of the line.
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Disable bootup info:
This part is optional. At every boot Raspberry will send all bootup information through serial port. If you want to keep that information to be sent, just skip this step.
Remove all ttyAMA0 references from /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
After deletion, it should look like the following code:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Now we must reboot the Raspberry!
sudo shutdown -r now
Next step is to install minicom and connect to wifi module. It will help us to communicate with the ESP8266 by offering us an interface where we can run the AT commands.
# Install minicon
sudo apt-get install minicom
# Connect to wifi module
minicom -b 115200 -o -D /dev/ttyAMA0
If everything went good you should see the minicom serial interface. Try to write AT+RST and hit Enter. If it will print some info it means that you are ready to go.
Connect to your home router
Where dlink is your router name (SSID) and password is the router password.
List of available AT commands can be found here
Use ESP8266 module as a wireless switcher – quick tutorial showing you how to upload a custom firmware.