Enabling Ethernet On The ESP32

The ESP32 is the latest and greatest wonderchip from Espressif. It’s a 32-bit, dual-core chip with WiFi, Bluetooth, and tons of peripherals such as CAN and Ethernet. For most of these peripherals, Espressif already has a few bits of example code, but [Frank Sautter] didn’t like the Ethernet implementation. The ‘stock’ code calls for a TLK110 Ethernet PHY, but that’s an expensive chip when bought in quantity one. A better chip would be the LAN8720, so [Frank] built a board to enable Ethernet on the ESP32 with this chip.

The ESP32 only needs a few components to wire it into an Ethernet network. Just a few resistors, capacitors, and an RJ45 jack will take care of most of the work, but because he’s taking the Ethernet ‘shield’ route, he needs to add his own Ethernet PHY. The Waveshare LAN8720 is the chip for this, but there’s an issue with the pin configuration of the ESP32. GPIO0 on the ESP32 has two functions — the first is pulling it low during startup for serial programming, and the second is the clock input for the EMAC function block. Some bit of circuitry must be devised to allow for both conditions to enable Ethernet on the ESP32.

[Frank]’s solution is to add a few pull-up and pull-down resistors to a breakout board, and use an unused GPIO pin to switch GPIO0 high during startup, but allows a crystal to grab it a bit later. It’s a hack, certainly, but it does allow for some much cheaper chips to be used to give the ESP32 Ethernet.

28 thoughts on “Enabling Ethernet On The ESP32

  1. >The ESP32 only needs a few components to wire it into an Ethernet network. Just a few resistors, capacitors, and an RJ45 jack will take care of most of the work, but because he’s taking the Ethernet ‘shield’ route, he needs to add his own Ethernet PHY

    So, am i reading this correctly?
    Only a few passives were needed, but somehow this design decided to plop an extra chip in there?

    1. Ok, I read some more.

      There is always a need for a chip as ESP32 needs a PHY in all cases. So this writeup mainly addresses about hooking up a different PHY to it than one that espressif recommends.

      Cool, and a job well done by Frank.

  2. When Arduino development for the ESP32 finally matures, it will make a very mighty Arduino compatible device. Quite possibly the most versatile one out there. MicroPython on it will also be amazing!

      1. Yeah, but you can go all the way DIY and make sure you don’t use over 30V, should be cheap with ebay parts.
        I have also used the passive PoE on cheap routers to make them access points, with their own original adapter. Worked fine over smallish distances, 15m.

        1. The RT9400-5V modules are what you’re looking for and they’re cheap. You need to be able to tap into the Ethernet pairs before the transformer though so a socket with integrated magnetics won’t work.

    1. Since the ESP32 ethernet mac only supports 100Mb/s ethernet anyways (as opposed to 1000Mbps), only two of the four wire pairs of an ethernet cable are used => you can use those cheap passive “POE” injectors and splitters for 1.5$ a pair that just use the other two wire pairs for the supply voltage instead of messing with combined power+data on the same lines. It’s way cheaper and you don’t even need a POE-capable switch either but can connect it to any switch, so you also save on that end.

      1. Well the thing is, I already have a 802.3af switch!
        I don’t want a passive injector as that means I still need one (or several) external power supply at the other side…

  3. I got my eps32 coming in any day now.
    Cant wait to start playing with it.
    I have about 23 esp8266 threw out the house now.
    I can see this coming in very handy. I have some projects that will need a faster connection.
    perfect timing.

      1. Hi.
        The Microchip’s ENC28J60 web page (https://www.microchip.com/wwwproducts/en/en022889) says it is:
        “a 28-pin, 10BASE-T stand alone Ethernet Controller with on board MAC & PHY, 8 Kbytes of Buffer RAM and an SPI serial interface.”

        Here, it is using the ESP32’s own MAC, therefore, the ENC28J60 can’t be used this way. However, you can still use it through one of the 4 ESP32’s SPI buses.

        Hope this can help, I may have not understood the question…

  4. Any idea if there would be any reason (aside from cost or silicon real estate) for the ESP32 not to have the PHY inbuilt by itself? My pipe dream would be just to hook the RJ45 with inbuilt transformers into a chip that already comes with both Wifi and wired Ethernet using just 2 or 3 pins.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.