From Waveshare Wiki
Jump to: navigation, search

M.2 B KEY, CSI HDMI, USB 2.0, Ethernet, FAN, 4G, 5G
Compute Module 4




Based on Raspberry Pi CM4, this is an industrial expansion module with a UPS module, which features common interfaces such as Gigabit Ethernet, HDMI, USB, and GPIO, allowing additional 4G / 5G wireless communication modules to be connected via the M.2 or Mini-PCIe socket. There are also industrial interfaces/resources including RS485, CAN, and RTC. Combined with the industrial rail-mount protection case, the module is an ideal choice for building IoT gateway, 4G/5G router, IoT data acquisition, or even the PLC device in the industrial automatic control system, and more.


1: Do not unplug devices other than USB and HDMI when powered on.
2: Confirm the fan voltage before connecting, support 5V and 12V by default connect 12V, switch please modify the FAN_VCC resistance. 3: In order to ensure the normal power supply of CM4, please do not connect other devices when using the Type C interface to program the image.
4: The module needs to be powered with 5V 2.5A /12V 1A or higher. Otherwise, there may be problems with automatic shutdown, degradation, etc. 5: The first time the battery is connected, there may be no power output, you need to press the BOOT activation button on the UPS module or charge the battery protection chip to activate the power output, the UPS module power switch needs to be set to the OFF position, the CM4 base plate switch is set to ON, ready to use. 6: The USB2.0 interface is disabled by default, you should add line dtoverlay=dwc2,dr_mode=host to the /boot/config.txt file to enable it.
7: When using UPS alone, the circuit should not exceed 2.5A, long working hours in the 2.5A state will heat up, pay attention to heat dissipation.
8. The external power supply must be greater than the overall system power, otherwise there is not enough current to charge the battery for a long time, and the battery power is getting low until shutdown.
9. When the system load is large and the battery voltage is low, there may be a lack of battery current and causing the system to constantly restart.
10: The battery is relatively strong, disassembly needs to be paired with tools (screwdriver), do not use a screwdriver to pry the battery positive pole easily leads to a short circuit, to pry the battery negative pole.


  • Li-ion and Li-po batteries are quite unstable. They may cause fire, personal injury, or property damage if they're not properly recharged or used.
  • Do not reversely connect the polarities when recharging or discharging the battery. Do not use an inferior charger/charging panel to recharge the battery.
  • Do not mix use old batteries with new ones, avoid using batteries of different brands.
  • When buying a Lithium battery, should always make sure the battery specification is compatible with the expansion board.
  • Choose batteries from the formal manufacturer, and ensure the batteries will work stably and safely by aging test.
  • Lithium batteries have limited cycle life, they will also deteriorate as time goes by.
  • Should be replaced with new ones when the batteries reach their max cycle life, or work over two years, whichever comes first.
  • Should be placed carefully and properly, keep it away from inflammable and explosive articles, away from children, and avoid any safety accident caused by careless storage.


Compute_Module 4
Compute Module 4 IO Board 5.png

Onboard Resources


