|
1 | 1 | # esp8266-basic-bridge
|
2 | 2 |
|
3 |
| -This is the "basic" esp8266 WiFi to serial bridge, in other words, it accepts |
4 |
| -connection tcp port 23, gets all data from it, sends it to the UART (serial |
5 |
| -port) and the other way around. This is the way to go to make your |
6 |
| -non-networking microcontroller WiFi-ready. If you add an RS-232C buffer |
7 |
| -(something like a MAX232), you can even make your non-networking peripherals |
8 |
| -like printers etc. available over the wireless lan. |
| 3 | +This is the "basic" esp8266 WiFi to serial bridge, in other words, it accepts connections |
| 4 | +on tcp port 23, gets all data from it, sends it to the UART (serial port) and the other way |
| 5 | +around. This is the way to go to make your non-networking microcontroller WiFi-ready. If you |
| 6 | +add an RS-232C buffer (something like a MAX232), you can even make your non-networking |
| 7 | +peripherals like printers etc. available over the wireless lan. |
9 | 8 |
|
10 |
| -This implementation is certainly not the first, there are various others |
11 |
| -implementations around but I decided to make my own for various reasons: |
| 9 | +This implementation is certainly not the first, there are various others implementations around |
| 10 | +but I decided to make my own for various reasons: |
12 | 11 |
|
13 |
| -- no pain no gain, in other words, just using someone else's stuff won't learn |
14 |
| - you anything; |
15 |
| -- I noticed the existing implementations were heavily based on Espressif's |
16 |
| - examples, the examples aren't quite stunning when it comes to programming |
17 |
| - skill level, they're clumsy and not efficient; |
18 |
| -- the exisiting implementations tend to be bloated, way too much code is |
19 |
| - copied and pasted which makes it hard to understand; |
20 |
| -- none of the existing implementations does (did?) feature a completely |
21 |
| - transparent where data forwarding is carried out over one tcp port and |
22 |
| - setting up the bridge is done over another tcp port; |
23 |
| -- not much active development on most of them, I have a lot of plans for |
24 |
| - development on queue; |
25 |
| -- my version implements heavy buffering and is completely interrupt-driven, |
26 |
| - so the chances on dropping bytes or buffers getting overrun is are very |
27 |
| - small, even at high uart speeds (I am using 460800 baud...); |
28 |
| -- I'm using next to none of all of the borked sdk functions, I try to address |
29 |
| - the hardware directly wherever that's possible, if documentation is available |
30 |
| - (which, unfortunately, is quite sparse), creating good examples for those |
31 |
| - who are planning to start developing on the esp8266 but are reluctant to |
32 |
| - start due to the lack of documentation. |
| 12 | +- no pain no gain, in other words, just using someone else's stuff won't learn you anything; |
| 13 | +- I noticed the existing implementations were heavily based on Espressif's examples, the |
| 14 | + examples aren't quite stunning when it comes to programming skill level, they're clumsy and not |
| 15 | + efficient; |
| 16 | +- the exisiting implementations tend to be bloated, way too much code is copied and pasted |
| 17 | + which makes it hard to understand; |
| 18 | +- none of the existing implementations does (did?) feature a completely transparent where data |
| 19 | + forwarding is carried out over one tcp port and setting up the bridge is done over another |
| 20 | + tcp port; |
| 21 | +- not much active development on most of them, I have a lot of plans for development on queue; |
| 22 | +- my version implements heavy buffering and is completely interrupt-driven, so the chances on |
| 23 | + dropping bytes or buffers getting overrun is are very small, even at high uart speeds (I am |
| 24 | + using 460800 baud...); |
| 25 | +- I'm using next to none of all of the borked sdk functions, I try to address the hardware |
| 26 | + directly wherever that's possible, if documentation is available (which, unfortunately, is |
| 27 | + quite sparse), creating good examples for those who are planning to start developing on the |
| 28 | + esp8266 but are reluctant to start due to the lack of documentation. |
33 | 29 |
|
34 | 30 | Having said this, it's very loosely based on the work of beckdac
|
35 |
| -(https://github.com/beckdac/ESP8266-transparent-bridge), which I used as a |
36 |
| -starting point, but hasn't been any original code left for some time ;-) |
| 31 | +(https://github.com/beckdac/ESP8266-transparent-bridge), which I used as a starting point, but |
| 32 | +hasn't been any original code left for some time ;-) |
37 | 33 |
|
38 | 34 | This is how it works:
|
39 | 35 |
|
40 |
| -- attach your microcontroller's uart lines or RS232C's line driver lines |
41 |
| - to the ESP8266, I think enough has been written about how to do that; |
42 |
| -- load a generic "AT-command" style firmware into the ESP8266; how to do that |
43 |
| - should be on the page you're downloading the firmware from; |
44 |
| -- setup the wlan parameters (SSID and password) from this firmware, using |
45 |
| - a terminal emulator, check it's working and write to flash (if the |
46 |
| - firmware doesn't do that automatically); |
47 |
| -- now flash this firmware, for example with the esptool.py command, something |
48 |
| - like this: esptool.py --port /dev/pl2303 --baud 460800 write_flash 0x00000 \ |
49 |
| - fw-0x00000.bin 0x40000 fw-0x40000.bin |
50 |
| - (replace \ bij joining the two lines). Replace /dev/pl2303 by the proper |
51 |
| - device node. Yes, the esp8266 can be flashed on this high speed, it's |
52 |
| - autoprobing the baud rate. If it doesn't succeed immediately, try again, |
53 |
| - sometimes the esp8266 gets the baud rate wrong. If it still doesn't work, |
54 |
| - try at a lower speed. |
55 |
| -- after flashing restart; in theory this is not necessary, but I found the |
56 |
| - uart won't start if you leave out the reset; |
| 36 | +- attach your microcontroller's uart lines or RS232C's line driver lines to the ESP8266, I think |
| 37 | + enough has been written about how to do that; |
| 38 | +- load a generic "AT-command" style firmware into the ESP8266; how to do that should be on the |
| 39 | + page you're downloading the firmware from; |
| 40 | +- setup the wlan parameters (SSID and password) from this firmware, using a terminal emulator, |
| 41 | + check it's working and write to flash (if the firmware doesn't do that automatically); |
| 42 | +- now flash this firmware, for example with the esptool.py command, something like this: |
| 43 | + esptool.py --port /dev/pl2303 --baud 460800 write_flash 0x00000 fw-0x00000.bin 0x40000 fw-0x40000.bin |
| 44 | + Replace /dev/pl2303 by the proper device node. Yes, the esp8266 can be flashed on this high |
| 45 | + speed, it's autoprobing the baud rate. If it doesn't succeed immediately, try again, sometimes |
| 46 | + the esp8266 gets the baud rate wrong. If it still doesn't work, try at a lower speed. |
| 47 | +- after flashing restart; in theory this is not necessary, but I found the uart won't start if you |
| 48 | + leave out the reset; |
57 | 49 | - do a telnet to port 24 of the ip address, type help and enter;
|
58 | 50 | - you will now see all commands;
|
59 |
| -- use the commands starting with baud to setup the uart, after that, issue |
60 |
| - the config-write command and use the reset command to restart; |
61 |
| -- after restart you will have a transparent connection between port 23 and |
62 |
| - the uart, whilst port 24 remains available for control. |
| 51 | +- use the commands starting with baud to setup the uart, after that, issue the config-write |
| 52 | + command and use the reset command to restart; |
| 53 | +- after restart you will have a transparent connection between port 23 and the uart, whilst port 24 |
| 54 | + remains available for control. |
63 | 55 |
|
64 | 56 | These are the currently implemented commands on port 24:
|
65 | 57 |
|
66 |
| -short long parameters description |
| 58 | + short long parameters description |
67 | 59 |
|
68 |
| - cd config-dump none shows the complete configuration as |
69 |
| - stored in non volatile memory |
70 |
| - cw config-write none writes config to non volatile memory |
71 |
| - ? help none shows list of commands |
72 |
| - q quit none disconnect the control channel |
73 |
| - r reset none reset the esp8266, necessary if you |
74 |
| - make changes to the uart parameters |
75 |
| - s stats none shows some statistics, these may |
76 |
| - change over time |
77 |
| - st strip-telnet 0 or 1 0 = disable, 1 = enable |
78 |
| - toggle stripping of telnet "garbage" |
79 |
| - at the start of a connection; don't |
80 |
| - forget to write using cw! |
81 |
| - ub uart-baud baud rate any baud rate you like, forget the |
82 |
| - 300-600-1200-2400-etc. list, the |
83 |
| - esp8266 can freely use any baud rate |
84 |
| - you like; don't forget to write and |
85 |
| - reset |
86 |
| - ud uart-data 5 to 8 the number of data bits, usually 8 |
87 |
| - us uart-stop 1 or 2 the number of stop bits, usually 1 |
88 |
| - up uart-parity none/even/odd the parity, usually none; don't |
89 |
| - forget to set data bits to 7 if you |
90 |
| - want to use parity |
91 |
| - wd wlan-dump none show everything known about the curent |
92 |
| - wlan connection (which isn't very |
93 |
| - much, blame Espressif...) |
| 60 | + cd config-dump none shows the complete configuration as |
| 61 | + stored in non volatile memory |
| 62 | + cw config-write none writes config to non volatile memory |
| 63 | + ? help none shows list of commands |
| 64 | + q quit none disconnect the control channel |
| 65 | + r reset none reset the esp8266, necessary if you |
| 66 | + make changes to the uart parameters |
| 67 | + s stats none shows some statistics, these may |
| 68 | + change over time |
| 69 | + st strip-telnet 0 or 1 0 = disable, 1 = enable |
| 70 | + toggle stripping of telnet "garbage" |
| 71 | + at the start of a connection; don't |
| 72 | + forget to write using cw! |
| 73 | + ub uart-baud baud rate any baud rate you like, forget the |
| 74 | + 300-600-1200-2400-etc. list, the |
| 75 | + esp8266 can freely use any baud rate |
| 76 | + you like; don't forget to write and |
| 77 | + reset |
| 78 | + ud uart-data 5 to 8 the number of data bits, usually 8 |
| 79 | + us uart-stop 1 or 2 the number of stop bits, usually 1 |
| 80 | + up uart-parity none/even/odd the parity, usually none; don't |
| 81 | + forget to set data bits to 7 if you |
| 82 | + want to use parity |
| 83 | + wd wlan-dump none show everything known about the curent |
| 84 | + wlan connection (which isn't very |
| 85 | + much, blame Espressif...) |
94 | 86 |
|
95 |
| -More commands will follow, especially for driving the gpio2 pin, probably |
96 |
| -also pwm and maybe even i2c. Also there will be an option to disable some |
97 |
| -debug output from the wlan subsystem at startup. The boot sequence (which |
98 |
| -normally show as garbage) can't be suppreseed, though, unfortunately. |
| 87 | +More commands will follow, especially for driving the gpio2 pin, probably also pwm and maybe even |
| 88 | +i2c. |
99 | 89 |
|
100 |
| -See here for latest news and join the discussion: |
101 |
| -http://www.esp8266.com/viewtopic.php?f=11&t=3212. |
| 90 | +See here for latest news and join the discussion: http://www.esp8266.com/viewtopic.php?f=11&t=3212. |
0 commit comments