
They're toggling a GPIO pin fast enough to simulate Ethernet without an Ethernet chip. Basically doing:
set pin HIGH
sleep x cycles, ms, or ns
set pin LOW
....
To form the network packages. It is cursed but it is also genius.
(And you're basically doing 100% CPU load most of the time to get the timing right for this)
Edit: Imagine you'd be flipping a light switch to send network packages. It's basically that.
Yea, I kinda glanced over the PIO part that makes the Raspberry PI more suited for this as I haven't worked with it myself yet.
But you'd have 100% CPU load without it on "regular" GPIO pins.
@steve_m really?
Huh...
Next thing you gonna tell me you're OpenSourcing it as a.general-pirpose Ethernet adaptor to DIY with pinout and firmware to fladh and add a socket to...
@steve_m I’m impressed that this works and at the same time scared for signal integrity
like, what if someone deploys this en masse
„my sensor only works with this specific cable“
It's not that bad actually. The signal integrity isn't the issue. The issue here is that ANY interrupt occurring will mess up your timing and you also basically can't do anything else on that CPU core as it needs to "busy-wait" to toggle the pin at the correct time.
a RP2040 is technically even better suited for this than e.g. ESP8266 that I've seen others do this with in the past as it has special hardware for bit-banging but even though less severe still same issues apply
Just adding a properly* twisted and shielded cable should already allow you to get longer distances to work. After that also moving RX and TX to more "distant" pins could also help to reduce the near end interferences.
But besides that there shouldn't really be much more required to get a clean (but limited by the PIO/CPU of the microcontroller's speed) signal across.
* don't undo the twisting and shielding until the very end, like with patch panels
Should you be able to get energy harvesting via the Ethernet port working as well then I'd be interested in c'n'p-ing your project 😅 (you basically beat me to it then. Wanted to build something like that to read data from the HAN-Port of the smartmeter and send it over wifi/lora/bluetooth/zigbee/... towards a server for charting)
@steve_m wow! That's super impressive! I wouldn't have thought it would be possible to bit-bang ethernet!
Super cool hack!