ESP8266 Firmware F1.1.17.n

Current Sept 2016 vF1_1.9.17

As this is essentially a serial device that will connect a TCP socket to a UART, i.e. anything going into the UART will be captured by the open socket and vice versa. It can be used as a wireless connection to any serial device.

Initial configuration can be done in one of three ways:

1) Via the built in configuration server. In this method the ESP8266 is set as an access point and a device such as a phone or laptop is connected to it, the wireless is open with no passwords. A browser is used with 192.168.4.1 where there is a web page to enable configuration settings. For more details on this see this link

2) The device can also be configured using commands from the serial connection. To prevent the commands from being confused with normal text a command must be entered at the START of a line and be preceded with +++

3) For updating: Version F1.9.7 Now has built in HTTP GET protocol support and so once the connection has been established via any of the two methods above then modifications can be made through a browser address line. For example to change get the information for a device with the address 192.168.4.1 enter 192.168.4.1/+++info in a browser address line.

<enter>+++<command name>[optional parameters]<enter>

Commands can be entered on either side; serial connection or TCP connection. Both have the same method.

Most commands is entered with no parameters returns the current state. where more than one parameter is required these are separated by a comma or space.

(default values in brackets)

This is for when the device is connected to another serial device that has a reset line, for example a ByPic microcontroller. It is so that it can re-set the connected device. Check with the actual device for the GPIO line, it is normally 4 but could be different.

The IP address requires 3 IP values, <address><router address><mask>. It will only take effect if mode is set to 1. Entering 0 for the IP address will activate DHCP and so the router will give the device an IP address. The IP address can be set to 0 to activate DHCP, thus 0,192.168.4.10,255.255.255.0. The router (192.168.4.10) will now give the device an IP address.

Authorisation mode: 0=Open, 1=WEP, 2=WPA_PSK, 3=WPA2_PSK, 4=WPA_WPA2_PSK

Default:  00110001 (0x31)

NOTE1: From factory reset, bit 0 is set to 1. This will allow the built in set up browser to operate. When the save changes button t=on the set up browser is pressed this flag is set to 0. Momentarily setting GPIO0 to ground (a button on some devices) will set this flag back to 1, keeping GPIO0 to ground for greater than 6 seconds will also set the station value to 2 making the device an access point.

NOTE2: If the flag is set to 0 the device acts as a pure bridge, i.e. everything sent to the wifi will appear on the com port and vice-versa. This can be used with a client capable of using TCP sockets.

NOTE3: Communication via browser, javascript is only possible if bit4 is set (16)

NOTE4: With bit 4 set (16) any incoming text will be checked for GET...HTTP (or POST...HTTP) as would be the case if using HTTP protocol. The data sent to the uart will be the GET (or POST) request, the bit between / and HTTP. The data received from the uart uses chunked encoding, transparent to the uart input. The session will close on ether a timout as set by +++restto or on receipt of the following special bytes 3,6,21,26 (^C, ^F, ^U, ^Z).

NOTE5: A POST request will also send the data between /...HTTP to the uart there is then a small delay and then the data following the post is sent, receiving data works in the same way as GET

NOTE6: The difference between GET and POST is that GET can only send the data in the query string but POST can send extra data after the query sting.

NOTE7: WebSocket: This is detected because the host will request a websocket connection, when established the connection will follow the websocket protocol until terminated by the host or device.

Bit 0: When set to 1 this will allow set up from the browser. (default on, until configured)
Bit 1: Verbose mode when set - outputs more information about what is going on
Bit 2: Debug, outputs even more information but mostly to the serial end.
Bit 3: When set echoes commands
Bit 4: HTML capture flag * (V1.9.8) (default on)
Bit 5: Adds CRLF to HTTP GET (V1.9.10) (default on)

* This when enabled captures a GET request from an HTML browser and passes the data to the serial port, the data is what follows the url, so for example if the url was 192.168.5.1/hello fred. Then the data would be "hello fred". Any incoming data from the serial RX will be sent back to the browser provided it is within the time limit set by +++restto. Note that this time limit is reset each time a byte is received by RX and so the time out is from when no characters are received.

In addition to the above from version F1.9.8, the response includes access-control-allow-origin: * and so can be called from another source. This functionality is enabled by default but if the flag is set to 0 it is switched off and all information is passed through to the TX pin.

The sysflag default (0x31 [48]) activates the internal web server that can be browsed to for setting the initial parameters. When the device is configured the flag is set to 0x30.

This fills an internal buffer (up to 256 characters) this the text that follows the command. If spaces are used the text must be within single quotes. For example a simple http 1.1 request to google would be entered as follows:

+++tosend='GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: close\r\n\r\n'
OR
+++tosend='GET%20/%20HTTP/1.1%0d%0aHost:%20www.google.com%0d%0aConnection:%20close%0d%0a%0d%0a'

The first is to send form the UART end, the second from a browser

This will send the text in the 'tosend' buffer to the host and then immediately close the connection. For example to send the text entered above +++send www.google.com,80. any text that is sent back will be presented on the serial link.

This will open the specified socket and it will remain open until either the server closes the port or it is closed here using the drop command (see disconnect). Any text entered after the client socket is open will be sent to that socket and also if the client sends text it will be received by the device.

Added to version 1.9.7 This command below will alter the timeout before sending the terminating HTTP command back to the browser. It is set by default to be 1 second but this could in most circumstances be reduces to something like 100mS

 

I2C Command for this Firmware (removed)

This will only work with the surface mount type of ESP8266 as that has the GPIO 14 that is used for the clock line.

GPIO14 SCL
GPIO2   SDA

The command format follows the BV4221 syntax and uses single letters to manipulate the bus. The I2C commands are as follows:

Writing

The I2C command must begin with the address and any numbers that follow will be sent to the bus. So for example if we have a device that has an address (8 bit address) of 0x7a and we which to send 34,35 and 26 to the device connected to the bus then the following sequence would be required:

The address is specified in decimal or hex at the command itself, all I2C sequences must end in the 'p' command.

Reading

There are two common options for read. when using an 8 bit address, even addresses are write and odd addresses are read. Normally devices are specified by their write address. If as above the address is 0x7a, then the read address would be 0x7b. To read form this device the following sequence is required.

<ret> is either carriage return, line feed or both.

More often than not, most devices require a write before read, the EEPROM address on a memory for example. Where this is the case the following can be implemented.

In the above, the write address is used to send a command first, after that 'r' is used which re-starts the I2C bus and send the read address. It is then just a matter of reading the number of bytes required.

LED & Button

If an LED is connected to GPIO13 then it will show the current state as follows:

A button can be connected to GPIO0: With GPIO0 normally high via a pull up resistor, the button can pull GPIO0 low and will do the following:

FAQ:

Bit 4 (16) of the sysflag must be set in order to communicate with the device via a browser or javascript. Set the flag using the UART side or use telnet or BVSerial.

History: