Cheap Power Over Ethernet For The ESP32

While most projects we see with the ESP32 make use of its considerable wireless capabilities, the chip can be connected to the wired network easily enough should you have the desire to do so. [Steve] liked the idea of putting his ESP32s on the wired network, but found the need for a secondary power connection burdensome. So he took it upon himself to modify some cheap Power Over Ethernet (PoE) hardware and create a single-cable solution (Google Translate).

[Steve] bought a PoE module intended for security cameras and ran a close eye over the board to figure out what kind of hardware it was using to generate the nominal 12 V output. He identified an MP2494 step-down converter, and with the datasheet in hand found how the output voltage is configured by changing the values of resistors in the circuit. Swapping out the stock 21.5 kΩ resistor for a 57.1 kΩ one changed the output of the converter to the 5 V necessary for his electronics.

But of course that was only half of the problem solved; he still had to connect the Ethernet side of the PoE device to the Waveshare LAN8720 board that’s providing Ethernet for the ESP32. So he removed the RJ45 jack from the LAN8720 completely, and wired that directly to the connector on the PoE board. Helpfully, the PoE board had all the pins labeled on the bottom side so this wasn’t nearly as tricky to figure out as you might expect (if only it was always that easy).

We’ve previously covered the Waveshare LAN8720 board for anyone who’s interested in the ins and outs of getting their ESP32 talking Ethernet. If you’re wondering how you can put PoE to work for you, our very own [Jonathan Bennett] has been showing off his home Raspberry Pi infrastructure which makes extensive use of the new PoE hat.

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.

Ethernet For Hackers: Transformers, MACs And PHYs

We’ve talked about Ethernet basics, and we’ve talked about equipment you will find with Ethernet. However, that’s obviously not all – you also need to know how to add Ethernet to your board and to your microcontroller. Such low-level details are harder to learn casually than the things we talked about previously, but today, we’re going to pick up the slack.

You might also have some very fair questions. What are the black blocks near Ethernet sockets that you generally will see on boards, and why do they look like nothing else you see on circuit boards ever? Why do some boards, like the Raspberry Pi, lack them altogether? What kind of chip do you need if you want to add Ethernet support to a microcontroller, and what might you need if your microcontroller claims to support Ethernet? Let’s talk.

Transformers Make The Data World Turn

One of the Ethernet’s many features is that it’s resilient, and easy to throw around. It’s also galvanically isolated, which means  you don’t need a ground connection for a link either – not until you want a shield due to imposed interference, at which point, it might be that you’re pulling cable inside industrial machinery. There are a few tricks to Ethernet, and one such fundamental Ethernet trick is transformers, known as “magnetics” in Ethernet context.

Each pair has to be put through a transformer for the Ethernet port to work properly, as a rule. That’s the black epoxy-covered block you will inevitably see near an Ethernet port in your device. There are two places on the board as far as Ethernet goes – before the transformer, and after the transformer, and they’re treated differently. After the transformer, Ethernet is significantly more resilient to things like ground potential differences, which is how you can wire up two random computers with Ethernet and not even think about things like common mode bias or ground loops, things we must account for in audio, or digital interfaces that haven’t yet gone optical somehow.

Continue reading “Ethernet For Hackers: Transformers, MACs And PHYs”

Ethernet For Hackers: Equipment Exploration

Last time, we talked about the surface-level details of Ethernet. They are fundamental to know for Ethernet hacking, but they’re also easy to pick up from bits and pieces online, or just from wiring up a few computers in your home network. Now, there’s also a bunch of equipment and standards that you will want to use with Ethernet – easy to find whether used or new, and typically as easy to work with. Let’s give you a few beacons!

Routers And Switches

Whenever you see a box with a few Ethernet ports, it’s either referred to as a router, or a switch, sometimes people will even use the word “hub”! Fortunately, it’s simpler than it may seem. A router is a smart device, typically with an OS, that ties two or more networks together – routing packers from one network to another, and typically taking care of things like handing out local IP addresses via DHCP. A switch merely helps Ethernet devices exchange packets between each other on the same level – it’s typically nowhere near as smart as a router gets. Oftentimes, a home router will contain a switch inside, so that you can plug in multiple of your home devices at once. That’s the main difference – a switch merely transmits packets between Ethernet-connected devices, while a router is a small computer taking care of packet forwarding between networks and possibly including an Ethernet switch on the side.
Continue reading “Ethernet For Hackers: Equipment Exploration”

