Welcome! Log In Create A New Profile

Advanced

esp32(esp3D) WIFI module wont talk to marlin (serial port config?)

Posted by mtraven 
esp32(esp3D) WIFI module wont talk to marlin (serial port config?)
January 14, 2025 01:09AM
I'm working with a BTT SKR-2 motherboard and an esp32u add on board. It is the BTT variety of the add on, but the original firmware (if there was any?) is long gone.
I've manage to flash esp3d (3.0) to the wifi module. It created an access point that allowed me to get in and setup the webUI and its connection to my home network.
The whole esp3D web UI seems to be be functional, but it would seem there is no communication between my skr2 motherboard & esp3D.

so the wifi board runs & gets hooked to my network....probably something in marlin then, right?

My understanding is that the esp32 running the wifi acts the same as the serial usb port I use to sent commands to my printer, that is to say its a simple serial connection.
As such, I shouldn't need to mess with the actuall wifi config options, right? Should just be a matter of the right serial port assignments...heres what I have:

#define SERIAL_PORT -1  //emulated USB (hard line)
#define BAUDRATE 250000
#define SERIAL_PORT_2 6     //tested, did not work: 1,2,3, 
#define BAUDRATE_2 250000


in the comments of serial port 2, you can see the options I've tested. rather slow going having to compile each time.

does anyone know what the magic port setup is to make this work?
if not...

do the different serial port defs mean anything? could I reverse 0 & 2 without ill effect?

thanks for your help!

couple sidequests:,
anyone tell me what "marlin embedded" is as it pertains to wifi?
these esp boards have pins for an SPI connection, why aren't we using that? Wouldn't it be faster than serial?
Re: esp32(esp3D) WIFI module wont talk to marlin (serial port config?)
January 14, 2025 02:39AM
Re serial port

You look at the pins diagram [github.com]

There is also a copy in Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h

/**
   *                      -------
   *            GND | 9  |       | 8 | 3.3V
   *  (ESP-CS) PB12 | 10 |       | 7 | PB15 (ESP-MOSI)
   *           3.3V | 11 |       | 6 | PB14 (ESP-MISO)
   * (ESP-IO0) PB10 | 12 |       | 5 | PB13 (ESP-CLK)
   * (ESP-IO4) PB11 | 13 |       | 4 | --
   *             -- | 14 |       | 3 | 3.3V (ESP-EN)
   *  (ESP-RX)  PD8 | 15 |       | 2 | --
   *  (ESP-TX)  PD9 | 16 |       | 1 | PC14 (ESP-RST)
   *                      -------
   *                       WIFI
   */
  #define ESP_WIFI_MODULE_COM                  3  // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this
  #define ESP_WIFI_MODULE_BAUDRATE      BAUDRATE  // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2
  #define ESP_WIFI_MODULE_RESET_PIN         PC14
  #define ESP_WIFI_MODULE_GPIO0_PIN         PB10
  #define ESP_WIFI_MODULE_GPIO4_PIN         PB11


You can either believe the define ESP_WIFI_MODULE_COM

Or you can lookup the STM32F407VG or STM32F429VG datasheet for PD8 and PD9


And note that PD8 can be USART3_TX and PD9 can be USART3_RX, IE this is UART 3


"could I reverse 0 & 2" yes.

"marlin embedded" Marlin firmware itself is runing on a chip that has wifi inbuilt, such as the esp32

"SPI connection, why aren't we using that" because Marlin only supports gcode over UARTS (port numbers >= 0) , USB CDC (port -1 ) and Ethernet (-2 is only supported on Teensy 4.1 boards so far)

Edited 4 time(s). Last edit at 01/14/2025 03:11AM by Dust.
Re: esp32(esp3D) WIFI module wont talk to marlin (serial port config?)
January 14, 2025 02:47AM
The most common reason for serial ports not working is your trying to use buggy 4 year old code on the BTT github

This old broken code sets the cpu clock frequency wrong and messes up most timing, especially baud rates (except for port -1 which actually ignores baudrates)