NO. Name Description
1 CM4 socket suitable for all variants of Compute Module 4
2 HDMI connector supports 4K 30fps output
3 USB 2.0 ports 3x USB 2.0, for connecting sorts of USB devices
4 RJ45 Gigabit Ethernet 10/100/1000M compatible
5 DC power supply 7 ~ 36V DC input
6 CM4 status indicator PWR (Red): Raspberry Pi power indicator
ACT (Green): Raspberry Pi operating status indicator
7 4G/5G module status indicator M.2 PWR (Red): module enable indicator
M.2 NET (Green): module operating status indicator
8 PWR & USB 5V DC power supply or USB programming port
9 M.2 B KEY supports 4G/5G modules with M.2 B KEY connector, or other communication modules using USB channel
10 Nano-SIM ard slot supports standard Nano-SIM card for 5G/4G/3G/2G communication
11 BOOT selection ON: CM4 will be booted from USB-C interface
OFF: CM4 will be booted from eMMC or TF card
12 UPS module ON/OFF ON: CM4 and the base board will be powered by UPS module
OFF: Turn off the UPS power supply to CM4 and base board
13 DC power supply 7 ~ 36V DC input
14 Dual non-isolated RS485 2x RS485, with 600W lightningproof, anti-surge, and 15KV ESD protection (reserved 120R optional balancing resistor jumper)
15 Non-isolated CAN ESD protection and transient spike voltage protection (reserved 120R optional balancing resistor jumper)
16 Micro SD card slot for connecting a TF card with pre-burnt image (Lite variant ONLY)
17 FAN header for connecting cooling fan, allows speed adjustment and measurement
18 CAM MIPI CSI camera port, 15Pin 1mm pitch
19 RTC battery holder supports CR1220 button cell
20 M.2 VCC selection select 3.3V or 4.2V power supply
21 RTC interruption configuration PI-RUN: CM4 will reboot on RTC interruption
GL-EN: CM4 power down on RTC interruption
D17: D17 pin is triggered on RTC interruption (default)
22 IO-VREF selection set the CM4 IO logic level as 3.3V (default) or 1.8V
23 FAN power supply selection select 12V (default) or 5V power to drive the fan
24 System function configuration BT_DIS: Bluetooth disabled, for CM4 with antenna variant ONLY
WiFi_DIS: WiFi disabled, for CM4 with antenna variant ONLY
WP_DIS: boot mode switch, ONLY be used when NOT booted from eMMC or SD card
25 RTC/FAN I2C bus selection SDA0/SCL0: I2C-10 is shared with CSI/DSI (default)
GPIO3/2: I2C-1 is shared with GPIO header
26 Partial GPIO header including 1x I2C, 2x GPIO pins, and power supply
27 UPS Module Mini header Adopts 10440 3.7V Lithium battery


Prohibit unplugging any equipment while powered.

Writing Image


The default is off, if you want to turn it on, you need to add the following to config.txt:

sudo nano /boot/config.txt

The device numbers are:



Close by default, if you want to open it, you need to add the following content in config.txt:

# Open and edit config.txt
sudo nano /boot/config.txt
#Add the following

Execute after rebooting:

dmesg | grep spi0

Compute Module 4 PoE 4G Board 1.png

sudo ip link set can0 up type can bitrate 1000000
sudo ifconfig can0 txqueuelen 65536

The can0 device number appears meaning drive successfully.


Install can-utils:

sudo apt-get install can-utils

Receive data:

candump can0

Send data:

cansend can0 000#
#Where is the data
#If you need to send additional data you can use the Continue to add for example
# cansend can0 000#
#English and Chinese are not allowed, and two codes are added in one format.


On-board M.2 B KEY with internal PCIE, USB2.0, GPIO, I2C, SPI interfaces.
The default can only be connected to
M.2 B KEY interface modules, etc.
SSD supporting NVME 2242 with M.2 B KEY interface.


The board itself does not support 4G/5G, you need to access the module through the M.2 B KEY interface, M.2 B KEY only USB2.0 channel.
Connect the 4G/5G module and insert the SIM card afterward.
If you need to turn off the 4G/5G module, you can use GPIO6 (BCM code 6) control, GPIO6 output a high level to turn off the module, and GPIO6 output a low level to turn on the module.
It takes some time (about 30 seconds) to turn off or turn on the module if the antenna is not connected or the SIM card is not connected before turning on the module.
If the module can not be turned on, it may be GPIO6 pin is pulled high, please use the following command to pull the GPIO6 pin low to turn it on:

echo Exporting pin 6
echo 6 > /sys/class/gpio/export
echo Setting direction to out.
echo out > /sys/class/gpio/gpio6/direction
echo Setting pin 0

M.2 4G/5G NIC

M.2 status indicator:

STA NET Status
Always on Off Shutting down or turning on
Always on Always on Searching the web
Always on Flash Networked and working normally
Off Flash/Always on Shutting down

Make sure the module is powered on before configuration.
For 5G, you can refer to [5G Configuration]

4G Configuration

