WLED icon indicating copy to clipboard operation
WLED copied to clipboard

Ethernet support

Open aaronk6 opened this issue 6 years ago • 93 comments

I would love to see Ethernet support in WLED to minimize the latency when syncing LED strips to audio.

There are two ESP32 boards that have Ethernet:

  • Olimex ESP32-POE (I have a few of these)
  • wESP32

Ethernet is working fine in ESPHome: https://esphome.io/components/ethernet.html However, ESPHome it is far less powerful compared to WLED when it comes to lighting and effects, so it’s not a real alternative for this particular use-case.

Related posts from the Discord forum:

  • https://wled.discourse.group/t/is-it-possible-to-use-the-esp32s-ethernet-connection/475
  • https://wled.discourse.group/t/wired-networking/567/2

aaronk6 avatar Jul 05 '20 19:07 aaronk6

I agree! Ethernet is also useful in areas where WiFi reception would be bad or would open up to using WLED in more professional applications. Ordered an Olimex POE board and will get to this soon!

Aircoookie avatar Jul 05 '20 23:07 Aircoookie

How about using Adafruit Ethernet FeatherWing, it looks like it fits on top of a nodemcu?

Datasheet attached.

adafruit-wiz5500-wiznet-ethernet-featherwing-1396496.pdf

AndrewApi avatar Jul 22 '20 08:07 AndrewApi

Hi @Aircoookie which Ethernet board did you order for testing? Thanks

dikt1338 avatar Oct 26 '20 18:10 dikt1338

I've ordered an ESP32-GATEWAY today, as I also prefer a wired connection over a wireless one. I would prefer to use the built-in Ethernet MAC over adding additional components.

itavero avatar Nov 04 '20 17:11 itavero

I applied several patches to the original WLED code for testing purposes... seems to work very nice: https://github.com/tbnobody/WLED/tree/ethernet

I am using the Olimex ESP32-POE Board: https://www.olimex.com/Products/IoT/ESP32/ESP32-POE/open-source-hardware

tbnobody avatar Nov 04 '20 18:11 tbnobody

as I also prefer a wired connection over a wired one

Hmmmm, sounds intriguing. How does that one work? 😂

Legsmaniac avatar Nov 04 '20 20:11 Legsmaniac

Also have the Olimex ESP32-POE(-EA)

@tbnobody that's awesome! If it doesn't cause issues for WiFi-only boards I'd be happy about a PR :)

Aircoookie avatar Nov 04 '20 21:11 Aircoookie

@Aircoookie to be honest I didn't know whats the best way to handle a board with wifi and eth capabilities. So I decided to disable the wifi interface when the eth interface is connected and retrieved an IP. But that also leads to the problem that every call of Wifi.Localip() (e.g. in the usermods or libraries) would return the wrong ip. So I decided to implement the Network class (https://github.com/tbnobody/WLED/blob/ethernet/wled00/Network.cpp) which returns the right IP/netmask/gateway etc. based on the current connection state. Don't know if this method suits you. I can send you a PR (after rebasing to your latest commit in the master repo) and we can discuss the required functionality there, or just here :-) Currently I would say its a work in progress status.

tbnobody avatar Nov 04 '20 21:11 tbnobody

@Legsmaniac It was a long day, I guess. 😅

I'm not very familiar with the WLED code base, but I browsed through the changes by @tbnobody yesterday. The abstraction for the Network makes sense. I also think disabling WiFi when there is an Ethernet link makes sense.

I'll have a more thorough look later today and add my feedback to the PR (if I have any). I think there will be a few interesting edge cases, like the Ethernet link is active but there is now DHCP server on the network and no static IP has been configured yet. In such a case WiFi should probably still be activated to do the configuration.

Unfortunately my ESP32 boards with Ethernet are still on their way from Texas to the Netherlands, so I can't test anything just yet.

itavero avatar Nov 05 '20 05:11 itavero

I’ve tried @tbnobody’s branch today. At first glance, this is working well and audio visualization via E131 is much smoother now! 🥳

However, for some reason, the connectivity gets lost when powering off the LED strip through the WLED web interface (clicking the Power button in the upper left). Once the fade is complete, the green status LED on the board is turned off and network connectivity is gone. This is reproducible for me—video attached.

Any idea why this is? I’m also using the Olimex ESP32-POE.


This is what happens when I click the Power button in the app:

