How to Enable Ethernet on Luckfox Pico Mini

The Luckfox Pico Mini is a thesaurus of a name for a teeny Rockchip RV1103 development board that can run Linux (mainly Ubuntu and buildroot).

It has a bunch of the usual pins and peripherals, but unfortunately there is no traditional networking (WIFI/LAN). You can use RNDIS to run TCP over USB which does work – it just removes the point of an SoC if you need a ‘host’ PC to talk to it.


Fortunately the Mini has a PHY and MAC, broken out to the bottom edge which you can link to an ethernet port. Even better, the Milk Duo V shares a similar interface, so you can use this ethernet adapter.

With a bit of soldering, we have a 5 pin dupont connector added to the exposed pins

Enable ethernet port

You need to enable the MAC by modifying the device tree. This tells the board via firmware which devices to enable.

Open <sdk_dir>/config/dts_config and add:

/**********ETH**********/
&gmac {
   # Change from 'disabled' to 'okay'
   status = "okay";
};

Ref: https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-SDK#4-modifying-device-tree

Rebuild the firmware, plug in the adapter and you’re done!

RJ45 adapter connected to the Mini

Connecting a network cable will get an address via DHCP and everything works… but the LEDs don’t :/

Enable port LEDs

The RJ45 jack on the ethernet board (https://www.lcsc.com/datasheet/lcsc_datasheet_1811141815_HANRUN-Zhongshan-HanRun-Elec-HR911105A_C12074.pdf) has two LEDs which are normally used to show link – cable is connected – and activity – flashing when the network is in use. These LEDs are not broken out like the jack connections, so we’ll need to add connections ourselves with some more soldering.

Two RJ45 breakout boards with heatshrink and nail polish added for resistors.

Its straight-forward – add two 100R resistors to the LED pins, some heatshrink and some nail-polish to mitigate shorts.

We’ll need to also add some extra headers to the Mini’s GPIO. I picked two closest to the ETH pins; 11 and 12. We’ll use 11 (GPIO1_C5_d) for link and 12 (GPIO1_D0_d) for activity. Pretty sure any pin could be used, just avoid the 1.8V ones.

Source: https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-GPIO
Extra pin headers added to GPIO

We need to enable the LED netdev trigger which will add link, rx and tx as triggers to our LEDs.

Open <sdk_dir>/config/kernel_defconfig and make sure you have the following set:

CONFIG_LEDS_GPIO=y
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_NETDEV=y

We’ll now need to add our two new LEDs to the device tree – the same place we enabled the ETH MAC.

Open <sdk_dir>/config/dts_config and add:

&leds {
   compatible = "gpio-leds";
   /** PIN 11 GPIO1_C5_d */
   eth_link {
      gpios = <&gpio1 RK_PC5 GPIO_ACTIVE_HIGH>;
      linux,default-trigger = "netdev";
      default-state = "off";
   };
   /** PIN 12 GPIO1_D0_d */
   eth_act {
      gpios = <&gpio1 RK_PD0 GPIO_ACTIVE_HIGH>;
      linux,default-trigger = "netdev";
      default-state = "off";
   };
};

Ref: https://stackoverflow.com/questions/63484352/device-tree-config-for-netdev-trigger-sources-to-control-led-based-on-link-statu

Build your firmware as usual and copy to an SD card.

Boot and you’ll see that still, nothing lights up :/

Thats because we need to run a few lines to configure which network port we’re monitoring activity and link for – the device tree doesn’t allow us to do that.

Run:

# Might need 'sudo passwd root' to configure your root account first
su root

# Assumes 'eth0' is the port to monitor
echo eth0 > /sys/class/leds/eth_link/device_name
echo eth0 > /sys/class/leds/eth_act/device_name

# Now we'll assign what triggers should be active
echo 1 > /sys/class/leds/eth_link/link
echo 1 > /sys/class/leds/eth_act/rx
echo 1 > /sys/class/leds/eth_act/tx

Tada!

There are many ways to automate this script, but I’ll leave that up to the reader.

Enclosure

If you’re feeling really adventurous, you can combine the LED mod, or just the ethernet mod with my 3D print – https://makerworld.com/en/models/956989

A short ribbon cable and resistors – looking neat

Koitrol – Pond monitoring

Nuts out gnome with the old switched junction box

Our pond was slowly losing water over time, and I wanted to be able to track whether it was normal (i.e. evaporation) or if there was a leak in the pond liner. While doing this, I figured adding some temperature sensors would be handy to know when to restart feeding – fish shouldn’t be fed while the water is less than 10C.

FUN FACT 1: Fish go into low activity mode over winter and won’t eat. Anything you feed will just sink and rot; affecting water quality.

Water and electronics don’t mix, so deciding on a water level sensor took a while. Capacitive systems will eventually corrode, ultrasonic ranging would work but drift over time (small error compounds leading to poor consistency) and float switches don’t show continuous change. I picked an etape sensor which is a thin tube with known resistance which changes as the surround liquid presses on it. The sensor has a second resistive element which is not affected by liquid level, but allows you to compensate for temperature changes.

Using an m5stack Atom Lite MCU, I first tried the built-in ADC which has poor linearity and is bad range (0-1.8v from memory?), so I switched to an external ADC121C021 over I2C which was much better. Popped a couple of DS18B20 waterproof temp probes on and we’re good to go.

FUN FACT 2: ADC stands for analog to digital converter. Its actually a very complicated network of resistors and capacitors to turn a wobbly voltage to a digital reading.

All of this was installed into a waterproof junction box with power in, and the two temperature sensors out. Using custom firmware, I had a websocket-backed web GUI and also a Blynk app to use on my phone. The web GUI allows for depth calibration – connect the returned resistance (in ohms) to a depth (mm). The ADC module was conformal coated incase of water ingress.

Sponges for mechanical mounting pressure and a delightful touch of colour.
Installed with no cable management
Web GIU
Blynk app

Pond-ering forward

The next step was to automate the pond filter. The pond has a basic box filter which has a UV lamp in the top which the water must first flow over, then through various compartments containing different foams before being spat out the from two pipes. After a while the bottom of the filter gets full of fish poop and other biological goodness.

To clean the filter, it must first be drained with a tap (quick de-sludge) on the bottom, and then the filters washed. Before draining, the UV lamp should be turned off, then the pump (the water cools the UV lamp in normal operation). Using switches to do this is the boomer way, so we’ll automate it and waste countless hours invest time into speeding this up in the future.

FUN FACT 3: UV light causes algae to die and clump together giving you clear water. A more cheerful name would be the Algae Genocider

Filter diagram

Using another Atom Lite, I hooked up a 4 channel relay board, two additional relays and a previous energy monitoring PCB I designed a while ago.

Should have cleaned the flux and that isn’t a bodge wire, I don’t make mistakes

The energy monitor board needs 3.3v but the MCU sends 5v. As the serial lines are not isolated from mains, I used a ADUM1201 and a B0505S isolated DC-DC converter into a linear voltage regulator (5v -> 3.3v) and packed it on a prototype board (gray box with arrows and + – on it).

V1. Energy monitoring board is in the light gray junction box with the serial lines out the bottom.

Using the relays, the filter and the pump (both 240V) can be controlled. Using a 150W waterproof 12V power supply, the remaining pond things can be controlled – lights, ball valve and bilge pump.

Originally I used a 12V to USB power supply (the Atom Lite uses USB C to power it) but I had issues with the 12V PSU browning out with the bilge pump (it doesn’t have soft-start, appears as dead short to the PSU on start up) so I just used a mains USB PSU instead.

Before the ball valve, I intended to use a solenoid value to control the sludge line, but solenoid valves required a minimum pressure to work which this gravity-fed system couldn’t supply. I also intended to use a small 12V pump to move the water, but it didn’t self-prime and kept running dry. In the end, I picked up a motorised ball-valve unit which you control by either sending power to 1 of two wires.

A standard relay with its NO and NC contacts will be perfect here – NC for the green/blue wire and NO for red.

I used some clear pipe so you can see the fish turds flying through while draining.

Ball-valve and an embarrassment of mismatched brass fittings with a nice telfon-tape scarf.

Everything was hooked up, some coding and another app later, I can turn lights on and off, drain the pond and see if its empty.

Barely any visible wires – score!
Night-time debugging. Shows the old 12V pump and unused solenoid valve
Web GUI

FINAL FOURTH FUNEST FACT: The pond level is mostly affected by evaporation. We don’t have a leak.

Pond with lights. I definitely didn’t just chuck the pump in

DeLonghi Magnifica now with Alexa

Introduction

I’ve have a DeLonghi Magnifica (ESAM 4200) bean-to-cup coffee machine and the most irritating part is turning it on and waiting for the cleaning cycle to complete – the unit turns on, heats up the water and then pumps a little through to make sure everything is clean.

Since getting an iKettle and being able to groggily say, ‘Alexa, turn on kettle’ in the morning to make the girlfriends tea, I’ve felt embarrassed by my stone-age coffee machine…

Continue reading DeLonghi Magnifica now with Alexa