Reverse-Engineering The ESP32’s WiFi Binary Blob With A Faraday Cage

The Faraday cage constructed by Jasper Devreker.
The Faraday cage constructed by Jasper Devreker.

As part of a team reverse-engineering the binary blob driver for the ESP32’s WiFi feature at Ghent University, [Jasper Devreker] saw himself faced with the need to better isolate the network packets coming from the ESP32-under-test. This is a tough call in today’s WiFi and 2.4 GHz flooded airwaves. To eliminate all this noise, [Jasper] had to build a Faraday cage, but ideally without racking up a massive invoice and/or relying on second-hand parts scavenged from eBay.

We previously reported on this reverse-engineering project, which has since seen an update. Although progress has been made, filtering out just the packets they were interested in was a big challenge. The solution was a Faraday cage, but on a tight budget.

Rather than relying on exotic power filters, [Jasper] put a battery inside a Faraday cage he constructed out of wood and conductive fabric. To get Ethernet data in and out, a fiber link was used inside a copper tube. Initial testing was done using a Raspberry Pi running usbip and a WiFi dongle.  The Faraday cage provided enough attenuation that the dongle couldn’t pick up any external WiFi signals in listening mode.

The total cost of this build came down to a hair over €291, which makes it feasible for a lot of RF experiments by hobbyists and others. We wish [Jasper] and the rest of the team a lot of luck in figuring out the remaining secrets of Espressif’s binary WiFi blob using this new tool.

Streaming Video From An ESP32

The ESP32, while first thought to be little more than a way of adding wireless capabilities to other microcontrollers, has quickly replaced many of them with its ability to be programmed as its own platform rather than simply an accessory. This also paved the way for accessories of its own, such as various sensors and even a camera. This guide goes over taking the input from the camera and streaming it out over the network to multiple browsers.

On the server side of things, the ESP32 and its attached camera are set up with MQTT, a lightweight communications protocol which uses a publish/subscribe model to send information. The ESP32 is configured to publish its images only, but not subscribe to any other nodes. On the client side, the browser runs a JavaScript program which is able to gather these images and stitch them together into a video.

This can be quite a bit of data to send out over the ESP32’s compact hardware, so there are some tips and tricks for getting more out of these little devices, including using an external antenna for better Wi-Fi signal, or omitting it entirely in favor of Ethernet. As far as getting a lot out of a tiny microcontroller, though, leveraging MQTT really helps the ESP32 go a long way. These chips have come along way since they were first introduced; they’re powerful enough to act as 8-bit gaming consoles too.

Thanks to [Surfskidude] for the tip!

Developing A Power Over Ethernet Stack Light

A common sight on factory floors, stack lights are used to indicate the status of machinery to anyone within visual range. But hackers have found out you can pick them up fairly cheap online, so we’ve started to see them used as indicators in slightly more mundane situations than they were originally intended for. [Tyler Ward] recently decided he wanted his build own network controlled stack light, and thought it would double as a great opportunity to dive into the world of Power Over Ethernet (PoE).

Now the easy way to do this would be to take the Raspberry Pi, attach the official PoE Hat to it, and toss it into a nice enclosure. Write some code that toggles the GPIO pins attached to the LEDs in the stack light, and call it a day. Would be done in an afternoon and you could be showing it off on Reddit by dinner time. But that’s not exactly what [Tyler] had in mind.

An early Arduino-based prototype.

He decided to take the scenic route and designed his own custom PCB that combines an Ethernet interface, PoE hardware, and the ESP32 into one compact unit. It’s no great secret that it only takes a few extra components to plug the ESP32 into the network rather than relying on WiFi, but it’s still not something we see done very often by hobbyists. Rarer still is seeing somebody roll their own PoE solution, but thanks to the in-depth documentation [Tyler] has provided for his circuit, that may change in the future.

On the software side [Tyler] has developed a firmware for the ESP32 that supports both Art-Net and RDM protocols, which are subsets of the larger DMX protocol. That means the controller should be compatible with existing software designed for controlling theatrical lighting systems. If you’d rather take a more direct approach, the firmware also sports a web interface and simple HTTP API to provide some additional flexibility.

While it’s exceptionally impressive, not everyone will need such a robust solution. If you just want a quick and easy way to fire up your stack light, a USB controlled relay and some Python can get you where you need to go.