Pico-ETH-CH9121

From Waveshare Wiki
Jump to: navigation, search
Pico-ETH-CH9121
Pico-ETH-CH9121
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Ethernet To UART Converter For Raspberry Pi Pico, 10/100M Ethernet, Enabling Network Communication Through UART.

Features

  • Standard Raspberry Pi Pico header, supports Raspberry Pi Pico series.
  • Onboard Ethernet to UART transparent transceiver, 2-CH UART, standalone transparent transmission for each channel.
  • Onboard jumpers for pin configurations.
  • Embedded Ethernet MAC and PHY layers.
  • Bi-direction transparent data transmission between UART and Ethernet.
  • 10/100M, full-duplex/half-duplex auto-negotiation Ethernet interface, 802.3-compliant.
  • Auto-MDI/MDIX, detect and switch cable type automatically.
  • Supports DHCP auto-obtained IP and DNS domain access.
  • Network parameter configuration like chip operating mode, port, IP, via host computer software or UART command
  • Four operating modes: TCP CLIENT, TCP SERVER, UDP CLIENT, UDP SERVER.
  • Full-duplex or half-duplex UART communication supports RS485 RX/TX auto switch (external RS485 controller required).
  • Supports virtual serial port software (provided).
  • KEEPALIVE mechanism support.

Specifications

  • Operating votlage: 3.3V/5V
  • Operating mode: TCP/UDP
  • UART TTL: 3.3V / 5V compatible
  • Operating temperature: -40°C ~ 85°C
  • Operating current: 140mA
  • Baudrate: 300bps ~921.6Kbps
  • Dimensions: 74.54 x 21.00 (mm)
  • Storage Condition: -55°C ~ 125°C

Pinouts

Pico-ETH-CH9121-details-inter.jpg

About the CH9121

The CH9121 is a transparent network serial port chip that supports bidirectional and transparent transmission of serial port data and network data. It supports four working modes: TCP CLIENT/SERVER and UDP CLIENT/SERVER. The serial port baud rate ranges from 300bps to 921600bps. Before using, you should set network and serial port parameters for the chip by the NetModuleConfig.exe software or serial commands. After the configuration is complete, the CH9121 saves the configuration parameters to the internal storage space. After the chip is reset, the CH9121 could work based on the saved configuration values.

Default Parameters

The UART 2 is disabled and the UART 1 works in TCP CLIENT mode by default.

  • The network parameters of UART1 (port 1)
    • Device IP: 192.168.1.200
    • Subnet mask: 255.255.255.0
    • Default gateway: 192.168.1.1
    • Device port: 2000
    • Target IP: 192.168.1.100
    • Target port: 1000
  • The Serial parameters of port
    • Baud rate: 9600
    • Timeout: 0
    • Data bit: 8
    • Stop bit: 1
    • Parity bit: None
    • Clear buffer: Never

Enable Port2 through the host

Connect to the module through the router, run NetModuleConfig.exe, search the device, double-click it, and check the "Enable Port2". Pico-ETH-CH9121-Port2.png

Configuration

TCP Client

  • Connect the Pico-ETH-CH9121 (ETH module hereafter) to the router, and use the host PC as a TCP server. The PC should be connected to the same LAN as the ETH module.
  • Use the SSCOM software, set the port to TCP server and you can check the local IP (the Target IP) and the port (Target port).
SSCOM-1.jpg
  • Run the NetModuleConfig.exe software on your PC.
    1. Click the Search button to detect the device.
    2. Double-click the device detected, then you can modify the network parameters in the left area.
    3. After configuration, the ETH module will auto-restart, wait for a moment, search the device again, and check the settings.
    4. Note that you need to modify the parameters according to the actual situation. The Mode should be TCP CLIENT, and the target IP and port should be the same as the TCP server.
NetModuleConfig-1.jpg
  • After setting, you can listen to the data with the SSCOM software.
SSCOM-2.jpg

TCP SERVER

  • Connect the Pico-ETH-CH9121 (ETH module hereafter) to the router, and use the host PC as a TCP CLIENT.
  • Run the NetModuleConfig.exe software on your PC.
    1. Click the Search button to detect the ETH module.
    2. Double-click the device detected.
    3. Set the mode to TCP SERVER and modify other parameters according to the actual situation.
    4. Click the Set ALL button to save the setting.
NetModuleConfig-2.jpg
  • User the SSCOM software, configure it as TCP CLIENT, and connect to the SERVER (The ETH module).
SSCOM-3.jpg

UDP CLIENT/SERVER

The UDP modes are the same as the TCP, the only difference is the mode is UDP CLIENT/SERVER but not the TCP CLIENT/SERVER.

Pico Quick Start

Hardware Connection