sudo apt-get install minicom
sudo minicom -D /dev/ttyUSB2
# Enter the following command:
#return OK and you're done
#Then wait for the card to reboot
#This command only needs to be set once, the next power-up will default in this mode
#If you can't get the USB0 NIC to execute.
sudo dhclient -v usb0
  • For RNDIS dial-up Internet access, please refer to RNDIS Dial-Up.
  • USB0 NIC will be recognized after normal execution above (if you don't connect other USB NICs).
  • If you use an IoT card, such as a mobile IoT card, and successfully register the network; however, the dial-up Internet access fails to ping through, you can try to select the optimal band with one of the following AT commands:

AT Command

If you cannot connect to the network, you can check the status by AT commands:

sudo apt-get install minicom
sudo minicom -D /dev/ttyUSB2

Common AT Commands

The following AT commands are for 4G/5G modules:

Command Description Return Value
AT AT Test Commads OK
ATE ATE1 sets echo

ATE0 turns off echo|| OK

AT+CGMI Inquire about module manufacturers OK
AT+CGMM Inquire about module model OK
AT+CGSN Inquire about product serial number OK
AT+CSUB Check module version and chip OK
AT+CGMR Check the firmware version serial number OK
AT+IPREX Set the module hardware serial port baud rate +IPREX:
AT+CRESET Retset module OK
AT+CSQ Network signal quality query, return signal value +CSQ: 17,99
AT+CPIN? Query SIM card status, return READY, means SIM card can be recognized normally +CPIN: READY
AT+COPS? Query the current operator, the operator information will be returned after normal networking +COPS:
AT+CREG? Check network registration status +CREG:
AT+CPSI? Query UE system information
AT+CNMP Network mode selection command:
2: Automatic
13:GSM only
38: LTE only
48: Any modes but LTE
... ....

For more AT commands, you can refer to SIM7500 SIM7600 Series AT Command Manual V2.00.pdf.
For more documents, you can refer to SIMCom.


  • Note: Please connect the fan before powering on the expansion board and then finish the test, please do not connect the fan after the expansion board has been powered on, that is, the fan control chip has been powered on, otherwise the chip will be burned!
  • Caution: Please confirm the fan voltage and the actually connected fan power supply before connecting.

Use the Raspberry Pi system(2021-05-07-raspios-buster-armhf-full )
Note: Do not use DSI and CSI when using RTC.
If simultaneous use is required, switch I2C to the I2C1 device (right).
All demos or drivers need to be modified after switching.
Demos adopt I2C10 (left) by default.

For simple use, or to add to your program, refer to the C and Python references. Click here to see.
Here's how to add the driver to the kernel:


sudo nano /boot/config.txt
# Add at the end
# add # sign in front of dtparam=audio=on
#Save to exit and reboot
sudo reboot

Hwclock Simple Use

Synchronize system clock -> Hardware clock.

sudo hwclock -w

Synchronize the hardware clock -> system clock.

sudo hwclock -s
# Need to turn off the network, or turn off the network pair time, the responsible will be changed back

To set the hardware clock time:

sudo hwclock --set --date="9/8/2021 16:45:05"

To view the hardware clock:

sudo hwclock -r

Show version information:

sudo hwclock --verbose


When the power is on, the fan will turn for 1 second, then stop for 2 seconds, then turn again, this is a normal phenomenon.
Fan currently has no official configuration method, there is a third-party configuration method:
This method is a third-party release, not the official release, any problems, not responsible!

mkdir -p ~/src
cd ~/src
git clone
cd cm4io-fan
sudo chmod 777
sudo  ./
#The following is the description of config.txt.
Name:   cm4io-fan
Info:   Raspberry Pi Compute Module 4 IO Board fan controller
Load:   dtoverlay=cm4io-fan,<param>[=<val>]
Params: minrpm             RPM target for the fan when the SoC is below 
                           mintemp (default 3500)
       maxrpm              RPM target for the fan when the SoC is above
                           maxtemp (default 5500)
       midtemp             Temperature (in millicelcius) at which the fan
                           begins to speed up (default 50000)
       midtemp_hyst        Temperature delta (in millicelcius) below mintemp
                           at which the fan will drop to minrpm (default 2000)
       maxtemp             Temperature (in millicelcius) at which the fan 
                           will be held at maxrpm (default 70000)
       maxtemp_hyst        Temperature delta (in millicelcius) below maxtemp
                           at which the fan begins to slow down (default 2000)
Or refer directly to the following:
Temperature above 45 degrees Celsius starts to accelerate, above 50 degrees Celsius maximum speed.

If there is a failure to compile properly, you can click here.


CSI and DSI are off by default when using the camera and DSI will occupy I2C-10, I2C-11, and I2C-0.
The DSI interface of CM4-DUAL-ETH-4G/5G-BASE is the DSI1 interface.
The power-on execution is as follows:

sudo apt-get install p7zip-full
7z x CM4_dt_blob.7z -O./CM4_dt_blob
sudo chmod 777 -R CM4_dt_blob
cd CM4_dt_blob/
#If you use two cameras and DSI0 to execute
sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
#If two cameras and DSI1 are used to perform
sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
#In the use of any DSI, HDMI1 no image output, even if you do not connect the DSI screen as long as the corresponding file compiled, that HDMI1 no output
#If you need to restore, just delete the corresponding dt-blob.bin, e.g. sudo rm -rf /boot/dt-blob.bin 
#Execution complete, Power off, Restart CM4

Then connect the camera and DSI screen to:

  1. Ensure connection in the power-off condition.
  2. Connecting the Compute Module 4 PoE Board to the DSI screen using the CM-DSI-ADAPTER .
  3. Connecting Compute Module 4 PoE Board and CSI Camera with CSI Adapter Board.
  4. Connect to the power.
  5. Wait a few seconds for the screen to start.
  6. If it fails to boot, check if /boot/dt-blob.bin exists, if it does, reboot it again.
  7. The camera needs to run raspi-config, select Interfacing Options -> Camera -> Yes -> Finish -> Yes, reboot the system, turn on enable camera, and then reboot to save the changes.

Testing the Raspberry Pi camera To view the first camera screen accessed:

sudo raspivid -t 0 -cs 0

To view the second camera screen:

sudo raspivid -t 0 -cs 1

You can refer to CSI camera and DSI display.

UPS Battery Level Detection and Function Pins

  • UPS( INA219 ) on i2c-10 at 0x43 (7-bit address).
  • Run the program by entering the following command:
sudo apt-get install p7zip
7zr x CM4_UPS_Code.7z -r -o./
cd CM4_UPS_Code
  • After running the program, it can out the battery voltage, current, power, and the battery remaining percentage.

Note: A positive current indicates the battery output current (which can be considered as Raspberry Pi load current), and if the current is negative, it indicates the battery charging current.
When the system load is high and the battery voltage is low, there is a possibility that the battery current will be insufficient and the system will keep rebooting. This is not desired. The actual application can be avoided by judging that the battery voltage is too low to shut down automatically.
The sample demo has added the battery voltage judgment, the demo will shut down the system within the 60s when the battery voltage is too low and there is no external power supply for charging.
The demo shows the following statement that the battery voltage is too low and needs to be charged in time, otherwise, the demo will shut down automatically.

Voltage Low, please charge in time, otherwise, it will shut down in 58 s

If you need to use the camera or DSI screen, it is recommended to switch the I2C pin of the INA219 to GPIO2/3 After the switch the program is modified to:

#ina219 = INA219(i2c_bus=10,addr=0x43)
ina219 = INA219(i2c_bus=1,addr=0x43)
  • When the case is fixed and the UPS is turned on, there is no output from the UPS, you need to start CM4, control the P2 (pin 13) pin to pull down 500ms, and then pull up.
  • If you need to know the battery status, you need to read the P25 (physical pin 37) pin.
    • If it reads low, it is charging.
    • If it reads high, it is not charging.
    • Read as 1Hz duty cycle 50%, then the battery is faulty.




3D Drawing





a) Check if dtparam -audio -on is blocked in /boot/config.txt.
b) Check if the /boot/dt-blob.bin file exists, if it does, please delete it.



The operating temperature range of the Raspberry Pi Compute Module 4 (CM4), including the CM4-IO-WIRELESS-BASE and CM4-IO-WIRELESS-BASE-B board, is approximately -20 to +85°C.



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 AM GMT+8 (Monday to Friday)