ESP8266

From Medien Wiki
Revision as of 14:43, 3 May 2016 by Mschied (talk | contribs)

Testing and using a ESP8266 board

Electronic Setup

http://www.uni-weimar.de/medien/wiki/images/Esp-201-cheatsheet.svg

Supply the board with 3.3V on VCC, best run it with a voltage source or regulator that can at least deliver 300mA (many arduino boards have 3.3V regulators on board, but they deliver less than 300mA). Initial testes just with a ftdi usb to serial converters show unstable wifi connections, sometimes even board startup is impossible (the esp8266 board draws too much current).

Testing the Board with AT Commands

full reference of all AT commands: http://bbs.espressif.com/download/file.php?id=256

first steps:

AT+RST - resets the board:
ATE1 (verbose)
ATE0 (non verbose)

pre-setup to either join a network (station mode) or create a new network acces point (AP)

AT+CWMODE=1 station mode (join an existing wifi network)
AT+CWMODE=2 access point mode (create a new wifi network)
AT+CWMODE=3 access point mode + station mode (create a wifi and join an other one at the same time)

select a network around you and join it:

AT+CWLAP list available networks around you that you could join.
AT+CWJAP="SSID","Your Password" (join a network with the ssid (visible name) and your wifi password)

or if you don't want to join an existing network, create your own:

AT+CWSAP_DEF="GoAway!!!","myAss!!!",1,0 (creates a wifi with the name GoAway!!! and an optional password: myAss!!! on channel 1. 
0 means "no encryption", so the password that was set before as myAss!!!" is not used here. (instead 0 setting to 3 uses wpa2_psk, so the password would be used) 
AT+CWDHCP_DEF=1 (turn on DHCP, so others can automatically get an IP address when they connect to your wifi)

either as a station or an AP create a simple server others can connect to:

AT+CIPMUX=1 (1: server accepts multiple connection, 0: single connections only)
AT+CIPSERVER=1,80 (1: create 0:destroy server, 80: listening on port 80)

now you can try to connect to your server, eg with your browser (not a good idea, but still interesting...) we need the ip address for that.

find the ip of your esp8266 board:

AT+CIFSR (wait until you get the below output)
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:d2:47:65"
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"18:fe:34:d2:47:65"

The first line shows the IP address of your board. you can now enter it in a browser: http://192.168.4.1:80 other convenient tests: in the shell: telnet, netcat in puredata: netsend

using the esp8266 with software serial

AT+UART=9600,8,1,0,0

Sets the ESP8266 to 9600 baud, 8 databits, 1 stop bit no parity bit and no flow control.