ETH Pico/Pico2 Description
5V VSYS Power input
GND GND Ground
RXD1 GP0 UART 1 data input
TXD1 GP1 UART 1 data output
RXD2 GP4 UART 2 data input
TXD2 GP5 UART 2 data output
CFG0 GP14 Network configrate enable pin
RST1 GP17 Reset pin

Pico-ETH-CH9121-connect.jpg

  • If you want to use the screen, please unplug the CFG0 mini jumper cap on the Pico-ETH-CH9121.
  • Remove the jumper cap on the RST1 pin, and after powering on the pico, the Pico-ETH-CH9121 will start directly, don't need to download the program.

Configurate Environment

To use the Pico, you need to configure your PC or the Raspberry Pi first.
Please refer to the official guide about the setting Pico Manual.

Examples

We use Raspberry Pi boards as examples.

Download examples

Open the terminal and run the following commands:

sudo apt-get install p7zip-full
cd ~
sudo wget  https://files.waveshare.com/upload/5/5a/Pico_ETH_CH9121_CODE.7z
7z x Pico_ETH_CH9121_CODE.7z -o./Pico_ETH_CH9121_CODE
cd ~/Pico_ETH_CH9121_CODE
cd Pico/c/build/

C examples

  • Go into the c directory.
cd ~/Pico_ETH_CH9121_CODE/Pico/C/
You can use the Pico_ETH_CH9121_CODE/Pico/C/Serial Port Parameter Configuration: configure module.
Pico_ETH_CH9121_CODE/Pico/C/RX_TX: Echo examples, receive data, and echo
  • Go into the examples directory and export sdk
cd build
export PICO_SDK_PATH=../../pico-sdk
You need to modify the path to the actual one if you use a direct path.
  • Generate the Makefile file
#Pico
cmake -DPICO_BOARD=pico -DPICO_PLATFORM=rp2040 ..
#Pico2
cmake -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350 ..
  • Build the examples.
make -j9
  • After building, copy the .uf2 file to the Pico.
Press the BOOTSEL button of Pico and hold it, connect the Pico to your Pi by micro USB cable, and then release the button. The portable disk RPI-RP2 is recognized, you need to copy the uf2 file to the portable disk.
#Pico
cp main.uf2 /media/pi/RPI-RP2/
#Pico2
cp main.uf2 /media/pi/RP2350

Python examples

Windows

1. Press and hold the BOOTSET button on the Pico board, connect the Pico to the USB port of the computer through the Micro USB cable, and release the button after the computer recognizes a removable hard disk (RPI-RP2).
2. Copy the .uf2 file in the python directory to the recognized removable disk (RPI-RP2).

3. Open Thonny IDE (note: use the latest version of Thonny, otherwise there is no Pico support package, the latest version under Windows is v3.3.3).
4. Click Tools -> Settings -> Interpreter, select Pico, and the corresponding port as shown in the figure.
Pico-lcd-0.96-img-config.png
This demo provides two programs:
Serial Port Parameter Configuration.py: This program is used to configure the mode through the serial port.
RX_TX.py: This is used to send and receive information and return what is received.
5. File -> Open -> RX_TX.py, click to run, as shown below:
Note: If you want to start automatically, please rename RX_TX.py to main.py and save it to Pico.
Pico-lcd-0.96-img-run.png

Raspberry Pi

  • Press and hold the BOOTSEL button of Pico, connect it to Raspberry Pi or PC by micro USB cable, and then release the button.
  • The Pico is recognized as a portable disk RPI-RP2, copy the rp2-pico-20210418-v1.15.uf2 file to the portable disk.
  • Open the Thonny IDE.
  • Choose Tools -> Options .. -> Interpreter.
  • Choose MicroPython(Raspberry Pi Pico) and the related port.
Pico-lcd-0.96-img-config2.png
  • If your Thonny IDE doesn't support Pico, you need to update it to the newest version.
sudo apt upgrade thonny
  • Click File -> Open... -> python/RX_TX.py to run the codes.

Codes Description

C codes

  • Data types:
#define UCHAR unsigned char
#define UBYTE uint8_t
#define UWORD uint16_t
#define UDOUBLE uint32_t
  • Initialize module:
void CH9121_init(void);
  • Parameters for configuring modules:
UCHAR CH9121_Mode           //Mode
UCHAR CH9121_LOCAL_IP[4]    //Device IP
UCHAR CH9121_GATEWAY[4]     //Gateway
UCHAR CH9121_SUBNET_MASK[4] //Subnet mask
UCHAR CH9121_TARGET_IP[4]   //Target IP
UWORD CH9121_PORT1          //Device port
UWORD CH9121_TARGET_PORT    //Target port
UDOUBLE CH9121_BAUD_RATE    //baud rate of serial 
  • You can configure the module by the following functions with serial commands
