[Record] How to setup a WiFi-UART serial bridge by using NodeMCU
Scenario
In order to control or access a DUT without NIC, we can use ESP8266 as our solution.
User 1 can telnet to NodeMCU to control Raspberry Pi 2 remotely through WLAN or WAN as shown below.
ESP8266 is a cost-effective and highly integrated Wi-Fi MCU for IoT applications.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Hardware
- Access Point Or a Soft AP (enabling wireless hotspot on a phone)
- NodeMCU v3
- Raspberry Pi 2 Model B (including SD card and power supply)
- Laptop or Desktop with a wireless NIC
- type-A and micro USB cable
UART connection between RPi and NodeMCU
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- NodeMCU RXD0 to RPi UART0 TX
- NodeMCU TXD0 to RPi UART0 RX
- NodeMCU GND to RPi UART0 GND
Software
Enable UART in RPi2
Download and install CP210x_Windows_Drivers for NodeMCU v3
How to flash the esp-link firmware to NodeMCU
1. Prepare esp-link firmware
One of the most well-known (appeared on Hackaday’s blog) and well-designed projects to make ESP8266 as a WiFi-UART bridge is jeelabs’s esp-link.
- esp-link-v3.0.14-g963ffbb
whcih contains
- boot_v1.6.bin
- blank.bin
- esp_init_data_default.bin
- user1.bin
- user2.bin
- wiflash
- avrflash
- Download esp-link firmware: currently stable version is esp-link-v3.0.14-g963ffbb
- Extract esp-link-v3.0.14-g963ffbb.tgz
- Untar esp-link-v3.0.14-g963ffbb.tar
2. Prepare NodeMCU Flasher
- NodeMCU flasher is a firmware programmer for NodeMCU DEVKIT V0.9.
- You can use it to program NodeMCU DEVKIT or your own ESP8266 board.
- Download ESP8266Flasher.exe Win64/Release or Win32/Release
3. Flash esp-link firmware
- Execute ESP8266Flasher.exe
- Config it with
- flash boot_v1.X.bin from the official SDK or from the release tgz to 0x00000
- flash blank.bin from the official SDK or from the tgz to 0x3FE000
- flash esp_init_data_default.bin from the official SDK or from the tgz to 0x3FC000
- flash user1.bin to 0x01000
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- Flash it
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
You will see the LED on esp-12 module is blinking during flashing the firmware as shown below.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- Finish flashing
- The blue LED on esp-12 module will be dark.
- You will see the log end with the line "Note:Serial port disconnected."
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- Reset NodeMCU by clicking the RST button on the board
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
The LED will light up for about 2 secs while you press the RST button.
How to config NodeMCU
1. Boot NodeMCU
We can read u-boot messages while booting NodeMCU with esp-link firmware by using a serial console with 76600 baud rate as shown below.
- Boot by connecting a serial console with 76600 baud rate
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
We can read messages after booting u-boot by using a serial console with 115200 baud rate as shown below.
- Boot by connecting a serial console with 115200 baud rate

2. Connect to NodeMCU AP
After reboot NodeMCU, you should see a new WiFi network with SSID ESP_XXXXX as shown below. And you should connect to it.
===>
3. Config it
-
Open your browser with http://192.168.4.1 to see the esp-link homepage as shown below

-
Config "Pin assignment" to esp-12

-
Config WiFi station
4. Finish

Demo
Topology

Procedure
- Enable the mobile hotspot in my phone
- Open my laptop and connect to my mobile hotspot
- Connect NodeMCU to RPi2 with a type-A and micro USB cable
- Connect UART interface between RPi2 and NodeMCU
- Power up RPi2

- Ping 192.168.90.11 -t

- telnet to 192.168.90.11

- Login to RPi2 successfully

The blue LED on NodeMCU will blink once when you input a character each time.
Troubleshooting
Cannot see what I am typing in telnet through teraterm
Fix it by enabling localecho.

Appendix
NodeMCU Flasher logs
NodeMCU programming in C with Arduino IDE
Reference to this article.

We can upload these compiled code to NodeMCU by with Arduino IDE.

Methods to access the console
- telnet
- uC console

- socat
You can also use socat instead of telnet:
Another way of using socat is to redirect the TCP to a /dev/tty entry like /dev/vmodem0 for example:
One socat is running, you can connect to the device (with CRTL-C working and being able to out of top) with screen:
Reference
https://www.espressif.com/en/products/socs/esp8266
https://github.com/jeelabs/esp-link
https://github.com/nodemcu/nodemcu-flasher
https://atadiat.com/en/e-esp8266-esp32-wifi-serial-bridge-converter/amp/
https://pi4j.com/1.2/pins/model-2b-rev1.html
https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads
https://www.abelectronics.co.uk/kb/article/1035/serial-port-setup-in-raspberry-pi-os
https://www.hackster.io/higgsino/huzzah-feather-esp8266-with-max3232-as-rs232-to-wifi-device-5004f6
https://www.hackster.io/chuygen/wireless-serial-bridge-d149ef
http://www.zoobab.com/esp8266-serial2wifi-bridge
https://www.printables.com/model/226933-case-for-nodemcu-esp8266-v3-rs232-to-ttl-breakout-