🛠 Integrating GPIO with UEXT-CH390 Ethernet

Olimex UEXT-CH390: SPI to Ethernet 10/100 Mbps Module for Microcontrollers · intermediaire · Apprenez à combiner le contrôle des entrées-sorties locales et la communication réseau via le module UEXT-CH390.

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

Steps

  1. 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).
  2. Project Configuration: In your IDE, select the target board. If using ESPHome, define the spi block with MISO, MOSI, SCK, and CS pins corresponding to the CH390 module. Enable Ethernet support via the ethernet component specifying the ch390 model.
  3. Software Initialization: Import necessary libraries. For Arduino, initialize the SPI interface first, then the Ethernet driver. For ESPHome, configure the sensor block to read your GPIO sensor and the web_server or mqtt block for network transmission.
  4. 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.
  5. 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

Code examples for this board

← Back to the board 🛠 All tutorials