Edited 1 time(s). Last edit at 01/14/2025 02:57AM by Dust.
Re: esp32(esp3D) WIFI module wont talk to marlin (serial port config?)
January 14, 2025 04:21AM
Quote
Dust
Re serial port

And note that PD8 can be USART3_TX and PD9 can be USART3_RX, IE this is UART 3

"could I reverse 0 & 2" yes.

"marlin embedded" Marlin firmware itself is running on a chip that has wifi inbuilt, such as the esp32

"SPI connection, why aren't we using that" because Marlin only supports gcode over UARTS (port numbers >= 0) , USB CDC (port -1 ) and Ethernet (-2 is only supported on Teensy 4.1 boards so far)

thanks for your thorough response! I went down the chip pin path and got myself thoroughly confused! From what you showed me, it seems the best course of action is to set my second serial to 3 (thats the UART3 right?) and then modify the pins file to use PD8 & PD9. That sound reasonable?
and my usb connection to the computer, thats on a different UART and wont conflict / be placed by the wifi, right?


Quote
Dust
The most common reason for serial ports not working is your trying to use buggy 4 year old code on the BTT github

This old broken code sets the cpu clock frequency wrong and messes up most timing, especially baud rates (except for port -1 which actually ignores baudrates)

I'm not using any BTT firmware, I never have. Currently on marlin 2.1.2.5. and the esp3d firmware came right from esp3d. Though I did have to do a little config on it, clock frequency was one of them, whats is suppose to be?
Re: esp32(esp3D) WIFI module wont talk to marlin (serial port config?)
January 14, 2025 04:56AM
You do not define hardware uart pins in the pins file or the configuration files
You don't need to define them at all, this is done for you as parts of the build environment, and yes they should be named like they are.

-DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8



yes you need #define SERIAL_PORT_2 3

Edited 2 time(s). Last edit at 01/14/2025 04:58AM by Dust.
Re: esp32(esp3D) WIFI module wont talk to marlin (serial port config?)
January 14, 2025 09:52PM
Quote
Dust
You do not define hardware uart pins in the pins file or the configuration files
You don't need to define them at all, this is done for you as parts of the build environment, and yes they should be named like they are.

-DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8

yes you need #define SERIAL_PORT_2 3

well I have already tried that, along with every other port number. What about the discrepancy you pointed out between ESP_WIFI_MODULE_GPIO0(1)_PIN and DPIN_SERIAL3_Rhot smileyTX)?
or are the the RX/TX pins different than the pair of GPIO pins defined in pins_BTT_SKR_V2_0_common.h ?

sorry, something is just not clicking for me...appreciate your patient assistance!


edit: ok just got back to my project, started looking at that pins file, now I see its only active when wifispport is defined, which it is not in my case. Still trying to understand why BTT would put all those pins on the board, I guess they are for other firmewares?

so I set my serial 2 back to "3" and I'll continue to play with it tonight....

Edited 1 time(s). Last edit at 01/14/2025 10:17PM by mtraven.
Re: esp32(esp3D) WIFI module wont talk to marlin (serial port config?)
January 15, 2025 05:22AM
update: once I knew it was serial 3 I needed(thank you), that limited options a lot. and your comment out the BTT firmware & speeds had me look into the firmware I compiled for the esp32. Sure enough the platform IO ini had the port set to 115200, while marlin was set to 250000. 115200 all the way around worked! oddly enough, its the ONLY baud rate that worked. I tried juicing it up to 250,000 or 500,000..matching marlin each time, no luck...but 115200 is fine... EDIT: turns out the firmware(esp3d) was overriding my baud assignments, undermining the tests. Now works at 115200, 250000 and 500000

Gotta say, I'm a little bit disappointed with what I'm actually able to do from the webUI. I can send &rec commands, homing works, movement buttons work, but thats about it. Its not even clear to be if I'll be able to send a gcode file wirelessly to my printers sd card, without that, this whole endevour was a massive waste of time. Maybe I'm just tired & will feel differently tomorrow....

anyways, thats not your problem, your help was pivotal in getting it working, many thanks!

Edited 1 time(s). Last edit at 01/15/2025 10:07PM by mtraven.
Sorry, only registered users may post in this forum.

Click here to login