The
ESP8266 pHAT from Pimoroni for adding wifi to your Raspberry Pi projects. Here's a brief 'quick-start guide'. If you're going to use the pHAT on a Pi Zero, it can be easier to do the config on a full-size Pi then just transfer the pHAT and SD card when you're all done.
1. Start with a fresh install of Jessie
2.
sudo apt-get update
3.
sudo apt-get upgrade
4.
sudo apt-get install minicom
5. We need to stop the Pi using the Serial port for console messages. Edit /boot/cmdline.txt to remove '
console=ttyAMA0' from the line. You should be left with:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
6. sudo raspi-config. Go to Advanced Options => Serial and set it to disabled.
7. Shutdown the Pi
8. Solder the header onto the pHAT. Attach to the Pi and power up.
9. Now we can connect to the ESP8266 via a serial connection. Run minicom -b 115200 -o -D /dev/ttyAMA0
10. To test, type
AT
and hit enter/return as normal. Then type ctrl+j
You should see the reply OK
11. Now you can start putting the ESP8266 to work. There's a useful list of AT commands
here, but to get started try:
AT+CWMODE=1
AT+CWLAP
which will list all the wifi Access Points that it can see.
12. To connect to one:
AT+CWJAP="SSID","password"
Obviously replace SSID and password of the network you're trying to connect to!
13. Then find your IP address
AT+CIFSR
To disconnect for the AP, type
AT+CWQAP
Don't forget the ctrl-j after each command.
To quit minicom, type ctrl+a then q
14 As a more advanced test, you can set up your Pi as a simple web server. Download this really useful python code:
git clone https://github.com/guyz/pyesp8266.git
Then change into that directory and run the server code
python esp8266server.py /dev/ttyAMA0 115200 "SSID" "password"
You should see a whole bunch of familiar AT commands being executed. When everything has finished, fire up your web browser and connect to the IP address just allocated to your PI/ESP8266.
You should see the system date displayed:
Once you're finished developing, transfer everything over to your Pi Zero.