Saturday, November 8, 2025

ESP8266 serial bridge WIFI to UART

 ESP-01 -> USB-TTL

===================

3v3, EN -> 3V
TX      -> RX
RX -> TX
GND,IO0 -> GND

IO0 -> GND -- programming mode
IO0 -> 3.3V -- normal boot mode

RST - via button - GND - when you press button it resets

It draws around 60-80ma @ 3.3V. Can check the USB to TTL 3.3V regulator on the back for max power. Mine is AMS1117. Can supplu 1A - (1.5A maximum)

sudo apt install esptool

Read chip info:
esptool.py --port /dev/ttyUSB0 flash_id
esptool.py --port flash_id

Output:
Detecting chip type... ESP8266
Chip is ESP8266EX
Detected flash size: 1MB

The cip supports external FLASH via SPI up to 16MB. You can find 1MB or 4MB versions.

Dowload firmware:
https://www.espressif.com/en/support/download/all?keys=8266 pick ESP8266 NONOS SDK
Direct link: 
https://codeload.github.com/espressif/ESP8266_NONOS_SDK/zip/refs/tags/v3.0.6

extract and go into /bin

esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash \
  --flash_mode dout --flash_size 1MB \
  0x00000 boot_v1.7.bin \
  0x01000 at/512+512/user1.1024.new.2.bin \
  0xFC000 esp_init_data_default_v08.bin \
  0x7e000 blank.bin
  0xfe000 blank.bin

Make a backup:
esptool.py --port /dev/ttyUSB0 read_flash 0x00000 0x100000 esp8266_at_backup.bin
Restore backup:
esptool.py --port /dev/ttyUSB0 write_flash 0x00000 esp8266_at_backup.bin

Connect to ttyUSB0 you can use CuteCom. Use speed 115200 and at INPUT select CR/LF.
Commands: 
https://docs.espressif.com/projects/esp-at/en/release-v2.2.0.0_esp8266/AT_Command_Set/index.html
AT
Ouput: OK

AT+GMR
Output:

AT version:1.7.6.0(Jan 24 2022 08:56:02)␍␊

SDK version:3.0.6-dev(072755c)␍␊

compile time:Jun 17 2024 07:38:00␍␊

Bin version(Wroom 02):1.7.6␍␊

AT+CWMODE?

→ shows current Wi-Fi mode:

  • 1 = Station

  • 2 = SoftAP

  • 3 = Both

Set to ap : AT+CWMODE=1
Scan for networks: AT+CWLAP
Connect: AT+CWJAP="YourSSID","YourPassword"
Show ip: AT+CIFSR

These are saved even on reboot.
Next section must be sent on every reboot:

Step 1 — start a TCP connection to a remote device
AT+CIPMUX=0
AT+CIPSTART="TCP","192.168.1.50",8888
Step 2 — enter transparent (bridge) mode
AT+CIPMODE=1
AT+CIPSEND

Compile and configure ESP3D as a Serial UART to WIFI Bridge

git clone https://github.com/luc-github/ESP3D.git

Configuration before compile:

ESP3D/platformio.ini   --- add to the end of the file
[env:esp01_1m_bridge]
platform = espressif8266@4.1.0
board = esp01_1m
framework = arduino
monitor_speed = 115200
monitor_filters = send_on_enter, colorize, esp8266_exception_decoder
board_build.f_cpu = 160000000L
board_build.f_flash = 40000000L
board_build.flash_mode = dout
board_build.ldscript = eagle.flash.1m.ld
upload_resetmethod = ck
upload_speed = 115200
extra_scripts = pre:platformIO/extra_script.py
build_flags =
    -D ESP3D_BRIDGE            ; enable bridge mode (no web UI)
    -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
    -DNONOSDK221=1
    -DNDEBUG
    -DVTABLES_IN_FLASH
lib_ignore =
    ESP32SSDP
    TFT_eSPI
    esp32-usb-serial

