Connecting ESP8266 to Raspberry Pi: Difference between revisions

From Playful Exploration
Jump to navigation Jump to search
(Created page with "Category:Rpi Category:ESP8266 These were my steps, but your specific setup may vary. Turn off aLaMode (don’t know if this is necessary) Connect Tx, Rx, GND directly...")
 
No edit summary
Line 1: Line 1:
[[Category:Rpi]] [[Category:ESP8266]]
[[Category:Rpi]] [[Category:Esp]]
These were my steps, but your specific setup may vary.
These were my steps, but your specific setup may vary.



Revision as of 02:12, 18 May 2016

These were my steps, but your specific setup may vary.

Turn off aLaMode (don’t know if this is necessary) Connect Tx, Rx, GND directly to GPIO pins Connect VCC, CH_PD, to 3v3

Device is accessible via /dev/ttyS0 on 9600 baud. Used Arduino IDE serial monitor.

Used a variety of AT commands. Verified that I could connect to its Access Point (open wifi) Connected it to home wifi network

Pinged repeatedly. Power off/on time is < 1 second

____________

Flashing ESP from RPi using NODEMCU firmware

Steps:

  1. Ensure /dev/ttyS0 port is a functioning serial port
  2. This may already be setup. Mine was configured when installing aLaMode ArduinoIDE support.
  3. Install python library pyserial (used by firmware uploader tool)
  4. sudo pip install serial
  5. Baud rate. This presented a problem the first time around. But the nodemcu firmware uploader tool is open source so I was able to figure out the problem myself. Here’s the code that prevented the firmware from uploading to my ESP:
  6. #Default baudrate. The ROM auto-bauds, so we can use more or less whatever we want. ESP_ROM_BAUD = 115200 (Might want to check the assumption on this one.) My ESP has the original firmware installed and does not auto-sense baud rate like some of the later versions do. The NODEMCU tool uses 115200, so I had to change the baud rate from 9600 (default) to 115200. AT+CIOBAUD=115200
  7. Start a new clone of nodemcu-firmware from git
  8. sudo git clone https://github.com/nodemcu/nodemcu-firmware Or if this is already done update the repo (from nodemcu-firmware folder) sudo git pull
  9. If necessary, change directory to the nodemcu-firmware project
  10. cd /nodemcu-firmware/
  11. Put ESP8266 into flash mode by connecting GPIO-0 to ground and then apply power (or power cycle) Note: connecting GND and GPIO0 to different grounds on RPi (pins 6 and 14) did not register as GPIO0=low (went into some sort of non responsive mode). Therefore, GND and GPIO0 should use a common ground (be directly connected)
  12. Run uploader specifying the serial port and firmware that was included in the git clone (from the nodemcu-firmware root folder):
  13. sudo tools/esptool.py --port /dev/ttyS0 write_flash 0x00000 pre_build/latest/nodemcu_latest.bin Success! Connecting... Erasing flash... Writing at 0x00060a00... (100 %) Leaving...

The ESP is now ready to be configured for lua scripting. I’ll be taking advantage of MQTT for sending simple messages around my home.