🛠 Connect a RP2040 to the network with UEXT-CH390 and ESPHome
Objectives
This tutorial aims to transform a Raspberry Pi Pico (RP2040) board into a reliable wired IoT node. By using the UEXT-CH390 module, we bypass Wi-Fi limitations to achieve a stable Ethernet connection, crucial for critical home automation systems. The goal is to integrate this node into Home Assistant via ESPHome, leveraging native DHCP and OTA features.
Required Hardware
- A Raspberry Pi Pico or Pico 2 board.
- The Olimex UEXT-CH390 module (WCH CH390 controller).
- An RJ45 Ethernet cable and an active router/switch.
- A USB-C cable for power and programming.
- A computer with ESPHome installed (via pip or Docker).
Steps
- Hardware Connection: Insert the UEXT-CH390 module into the Pico's UEXT connector. Ensure pins are aligned. The module is powered at 3.3V via the UEXT bus. No soldering is required if using dedicated connectors.
- ESPHome Configuration: Create a new YAML file in your ESPHome editor. Define the platform as
rp2040. Add thespicomponent using the Pico's default pins (GP2, GP3, GP4, GP5 for MOSI, MISO, SCLK, CS respectively, verify with your schematic). - CH390 Declaration: In the
ethernetsection, specify theCH390chipset. ESPHome automatically handles the initialization of the integrated MAC and PHY. - Service Activation: Enable
apifor communication with Home Assistant,otafor wireless updates, andweb_serverfor local access. Configuredhcpfor automatic IP assignment. - Compile and Flash: Compile the firmware. Connect the Pico in bootloader mode (hold BOOTSEL while connecting USB). Drag the generated
.uf2file onto the USB mass storage drive.
Verification
Once the Pico restarts, plug in the Ethernet cable. Check your router's interface to confirm a new device has obtained an IP address. Open the IP address in a web browser to view the local ESPHome interface. In Home Assistant, the node should appear automatically via mDNS discovery. Test latency with a simple command (e.g., reading a virtual sensor) to confirm wired link stability.
Going Further
Explore using the CH390's 16KB SRAM buffer to handle heavier data streams or fast OTA updates. You can also combine this module with other sensors on the remaining I2C or SPI bus to create a high-frequency wired weather station.
Other tutorials for this board
Code examples for this board
esp32-ch390-lwip-station.inoC++rp2040-pico-ch390-micropython.pyPythonesp32-ch390-udp-sensor-gateway.inoC++esp32-ch390-web-server-local.inoC++rp2040-ch390-iot-home-assistant.inoYAMLrp2040-lwip-ethernet-ping-6.inoC/C++ (Raspberry Pi Pico SDK)