ESP8266: Difference between revisions

From Medien Wiki
mNo edit summary
mNo edit summary
Line 10: Line 10:
full reference of all AT commands: http://bbs.espressif.com/download/file.php?id=256
full reference of all AT commands: http://bbs.espressif.com/download/file.php?id=256


'''first steps:'''
<source lang="c">
<source lang="c">
AT+RST - resets the board:
AT+RST - resets the board:
ATE1 (verbose)
ATE1 (verbose)
ATE0 (non verbose)
ATE0 (non verbose)
</source>
'''pre-setup''' to either join a network (station mode) or create a new network acces point (AP)
<source lang="c">
AT+CWMODE=1 station mode (join an existing wifi network)
AT+CWMODE=1 station mode (join an existing wifi network)
AT+CWMODE=2 access point mode (create a new 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)
AT+CWMODE=3 access point mode + station mode (create a wifi and join an other one at the same time)
</source>
'''select a network around you and join it:'''
<source lang="c">
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)
AT+CWJAP="SSID","Your Password" (join a network with the ssid (visible name) and your wifi password)
</source>
</source>


create a simple server:
or if you don't want to join an existing network, '''create your own:'''
<source lang="c">
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)
</source>
 
either as a station or an AP '''create a simple server''' others can connect to:
<source lang="c">
<source lang="c">
AT+CIPMUX=1 (1: server accepts multiple connection, 0: single connections only)
AT+CIPMUX=1 (1: server accepts multiple connection, 0: single connections only)
Line 26: Line 43:
</source>
</source>


now you can try to connect to your server, eg with your browser.
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.
we need the ip address for that.


find the ip of the board:
find the ip of your esp8266 board:
<source lang="c">
<source lang="c">
AT+CIFSR
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"
</source>
</source>


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:
other convenient tests:
in the shell: telnet, netcat
in the shell: telnet, netcat
in puredata: netsend
in puredata: netsend

Revision as of 23:59, 20 April 2016

Testing and using a ESP8266 board

Electronic Setup

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