🛠 Integrating GPIO with UEXT-CH390 Ethernet
Objectives
This tutorial aims to master the interaction between local peripherals (GPIO) and network connectivity provided by the UEXT-CH390 module. We will configure a microcontroller to read a sensor or drive a display while transmitting data via Ethernet. The goal is to understand how to manage concurrency between fast local tasks and network interrupts, a key skill for reliable IoT projects.
Required Hardware
- Compatible board: Raspberry Pi Pico 2 or ESP32 module (S3, C3, C5, C6).
- Olimex UEXT-CH390 module (10/100 Mbps Ethernet).
- Simple sensor (e.g., push button or DHT11 temperature sensor) or LED.
- Connecting wires and breadboard.
- Development environment: Arduino IDE or ESPHome (version 2026.9.0 recommended for RP2040 drivers).
- Stable 3.3V power supply.
Steps
- Hardware Connection: Insert the UEXT-CH390 module into the UEXT or pUEXT connector of your board. Ensure power is supplied at 3.3V. Connect your sensor to a free GPIO pin (not used by the CH390's SPI bus).
- Project Configuration: In your IDE, select the target board. If using ESPHome, define the
spiblock with MISO, MOSI, SCK, and CS pins corresponding to the CH390 module. Enable Ethernet support via theethernetcomponent specifying thech390model. - Software Initialization: Import necessary libraries. For Arduino, initialize the SPI interface first, then the Ethernet driver. For ESPHome, configure the
sensorblock to read your GPIO sensor and theweb_serverormqttblock for network transmission. - Control Logic: Write the main loop to read the GPIO state. If the sensor detects a change, update a global variable. This variable will be automatically published over the network by the configured Ethernet layer.
- Compilation and Upload: Compile the code. Check for pin conflict errors. Upload the firmware to the microcontroller.
Verification
Open a web browser and enter the DHCP-assigned IP address of your board. You should see a local web interface or data in a dashboard (like Home Assistant). Press the button or change the sensor value: the value displayed on the web interface should change almost instantly, proving that the GPIO -> Memory -> Ethernet flow is working correctly.
Going Further
Explore the use of hardware interrupts (ISR) for GPIO to reduce latency. Try adding an OTA (Over-The-Air) update via the Ethernet network to modify the GPIO code without physical reconnection.
Other tutorials for this board
- First connection and startup of the UEXT-CH390
- Controlling GPIO and sensors with UEXT-CH390
- Complete Use Case: Ethernet Connectivity for Raspberry Pi Pico
- First connection and startup of the UEXT-CH390
- Connect a RP2040 to the network with UEXT-CH390 and ESPHome
- Advanced Startup: UEXT-CH390 and Raspberry Pi Pico
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)