ESP3D/esp3d/configuration.h
uncomment and replace xxx with your router data
#define STATION_WIFI_SSID "xxx"
#define STATION_WIFI_PASSWORD "xxxxxxxxx"

Optional if you want better speed

ESP3D/esp3d/src/core/esp3d_settings.cpp

#define DEFAULT_BAUD_RATE "230400"

#define DEFAULT_SERIAL_BRIDGE_BAUD_RATE "230400"


Compile

====

python3 -m venv platformio

source platformio/bin/activate

pip install platformio

cd ESP3D

platformio run -e esp01_1m_bridge --target clean   
platformio run -e esp01_1m_bridge


Upload firmaware

====== dont forget to have IO0 to GND and reset before uploading 

esptool.py --port /dev/ttyUSB0 flash_id

esptool.py --port /dev/ttyUSB0 erase_flash

esptool.py --port /dev/ttyUSB0 write_flash 0x00000 .pioenvs/esp01_1m_bridge/firmware.bin


If you want more speed use a ESP32

git clone https://github.com/luc-github/ESP3D.git

build_flags =

    -DESP_SERIAL_BRIDGE
    -DCONFIG_FREERTOS_HZ=1000

platformio = pio (same command)

pio run -e esp32dev
pio run -e esp32dev -t upload

ESP_LINK for ESP6288

Go to https://github.com/jeelabs/esp-link/releases
Pick latest stable version
You have a Download link of the compiled firmware in the text, NOT in the Assets.


curl -L 
http://s3.voneicken.com/esp-link/esp-link-v3.0.14-g963ffbb.tgz | tar xzf -

Unzip and Flash:
dout is important and 1MB for the 1mb version ESP-01

esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 460800 write_flash \
  -fs 1MB -fm dout -ff 40m \
  0x00000 boot_v1.6.bin \
  0x01000 user1.bin \
  0xFC000 esp_init_data_default.bin \
  0xFE000 blank.bin

Then connect to ESP_LINK acces point - access 192.168.4.1 and connect to your AP.

ESP6288 WIFI BRIDGE FOR KLIPPER

phyton3 -m venv platformio
source platformio/bin/activate
pip install platformio

mkdir esp8266_raw_bridge
cd esp8266_raw_bridge
pio init --board esp01_1m

[platformio.ini]
[env:esp01_1m]
platform = espressif8266@4.1.0
board = esp01_1m
framework = arduino

monitor_speed = 115200
upload_speed = 115200

; 1MB flash, safe mode for cheap modules
board_build.flash_mode = dout
board_build.f_cpu = 80000000L


[src/main.cpp]
#include <ESP8266WiFi.h>

const char* ssid     = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";

WiFiServer server(8888);
WiFiClient client;

void setup() {
  Serial.begin(115200);
  delay(200);

  WiFi.mode(WIFI_STA);
  WiFi.setSleepMode(WIFI_NONE_SLEEP);   // disable WiFi power save (reduces jitter)
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
  }

  server.begin();
  server.setNoDelay(true);              // disable Nagle -> lower latency
}

void loop() {
  if (!client || !client.connected()) {
    client = server.available();
    return;
  }

  // TCP → UART
  while (client.available()) {
    Serial.write(client.read());
  }

  // UART → TCP
  while (Serial.available()) {
    client.write(Serial.read());
  }
}


Compile:
pio run -e esp01_1m
Erase flash:
esptool.py --port /dev/ttyUSB0 erase_flash
Upload:
pio run -e esp01_1m -t upload --upload-port /dev/ttyUSB0

Test:
Check router for IP
ping IP
telnet IP 8888
Open serial - I prefer CuteCom GUI, but can use
screen /dev/ttyUSB0 115200

Now type something in telnet and serial, and you should see it on the other side.

Now for KLIPPER
Connect RX,TX and power to ESP6288

Serial to TCP bridge on host running klipper (use your IP)
socat pty,raw,echo=0,link=/tmp/espbridge tcp:192.168.1.176:8888

klipper config:
[mcu]
serial: /tmp/espbridge

No comments:

Post a Comment