Connect an ESP8266 to your RaspberryPi

ESP8266 boards are pretty neat, but if you just bought one (And why wouldn't you for only $5?) and have realized that you don't have any obvious means (3.3V TTL USB serial device) to communicate with it, you can talk to it directly with a Raspberry Pi. Both use 3.3V signaling, so no level converting is required.

You will need:

Raspberry Pi desktop setup (just about any Pi should do, but with power, keyboard, screen, etc. network access is a plus)Connect an ESP8266 to your RaspberryPi

ESP8266-01 (or equivalent)

Some jumper wire and nipper/strippers

Solderless Breadboard (or You can solder this instead)

2x Pull-up/down resistors

(optional) push-button switch

The process is roughly two steps,

1) Wire them together

2) Configure Raspbian

3) Start talking to your ESP8266

Step 1: Wire them together

With the power off, connect the 3.3V and ground pins to one another. Similarly connect the RX to TX and vice versa. You will also want some pull down resistors and optionally a reset button. I've included a Fritzing diagram (above).

Step 2: Configure Raspbian Linux

Boot up the Pi and with super user privs make some edits (e.g. “sudo nano”).

Disable the Kernel serial console

Edit /boot/cmdline.txt to remove the underlined text:

dwc_otg.lpm_enable=0 rpitestmode=1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

Disable serial logins

Edit /etc/inittab and remove the (usually) last line:

2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Reboot

sudo shutdown -r nowConnect an ESP8266 to your RaspberryPi schematic

Step 3: Start talking to your ESP8266

Connect to the serial port
You should now be able to interact with the ESP8266 via a terminal emulator program. I suggest GNU Screen for this (“sudo apt-get install screen”). Screen passes through your keystrokes unless you start with “CTRL-A” in which case you can then make screen do things. For example “CTRL-A” then “k” will close (kill) the session. screen /dev/ttyAMA0 115200 (the speed may vary depending on your ESP8266 board) (you may need to sudo this too, depending permissions) You can now send your ESP8266 “AT” commands. You’ll still need “return” and “CTRL-J” after each one, though.

Notes/Caveats

The Pi does not seem to recover well if you try to use the reset button. Best to shutdown the pi, then remove power, then power/boot back up rather than try the reset button.

Don’t mess with the wires while power is on. Shutdown the Pi (“sudo shutdown -h now”) and wait for any blinking LEDs to stop and disconnect power before trying to connect/disconnect wires.

 

For more detail: Connect an ESP8266 to your RaspberryPi


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

Scroll to Top