2011 CM4 4G UPS EN
Keywords
Raspberry Pi, CM4 Core board, UPS, 100Mbps Ethernet, Gigabit Ethernet, RPi OS, Ubuntu, OpenWrt, 18650, Li-ion battery, 4G LTE Driver-free
I. Introduction
The CM4_4G_UPS expansion board is a dual Ethernet port expansion board with UPS backup power, designed based on the Raspberry Pi CM4. It is equipped with 2*USB 2.0 ports and 1*1.25mm 4-pin USB 2.0 interface (multiplexed with one of the USB 2.0 ports), one Mini PCIe slot supporting 4G modules with Mini PCIe port, as well as common peripherals such as HDMI, 40P, CSI, and DSI. The user can optionally choose one or two onboard 18650 Li-ion batteries as a UPS backup power source, with a maximum capacity of up to 6800mAh. The input power supports 7-24V DC input and UPS backup power input, enabling simultaneous charging and discharging for uninterrupted power supply. This extension board is suitable for attended power-off endurance applications, such as mobile demonstration platforms or portable soft routers (especially ideal for dormitories with nighttime power outages).
The 4G LTE module adopts CAT4 speed, with the theoretical uplink speed of the 4G module capable of reaching over 50Mbps. The 4G LTE modules provided by our company are plug-and-play with auto-identification on Raspberry Pi OS, Ubuntu OS, and OpenWrt, requiring no additional drivers or dial-up configuration, making them highly user-friendly. The 4G models are as follows: CAT4 4G, Qualcomm 4G/4G-GPS, and NL668-EAU/EU/AM 4G.
II. Hardware Spec
| CM4 interface | DF40HC(3.0), Compatible with all versions of the Raspberry Pi CM4 core board. |
| Battery Specifications | 18650 battery*2, Single-cell capacity: 3400mAh, total capacity: 6800mAh. |
| Ethernet | 1*Gigabit Ethernet+1*100Mbps Ethernet, integrated RJ45 interface. |
| 4G LTE | 1*USB MiniPCIE interface. |
| 1*Nano SIM card slot | |
| USB | 2*USB2.0 HOST-A ports, one of which (the upper USB-A in the double-layer port) is multiplexed with the 1.25MM-4P connector. |
| 1*USB-C flashing port, onboard boot jumper (only for flashing OS to eMMC-based CM4). | |
| Display | 1*standard HDMI port (supports resolutions up to 4K). |
| 1*MIPI DSI1 interface (22-pin 0.5mm FPC connector). | |
| Camera | 1*MIPI DSI1 interface (22-pin 0.5mm FPC connector). |
| Storage | 1*TF card slot (for CM4 without eMMC to store and boot the OS). |
| LED | Power LED/Battery LED/CM4 LED/Status LED/4G LED |
| GPIO | 2.54mm 40-pin GPIO, fully compatible with Raspberry Pi 4B pins. |
| Fan power | 1*3.3V fan power supply connector (2.54mm 2P). |
| Power supply | Powered by 7-24V DC (inner negative, outer positive) or 18650 Li-ion battery. |
| Size | 135*111mm. The panels are UL and ROHS certified with a flammability rating of 94V-0. |
| Outer casing | Aluminum alloy case with bracket holes, size: 138 (154mm with bracket) *114*31mm. |
| OS | RPi OS/Ubuntu/OpenWrt |
III. Flash OS
It was tested using Raspberry Pi OS, Ubuntu OS, and OpenWrt. The OSs versions are as follows:
▶ The version of Raspberry Pi OS is: 2025-05-13-raspios-bookworm-arm64.img.xz
You can download it in:
https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit
▶ The version of Ubuntu OS is: ubuntu-25.04-preinstalled-desktop-arm64+raspi.img.xz
You can download it in:
https://ubuntu.com/download/raspberry-pi
For core boards with eMMC, the OS is flashed onto the eMMC. For core boards without eMMC, the OS is flashed onto the TF card.
Use a core board with eMMC. Before flashing the OS, please use a jumper cap to short the BOOT pins on the board and connect the power USB-C interface to the computer:
After the device is recognized by the computer, remove the jumper cap and power on again to start the OS.
For the flashing method, please refer to:
IV. Power management policy
The power management section of the CM4_4G_UPS expansion board consists of three circuits: a buck circuit that steps down the 7-24V DC input to 5V, a lithium battery charging circuit that takes 5V as input, and a boost circuit that raises the lithium battery voltage to 5V. These three power circuits form a complete power management system.
The power management policy is as follows:
1. When an external 7-24V DC input is applied, the system will be powered by the 5V converted from this external input through voltage step-down. This power source is also responsible for charging the lithium battery. In this mode, regardless of whether there is a battery or not, and regardless of whether the power switch is turned on or not, the system will be powered up and operational.
▶ For example, when the onboard 18650 lithium battery is in use, if an external power supply is connected and the power switch is turned on, the external power supply will take priority in providing power.
▶ For example, when the onboard 18650 lithium battery is in use, if an external power supply is connected while the power switch is turned off, the system will be powered by the external source.
2. When no external power supply is connected, moving the power switch to the right ON position enables the Li-ion battery to power the system, while moving it to the left OFF position shuts down the device.
3. The Raspberry Pi CM4 can monitor whether an external power supply is connected (i.e., detect external power loss) via GPIO26, but it cannot read the battery voltage or battery capacity. So the Raspberry Pi cannot accurately calculate the remaining battery life.
Supports simultaneous charging and discharging for uninterrupted power supply.
With the power switch turned on, connect the external power supply. The external power supply provides power to the system while simultaneously charging the battery. When the external power supply is disconnected, the system automatically switches to battery power without affecting operation!
Notes:
1. This extension board can be optionally equipped with 1-2 18650 batteries, supporting 1-10 hours of battery-powered operation (runtime varies depending on the load).
2. This extension board is suitable for attended power-off endurance applications, such as mobile demonstration platforms or portable soft routers (especially ideal for dormitories with nighttime power outages). Please remember to turn off the power switch promptly to protect the lithium battery.
3. The default charging current for the 18650 battery is around 2A. The onboard 4G module requires the external DC 5.5V input to have an output capability of approximately 15W. This means that with a 7.5V input, it must support an output of at least 2A, while a 12V input must support at least 1.2A. A 12V/2A power supply is recommended.
4. When running on a lithium battery, check the battery level regularly. The hardware lacks full load-disconnect capability, and delayed shutdown may cause over-discharge.
5. The 18650 battery stores a significant amount of energy. Please double-check the orientation before inserting it into the battery holder. If inserted incorrectly, it may smoke, catch fire, or even explode. For everyone's safety, please verify carefully.
V. Work with Raspberry Pi OS
5.1 USB port test
Connect devices to each USB port, then execute the commands lsusb and lsusb -t in the terminal. The output is as follows:
Device 003: 1.25mm-4p connector, multiplexed with the upper port of the dual-layer USB 2.0-A port.
Device 004: The lower port of the dual-layer USB 2.0 Type-A port.
Device 005: USB 2.0 to 100Mbps Ethernet adapter.
Device 006: USB2.0 to MiniPCIe port.
USB devices are detected normally. No device number will appear if no external USB device is connected.
Bus 01 is a USB 2.0 interface with 480 Mbps, and the operating mode is also normal.
5.2 Test for monitoring whether an external power supply is connected
The Raspberry Pi CM4 can monitor whether an external power supply is connected via GPIO 26. Here, we will execute a script to monitor it.
The script code is as follows (script name: gpiot.sh):
Reference script:
http://www.mcuzone.com/wiki/2011_CM4_4G_UPS/gpiot.sh.zip
Note: After downloading, rename the file to gpiot.sh and copy it to the Raspberry Pi OS for use.
Execute the command below to give the script executable permissions:
sudo chmod +x gpiot.sh
Then execute the script:
./gpiot.sh
The result is: when the input power is properly connected (i.e., in charging state), the terminal displays:
The current state of GPIO26 is high (hi, high level).
When the input power is disconnected (i.e., in discharge state), the terminal displays:
The current state of GPIO26 is low (lo, low level).
Plug in the external power supply, power on and execute the script, unplug the external power supply, then plug it back in. A video example of the results:
Note: The state change of GPIO26 from high to low level may take some time. It typically requires several seconds from disconnecting the input power to the actual state change, during which the state remains high.
5.3 Ethernet port test
Execute the command ifconfig in the terminal, and the display is as follows:
▶ Testing native Gigabit Ethernet:
Connect the native Gigabit Ethernet to the upper-level router. We use the network speed testing tool iperf3 for speed tests.
Download iperf3 for Windows:
http://www.mcuzone.com/down/Software.asp?ID=10000634
Install iperf3 on Linux:
sudo apt-get install iperf3
Client mode is around 942Mbps:
Server mode is around 948Mbps:
▶ Testing 100Mbps Ethernet:
Connect the 100Mbps Ethernet to the upper-level router. We use the network speed testing tool iperf3 for speed tests.
Client mode is around 92.2Mbps:
Server mode is around 91.6Mbps:
Note: Network speed tests are affected by the network environment and testing methods. Please refer to the actual speed, as this test is for reference only.
5.4 Test 4G module
Execute the command ifconfig -a in the terminal, and the displayed results are as follows:
CAT4 4G:
Qualcomm 4G/4G-GPS or NL668-EAU/EU/AM 4G:
We can now successfully ping both the IP address and the domain name, confirming that the 4G module is working correctly:
Open https://test.ustc.edu.cn/ to conduct a speed test, and the results are as follows:
CAT4 4G:■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■Qualcomm 4G/4G-GPS or NL668-EAU/EU/AM 4G:
Note: Network speed tests are affected by the network environment and testing methods. Please refer to the actual speed, as this test is for reference only.
The use of GPS is operated through AT commands, as well as other operations related to the 4G module, such as AT commands or network priority testing. For reference, please click this link: M4GUSB.
5.5 DSI1 test
The official two LCD screens for Raspberry Pi: the 1st-gen LCD has a resolution of 800×480, while the 2nd-gen LCD has a resolution of 1280×720. Both screens require additional power supply.
5.5.1 Raspberry Pi 1st-Gen LCD Display
Power up the OS, open the terminal and execute the following commands:
sudo nano /boot/firmware/config.txt
Insert the following lines at the end of the file:
dtoverlay=vc4-kms-dsi-7inch,dsi1
After saving and restarting the OS, you can use the Raspberry Pi 7-inch touchscreen.
5.5.2 Raspberry Pi 2nd-Gen LCD Display
Open the terminal and execute the following commands:
sudo nano /boot/firmware/config.txt
Insert the following lines at the end of the file:
dtoverlay=vc4-kms-dsi-ili9881-7inch,dsi1
After saving and restarting the OS, you can use the Raspberry Pi 2nd-Gen 7-inch touchscreen.
Notes:
1): If both the HDMI display and the 7-inch touchscreen are connected simultaneously, the 7-inch touchscreen may become the secondary screen. Simply power off the system, disconnect the HDMI display, and restart; the 7-inch touchscreen will then function as the primary display.
2): The added command actually enables the second display, meaning a dual-screen setup. Whether the second screen's hardware is installed or not, the system may still recognize it as a dual-display configuration. If you use PrtScn (Print Screen) to take a screenshot, it may capture both screens. In some cases, this could even cause the system to fail to boot. Therefore, if you don’t need this screen, it is recommended to remove or comment out this line in config.txt.
5.6 CSI1 test
The camera used for testing here is the OV5647. Once the OS is running, open the terminal and execute the following commands:
sudo nano /boot/firmware/config.txt
Insert the following lines at the end of the file:
dtoverlay=ov5647,cam1
Add according to your model in practice. Save and restart the OS, then you can use the OV5647 camera.
Execute the following command in the terminal:
ls /dev/video*
You will then see the video0 device listed:
Execute libcamera-hello --camera 0 in the terminal to open the corresponding camera for preview:
If a photo is required, please excute:
libcamera-jpeg -o test.jpg
The photos are saved in the /home/mcuzone directory (i.e., the user's home directory). The photo effects are as follows:
VI. Work with Ubuntu OS
6.1 USB port test
Connect devices to each USB port, then execute the commands lsusb in the terminal. The output is as follows:
Execute the commands lsusb -t in the terminal. The output is as follows:
Device 003: 1.25mm-4p connector, multiplexed with the upper port of the dual-layer USB 2.0-A port.
Device 004: The lower port of the dual-layer USB 2.0 Type-A port.
Device 005: 100Mbps Ethernet adapter.
Device 006: The MiniPCIe port is connected to a Qualcomm 4G module.
USB devices are detected normally. No device number will appear if no external USB device is connected.
Bus 01 is a USB 2.0 interface with 480 Mbps, and the operating mode is also normal.
6.2 Test for monitoring whether an external power supply is connected
In the Ubuntu OS, monitoring whether an external power supply is connected follows the exact same testing method as in Raspberry Pi OS. Please refer to Section 5.2 for details.
6.3 Ethernet port test
By default, the net-tools package is not installed in Ubuntu, so the ifconfig command cannot be executed. Please install the net-tools package first.
Execute the command in the terminal:
sudo apt install net-tools
After the installation is complete, execute ifconfig in the terminal, and the following will be displayed:
▶ Testing native Gigabit Ethernet:
Connect the native Gigabit Ethernet to the upper-level router. We use the network speed testing tool iperf3 for speed tests.
Client mode is around 941Mbps:
Server mode is around 948Mbps:
▶ Testing 100Mbps Ethernet:
Connect the 100Mbps Ethernet to the upper-level router. We use the network speed testing tool iperf3 for speed tests.
Client mode is around 93.1Mbps:
Server mode is around 94.7Mbps:
Note: Network speed tests are affected by the network environment and testing methods. Please refer to the actual speed, as this test is for reference only.
6.4 Test 4G module
Execute the command ifconfig -a in the terminal, and the displayed results are as follows:
We can now successfully ping both the IP address and the domain name, confirming that the 4G module is working correctly:
Open https://test.ustc.edu.cn/ to conduct a speed test, and the results are as follows:
CAT4 4G:■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■Qualcomm 4G/4G-GPS or NL668-EAU/EU/AM 4G:
Note: Network speed tests are affected by the network environment and testing methods. Please refer to the actual speed, as this test is for reference only.
Other operations related to the 4G module follow the same procedures as the Raspberry Pi OS.
6.5 DSI1 test
The official two LCD screens for Raspberry Pi: the 1st-gen LCD has a resolution of 800×480, while the 2nd-gen LCD has a resolution of 1280×720. Both screens require additional power supply.
6.5.1 Raspberry Pi 1st-Gen LCD Display
Power up the OS, open the terminal and execute the following commands:
sudo nano /boot/firmware/config.txt
Insert the following lines at the end of the file:
dtoverlay=vc4-kms-dsi-7inch,dsi1
After saving and restarting the OS, you can use the Raspberry Pi 7-inch touchscreen.
6.5.2 Raspberry Pi 2nd-Gen LCD Display
Open the terminal and execute the following commands:
sudo nano /boot/firmware/config.txt
Insert the following lines at the end of the file:
dtoverlay=vc4-kms-dsi-ili9881-7inch,dsi1
After saving and restarting the OS, you can use the Raspberry Pi 2nd-Gen 7-inch touchscreen.
Notes:
1): If both the HDMI display and the 7-inch touchscreen are connected simultaneously, the 7-inch touchscreen may become the secondary screen. Simply power off the system, disconnect the HDMI display, and restart; the 7-inch touchscreen will then function as the primary display.
2): The added command actually enables the second display, meaning a dual-screen setup. Whether the second screen's hardware is installed or not, the system may still recognize it as a dual-display configuration. If you use PrtScn (Print Screen) to take a screenshot, it may capture both screens. In some cases, this could even cause the system to fail to boot. Therefore, if you don’t need this screen, it is recommended to remove or comment out this line in config.txt.
VII. Work with OpenWrt
The version of the OpenWrt we tested with is: openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade-linux-6.6.73-20250324-7925.img.gz
The OS defaults to the native Gigabit Ethernet as LAN. We can configure the expansion board as follows: set the 4G module as WAN, and configure the 100Mbps Ethernet as either WAN or LAN.
7.1 Preparation
Connect the native Gigabit Ethernet to the PC's network port. After the OS boots up, go to Windows Settings, find Network & Internet, and open the connected network under Ethernet to view the default gateway IP address. This address is the access address for the OpenWrt's configuration page. As shown in the figure, the tested address in this article is 192.168.1.1.
Then open a web browser, enter 192.168.1.1 to access the OpenWrt. The default username is root, and the default password is password.
7.2 Set the 4G module as WAN
Connect the native Gigabit Ethernet port to the PC and power on the OS. Click on "Services - Terminal," then log in to the terminal. The default username is root, and the password is password.
Execute ifconfig -a, and the result is as follows:
Both CAT4 4G, Qualcomm 4G/4G-GPS, and NL668-EAU/EU/AM 4G modules are recognized as eth2, but no IP address is visible. This is normal because the setup is not yet complete.
Click "Network - Interfaces" - "Add new interface...":
Configure as shown in the figure (the "Name" can be customized), then click "Create Interface":
In the "Firewall Settings", set "Create/Assign firewall-zone" to "wan", then click "Save":
Return to the previous page, click "Save & Apply":
So we have configured the 4G module as a WAN port. After a short wait, we can see that the 4G module has obtained an IP address:
Then we return to the terminal and execute ifconfig -a, with the following result:
It can be seen that eth2 has obtained an IP address.
Pinging the domain name is successful, and the 4G module is working normally:
Now the properties of the PC's network adapter connected to the LAN port show that it can access the Internet:
Open https://test.ustc.edu.cn/ to conduct a speed test, and the results are as follows:
CAT4 4G:■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■Qualcomm 4G/4G-GPS or NL668-EAU/EU/AM 4G:
Note: Network speed tests are affected by the network environment and testing methods. Please refer to the actual speed, as this test is for reference only.
7.3 Set the 100Mbps Ethernet port
The 100Mbps Ethernet on the expansion board is identified as eth1 in the OS. The method for setting the 100Mbps Ethernet as the WAN is the same as the method described in the previous section for setting the 4G module as the WAN, except the network interface needs to be selected as eth1.
After completing the setup, the PC can access the internet. Open https://test.ustc.edu.cn/ to conduct a speed test, with the results as follows:
Note: Network speed tests are affected by the network environment and testing methods. Please refer to the actual speed, as this test is for reference only.
Before setting the 100Mbps Ethernet port as a LAN port, if it has already been configured as a WAN port, please delete that configuration first:
Click "Network - Interfaces", click the delete button behind WAN, then click "Save & Apply"
Go to "Devices", click "Configure..." after "br-lan":
In the "Bridge ports" section, select "eth1" (the 100Mbps port), then click the "Save" button:
Return to the previous page, click "Save & Apply":
So we have also configured the 100Mbps Ethernet port (eth1) as a LAN port.
VII. The compatibility test of the CM5 core board
▶ Raspberry Pi OS:
| Boot | The CM5 core board with eMMC supports direct booting from eMMC,
while the CM5 core board without eMMC supports booting from a TF card. | ||||
| Device Name | HDMI output | USB2.0-A ports | MiniPCIe port(4G) | Gigabit Ethernet | 100Mbps Ethernet |
| Compatible or not? | √ | √ | √ | √ | √ |
| Device Name | Monitor external power input | Core Board WiFi | DSI1 | CSI1 | Use CSI1 as DSI |
| Compatible or not? | √ | √ | × | √(cam0) | √(dsi0) |
| Note: √ = compatible, × = incompatible, (text in parentheses shows differences vs. CM4 core board). | |||||
▶ Ubuntu OS:
| Boot | The CM5 core board with eMMC supports direct booting from eMMC,
while the CM5 core board without eMMC supports booting from a TF card. | ||||
| Device Name | HDMI output | USB2.0-A ports | MiniPCIe port(4G) | Gigabit Ethernet | 100Mbps Ethernet |
| Compatible or not? | √ | √ | √ | √ | √ |
| Device Name | Monitor external power input | Core Board WiFi | DSI1 | Use CSI1 as DSI | |
| Compatible or not? | √ | √ | × | √(dsi0) | |
| Note: √ = compatible, × = incompatible, (text in parentheses shows differences vs. CM4 core board). | |||||
Note: You need to add dtoverlay=dwc2,dr_mode=host at the end of the config.txt file, otherwise the USB ports (including the Mini PCIe port) will not function.
▶ OpenWrt:
| Boot | The CM5 core board with eMMC supports direct booting from eMMC,
while the CM5 core board without eMMC supports booting from a TF card. | ||||
| Device Name | HDMI output | MiniPCIe port(4G) | Gigabit Ethernet | 100Mbps Ethernet | Core Board WiFi |
| Compatible or not? | √ | √ | √ | √ | √ |
| Note: √ = compatible, × = incompatible | |||||
Note1: The test OS version is: openwrt-bcm27xx-bcm2712-rpi-5-squashfs-sysupgrade-linux-6.12.32-USBlan-oled-20250608.img.gz
Note2: In the config.txt file, change dr_mode=peripheral to dr_mode=host, otherwise, the USB ports (including the Mini PCIe port) will not function.
Contact Us
Email: mcuzone@vip.qq.com
Tel: +86(0)13957118045
If there are any omissions, errors, or infringements on this page, please contact us through the above methods. Thank you!
Copyright 2004-2025 Wildchip




QQ:8204136