An Elegant Ethernet Library For Your Next RP2040 Project

The Pi Pico board on top of a white box with an Ethernet jack, with a sensor module plugged onto the Pico's pin headers. A black MicroUSB and a green Ethernet cable are connected to this device.

A few days ago we covered a project that brought Ethernet connectivity to the Raspberry Pi Pico using little more than some twisted pair and a RJ-45 connector. It was a neat trick, but not exactly ready for widespread adoption. Looking to improve on things a bit, [tvlad1234] has taken that project’s code and rewritten it into a friendly library you can use with any RP2040 board.

In case you missed it, the initial demo did 10BASE-T transmission by bit-banging with the PIO, and was able to send UDP messages to devices on the wired LAN. It was an impressive accomplishment, but its code didn’t make it easy to build your project around it. This new library makes UDP messaging as easy as a printf, offloading all non-PIO-managed Ethernet signal work onto the RP2040’s second CPU core. The library even generates a random MAC address out of your flash chip’s serial number!

As a demonstration of the new library, [tvlad1234] has put together a simple Ethernet-connected temperature monitor using the BMP085 or BMP180 sensor connect over I2C. If you feel like you could use an Ethernet transmit-only sensor in your life, browsing the source code would be a great start.

17 thoughts on “An Elegant Ethernet Library For Your Next RP2040 Project

  1. IMHO, this is really a waste of time. Without receive, DHCP is out of the question. So you’re going to have to make it static IP. Might as well just buy a W5500-EVB-Pico, or a EM510 MiniMo.

  2. Ethernet require a transformer to isolate common mode voltage between different loads, using only resistors as here you made a short between different ground, risking to burn the 3V3 regulator or worse the RP2040 GPIO

        1. How does this invalidate that the hack HAS a pulse transformer? HaD might not be fun for you, if you only want to use ready-for-use industrial solutions. Just let people have their joy.

          1. I just wanted to warn that without using a transformer a short between masses is made, while using a transformer with impedance not in compliance with the standard, the performance of the LAN are penalized by increasing the BER. Up to your joy

      1. yes, using capacitors instead of transformer, you have the advantage of very small footprint and remove the DC, so no risk of shorting GND. Anyway you have to choose between required receiver voltage swing or right termination resistance. In both cases you cannot reach the full performance of the standard 10 Mbps. This is why the IEEE standard recommend a pulse transformer with given ratio and impedance. Nothing impossible to do for an HaD user with fun, just use the right value, not a generic random ferrite choke

  3. Could a rp2040 cpu run directly inside a rj45 connector, with serial debug io and PoE. Turning a switch 48 PoE switch into a mini 48 unit cluster, all directed from a computer connected through dual sfp+ ports in the back.

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.