void CH9121_TX_4_bytes(UCHAR data, int command); //Can be used to configure the mode, random port, disconnect network, clear buffer, DHCP, UART2
void CH9121_TX_5_bytes(UWORD data, int command);//Can be used to set the port of Serial
void CH9121_TX_7_bytes(UCHAR data[], int command);//Can be used to set IP, subnet mask, gateway.
void CH9121_TX_BAUD(UDOUBLE data, int command);//Can be used to set the baud rate of Serial.
void CH9121_Eed(); // Can be used to save settings to EEPROM, enable the setting, reset module, exit from setting mode

Python
You just need to modify the Serial Port Parameter Configuration.py for setting the module.

ODE = 1  #0:TCP Server 1:TCP Client 2:UDP Server 3:UDP Client
GATEWAY = (169, 254, 88, 1)   # GATEWAY
TARGET_IP = (169, 254, 88, 17)# TARGET_IP
LOCAL_IP = (169,254,88,70)    # LOCAL_IP
SUBNET_MASK = (255,255,255,0) # SUBNET_MASK
LOCAL_PORT1 = 5000             # LOCAL_PORT1
LOCAL_PORT2 = 4000             # LOCAL_PORT2
TARGET_PORT = 3000            # TARGET_PORT
BAUD_RATE = 115200            # BAUD_RATE

Pico Quick Start

Firmware Download

  • MicroPython Firmware Download

MicroPython Firmware Download.gif

  • C_Blink Firmware Download

C Blink Download.gif

Text Tutorial

Introduction

MicroPython Series

C/C++ Series

For C/C++, it is recommended to use Pico VS Code for development. This is a Microsoft Visual Studio Code extension designed to make it easier for you to create, develop, and debug projects for the Raspberry Pi Pico series development board. Whether you are a beginner or an experienced professional, this tool can help you confidently and easily develop Pico. Below we will introduce how to install and use the extension.

  • Official website tutorial: https://www.raspberrypi.com/news/pico-vscode-extension/.
  • This tutorial is applicable to Raspberry Pi Pico, Pico2, and our company's RP2040 and RP2350 series development boards.
  • The development environment defaults to Windows as an example. For other environments, please refer to the official website tutorial for installation.

Arduino IDE Series

Install Arduino IDE

  1. Download the Arduino IDE installation package from Arduino website.
    RoArm-M1 Tutorial II01.jpg
  2. Just click on "JUST DOWNLOAD".
    Arduino IDE Pico.png
  3. Click to install after downloading.
    RoArm-M1 Tutorial II02.gif
  4. Note: You will be prompted to install the driver during the installation process, we can click Install.

Install Arduino-Pico Core on Arduino IDE

  1. Open Arduino IDE, click the File on the left corner and choose "Preferences".
    RoArm-M1 Tutorial04.jpg
  2. Add the following link in "Additional boards manager URLs", then click OK.
    https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

    RoArm-M1 Tutorial II05.jpg
    Note: If you already have the ESP32 board URL, you can separate the URLs with commas like this:

    https://dl.espressif.com/dl/package_esp32_index.json,https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
    
  3. Click on Tools -> Board -> Board Manager -> Search for pico, it shows installed since my computer has already installed it.
    Pico Get Start 05.png
    Pico Get Start 06.png

Upload Demo At the First Time

  1. Press and hold the BOOTSET button on the Pico board, connect the Pico to the USB port of the computer via the Micro USB cable, and release the button when the computer recognizes a removable hard drive (RPI-RP2).
    Pico Get Start.gif
  2. Download the demo from #Resource, open the D1-LED.ino under arduino\PWM\D1-LED path.
  3. Click Tools -> Port, remember the existing COM, do not need to click this COM (different computers show different COM, remember the existing COM on your computer).
    UGV1 doenload02EN.png
  4. Connect the driver board to the computer with a USB cable, then click Tools -> Ports, select uf2 Board for the first connection, and after the upload is complete, connecting again will result in an additional COM port.
    UGV1 doenload03EN.png
  5. Click Tools -> Board -> Raspberry Pi Pico/RP2040 -> Raspberry Pi Pico.
    Pico Get Start02.png
  6. After setting, click the right arrow to upload.
    Pico Get Start03.png
    • If you encounter problems during the period, you need to reinstall or replace the Arduino IDE version, uninstall the Arduino IDE clean, after uninstalling the software you need to manually delete all the contents of the folder C:\Users\[name]\AppData\Local\Arduino15 (you need to show the hidden files in order to see it) and then reinstall.


Open Source Demo

Resource

FAQ

 Answer:

They are used for resetting the setting of the module, short the holes and then powering will restore the module to factory setting.

{{{5}}}


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)