ESP support (connection over wifi)

Hi! Is there a way to use ESP8266 with klipper? I can add to my printer just a small ESP-12E (or similar) and connect it to my home server (where klipper and other services are) via wifi and my printer became wireless. I tried ESP-link and socat but it was unsuccessfully. Anyone wandered about this feature?

Not too sure what you are trying to do. Please define “…and my printer became wireless…”

Do you want to replace the printer’s control board with the ESP8266 ?
Do you want to substitute the Raspberry Pi with a ESP8266?
Or do you want to control the power supply of your printer with the ESP8266?

The first option might be possible with a lot of work, for the second option forget about it.
The third option is easily doable with a relay.

1 Like

Sorry for misunderstanding.

I have:

  • Ender 3 with stock control board;
  • ESP 8266
  • Server (not raspberry) running debian with klipper on it and many other programs.

I need to establish the following connection:
Printer control board - ESP - wifi - TCPtoSerial - klipper.

With this connection I get:

  • No need to buy additional raspberry to run klipper on it (because I have home server that can carry klipper and many other things);
  • No need to keep my server near the printer (no usb cable);
  • Printer becomes more mobile: I can take it wherever I want within wifi coverage area and presence of an outlet.

Ah! ok now I understand.

Although I am sceptical on the reliability of such a setup, you might want to have a look at Esp-Link project. GitHub - jeelabs/esp-link: esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer . and this youtube video Using ESP-LINK (ESP8266 Wi-Fi to Serial Bridge) to program an Arduino UNO over Wi-Fi - YouTube

I am very interested so, please keep us informed of your progress.

1 Like

I’m also skeptical of the reliability of this setup, and I would note that a Pi Zero W is not that much more expensive than an ESP8266. It also solves the other 2 goals you have in mind. The Pi eliminates the need to use your server at all, and it makes the printer accessible via wifi.

Look at Espeasy / serial link. On the server side you could use socat.
But this is not guaranteed to work over wifi, timinings are really important.

@lawashnik I’m curious how you got on with this idea?

Im curious aswell. Have you tried Serial-to-WiFi Tutorial using ESP8266


This sounds interesting! Can we brainstorm on how this can be implemented on serial without even touching Klipper if that is an initial step of possiblity?

In fact, this scheme works great. Personally for myself, I made my 3D printer controlled by klipper via Wifi.
The initial data are as follows: FlyingBear Ghost 5 as a 3D printer with a native board (MKS Robin Nano 1.2) and a native Wifi module (Mks robin wifi) flashed with its own firmware (analogue of Serial2Wifi).
As a machine with klipper, a server based on SuperMicro X8DTL-I (two Xeon E5630) with a simple wifi adapter (like this) is used. You can use the usual PC because, the load is extremely small.
Wifi module works in station mode.

Of the changes:

  1. It was necessary to modify the MCU firmware so that it will automatically enable the Wifi module on the board.
  2. for a server with klipper, socat was used to redirect traffic to the MCU. For good, you need to add another type of connection to the MCU - over the network.

Printing is stable. The last big seal lasted 9 hours.
If interested, I can send more information.

Hi! Thank you for your post. I start this topic about 2 years ago, the configuration of my printer changed since then. But I think this question should be answered. So if you want you can provide us a step by step tutorial, this will be a good work. I think the main questions are:

  • how to set up socat on server side (because when I tried socat I couldn’t get a good result);
  • how did you modified the firmware (if modifying is necessary);
  • what is your printing speed? Is connection stability depends on printing speed?
    -are you using wifi router or direct connection?

It’s great that my work is still relevant.
In fact, I took an already existing idea as a basis [How To] Wireless Klipper Printing - YouTube
The only thing that did not work well for the author of this video was the communication channel in station mode.
It seemed strange to me. this mode is implemented at the hardware level.
The problem turned out to be in the esp8266 mode enabled by default (i.e. in the call to WiFi.setSleepMode(WIFI_NONE_SLEEP);).

Okay, let’s go sequentially.
I used MKS Robin Nano 1.2 (from FlyingBear Ghost 5) as MCU. The 3D printer came with the MKS Robin WiFi WiFi module.
Pins PA9 / PA10 were chosen as the port of interaction with Klipper (which is logical).
In order for the WiFi module to work and transmit data, it must be turned on. The corresponding code was torn out of the Marlin firmware and put into the UART initialization procedure. (see Attachment)

Next, you need firmware for the WiFi module itself, which would establish an accurate WiFi connection and raise a tcp server to send data to the UART.
I was interested in researching esp8266 and wrote this firmware myself (see attachment). The firmware was written using the Arduino IDE.
There is a lot of information on how to assemble the firmware using the Arduino IDE and flash it into esp8266 on the Internet - I will not repeat it.
Will I clarify one moment - so far this firmware is just a sketch, which still needs to be completed but in a more normal state.

Now about the counterpart on the PC. Klipper works primarily with the serial port. Based on the total, we use socat as a classic serial2tcp translator.
I ran it through the systemd service, on which the klipper service depends.
The speed of interaction with klipper left by default. The documentation for klipper says that this is enough.

Socat’s startup options are as follows:
socat -dd pty,link=/home/klipper/printer_fb5_data/comms/virtualcom,ispeed=b250000,ospeed=b250000,raw,echo=0 TCP4-CONNECT:,nodelay,forever,interval=1

Now a little about the stand itself.
There is no router in the room where the 3D printer and PC are located. It is simply not needed there and its role is partially performed by the same PC. Thus, the PC itself acts as a WiFi access point.
WiFi is distributed via a small USB adapter (written above) without a visible antenna. The distance from the printer to the PC in a straight line is about 3 meters.
Based on the fact that nothing happened with the printing of the model in 9 hours, we can conclude that WiFi itself works without problems.

However, there are subtleties in my current implementation.
When a WiFi module is connected to an access point on a PC, it is given an IP address via DHCP.
In my current configuration, this address is not static (yet), but it can be done, and in various ways.
One of them is to make sure that the module’s WiFi address is written in it itself or configured somehow (via http for example).
This has not been done yet, but I plan to do so in the near future.

It seems to have answered all the questions. (3.2 KB)