Screen Shot 2020-11-07 at 17 03 02

IMG_7454

aaronk6 avatar Nov 07 '20 16:11 aaronk6

I cannot test it at the moment because I used the ESP32-POE for a CO2 sensor project... BUT

in NpbWrapper.h

#ifndef RLYPIN
#define RLYPIN 12  //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
#endif

And in the file https://github.com/espressif/arduino-esp32/blob/master/variants/esp32-poe/pins_arduino.h #define ETH_PHY_POWER 12

That means that the relay function of the WLED Source also powers off the ETH_PHY.

For testing purposes you could change line 255 in platformio.ini from build_flags = ${common.build_flags_esp32} ${common.debug_flags} to build_flags = ${common.build_flags_esp32} ${common.debug_flags} -D RLYPIN=-1

This should disable the relay function of WLED

tbnobody avatar Nov 07 '20 18:11 tbnobody

I'll try to do some testing next weekend. I expect to get my boards in on Monday.

itavero avatar Nov 07 '20 19:11 itavero

@tbnobody Awesome, that worked! I’ll monitor this over the next couple of days and report back if I encounter any other issues.

aaronk6 avatar Nov 08 '20 08:11 aaronk6

Tested out #1316 on my ESP32-POE-EA today! Works very well in my testing and I'm really glad to have ethernet as an option especially for areas where a strong WiFi signal would be hard to achieve or even zones where WiFi is not allowed. It's blistering fast as well.

On an unrelated note, the external antenna on the -EA version of this board is great too. Without ethernet hooked up, I get at least 15dBm better signal than with the same distance and the regular PCB antennas!

Aircoookie avatar Nov 12 '20 22:11 Aircoookie

I've received an ESP32-GATEWAY-IND this week. Hopefully I'll find some time this weekend to also give it a go.

itavero avatar Nov 13 '20 11:11 itavero

Closing since Ethernet support is now merged :) Feel free to use this thread though if there are any further findings or issues regarding Ethernet!

Aircoookie avatar Nov 20 '20 00:11 Aircoookie

WLED ethernet support is awesome, I was just going to look into it and you've already gotten POE ethernet boards integrated.

Is there any chance you can integrate support for the cheap W5500 boards? No POE needed since we have to drive the LEDs with power already. I've got ESP32 boards lying around that I would love to add ethernet to.

Here's the part on Amazon, you can obviously get them much cheaper from China: https://www.amazon.com/gp/product/B07MYY7QW2/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

Here's the wiring for the board to ESP32: https://esp8266hints.wordpress.com/2019/04/05/esp32-w5500-simple-working-example/

This is the wiring of the board to ESP32: https://github.com/jozala/ESP32_W5500_MQTT#physical-connection-between-esp32-and-w5500

GPIO23 <--> MOSI GPIO19 <--> MISO GPIO18 <--> SCLK GPIO5 <--> SCS GPIO11 <--> RESET

lonestriker avatar Dec 04 '20 05:12 lonestriker

@lonestriker I agree W5500 support would be cool. It would also work with ESP8266. However, it does not use the TCP/IP stack of the ESP32 (like the POE board), but its own. That could be challenging, because we'd need to get all the Async network libraries to work well with the default Arduino Ethernet.h library. Not sure it is feasible, but if someone wants to give it a try this is certainly something I'd love having!

Aircoookie avatar Dec 04 '20 07:12 Aircoookie

Ah, I didn't realize we would have to port/integrate a TCP/IP stack as well to get the W5500s to work. Definitely seems like a lot of work. I will try to grab a couple ESP32-POE-EA adapters as well as some ESP32s with external antenna connections to see if I can get past my E1.31 latency issues (I'm running quite a few WLED and Tasmota devices.) If I get a chance later, I'll have a look at what it would take to get TCP/IP on the W5500s, but won't happen until at least after Christmas.

Thanks for the quick reply and all your awesome work with WLED!

lonestriker avatar Dec 04 '20 08:12 lonestriker

Just got my Olimex ESP32 Gateway Rev G board but nothing seemed to get the LEDs to light up. The only way I could get the Ethernet port to show link (and get the web interface) was to compile it myself as the ESP32-POE option (didn't try others, that was my first one and it worked immediately for the Ethernet), and I tried several of the GPIO's for the LED pin but none seemed to do anything. What GPIO's did you all use to test with?

samstreak avatar Dec 07 '20 01:12 samstreak