🛠 Complete Use Case: Ethernet Connectivity for Raspberry Pi Pico
Objectives
This tutorial aims to transform a Raspberry Pi Pico into a reliable Ethernet network node. Unlike Wi-Fi, which is prone to interference, Ethernet offers constant latency and enhanced security. We will configure the UEXT-CH390 card to obtain an IP address via DHCP and verify connectivity.
Required Material
- A Raspberry Pi Pico (or Pico 2) board.
- The UEXT-CH390 expansion card.
- An RJ45 Ethernet cable connected to your router.
- A computer with the Raspberry Pi Pico SDK or Arduino IDE installed.
- Connection cables if necessary (though UEXT connectors are integrated).
Steps
- Hardware Preparation: Insert the UEXT-CH390 card into the UEXT connectors of the Raspberry Pi Pico. Ensure the pins are aligned correctly. The module is powered at 3.3V via the UEXT bus.
- Software Configuration: Open your development environment (Arduino IDE or Pico SDK). Select the "Raspberry Pi Pico" board. You will need the specific library for the CH390 driver. If using the SDK, ensure you include lwIP sources compatible with the CH390.
// Simplified example for Arduino IDE #include "CH390.h" CH390 eth; void setup() { Serial.begin(115200); // SPI and CH390 initialization if (!eth.begin()) { Serial.println("CH390 initialization failed"); while(1); } // Start DHCP if (eth.dhcp()) { Serial.print("IP Address obtained: "); Serial.println(eth.localIP()); } } void loop() { eth.maintain(); // Maintain connection }
- Network Initialization: In your code, initialize the SPI interface and the CH390 controller. The module uses the SPI interface in mode 0 or 3. Here is a code structure example for initialization:```cpp
4. **Compilation and Upload**: Compile the code and upload it to the Pico. Monitor the serial output to confirm that the module detected the physical link and obtained an IP address.
## Verification
Open a terminal on your computer. Use the command `ping <obtained_IP_address>`. If you receive replies, the connection is active. You can also check your router's administration interface to see if the device appears with a MAC address corresponding to the one factory-programmed on the CH390 module.
## To Go Further
Once basic connectivity is established, explore integration with home automation platforms. ESPHome firmware natively supports this type of configuration for OTA updates and automatic discovery by Home Assistant. You can also study the management of the CH390's 16KB SRAM buffers to optimize throughput in real-time data transfer applications.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)