From Waveshare Wiki
Jump to: navigation, search
Compute Module 4

Industrial IoT Wireless Expansion Module Designed for Raspberry Pi Compute Module 4





This is an industrial expansion module based on Raspberry Pi CM4, which features common interfaces such as Gigabit Ethernet, HDMI, USB, and GPIO, allowing additional 4G / 5G / LoRa 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 an IoT gateway, 4G/5G router, IoT data acquisition, or even the PLC device in the industrial automatic control system, and more.


1. DO NOT hot-plug any devices except the USB and HDMI.
2. Please check the FAN voltage before connecting the cooling fan. The BASE board supports a 12V cooling fan by default, if you want to use a 5V cooling fan, please change the FAN_VCC resistor.
3. DO NOT connect other devices while writing CM4 via the Type C interface for stable working.
4. 5V/2.5A or higher power supply is recommended for proper working.
5. DO NOT power the Base board by 12V DC and the 5V Type C at the same time.

6. The USB2.0 is disabled by default, you need to add the line dtoverlay=dwc2,dr_mode=host to config.txt to enable it.


CM4 SOCKET suitable for all variants of Compute Module 4
NETWORKING Dual Gigabit Ethernet RJ45
M.2 B KEY / Mini-PCIe (via adapter), for connecting 5G / 4G / LoRa wireless module
Nano-SIM card slot supports standard Nano-SIM card for 5G/4G/3G/2G communication
USB USB 2.0 × 3
PIN HEADER Non-isolated RS485 × 2, Non-isolated CAN × 1, Partial GPIO headers
CAMERA MIPI CSI-2 × 1 (15pin 1.0mm FPC connector)
VIDEO HDMI × 1, supports 4K 30fps output
RTC Real-time clock with a battery socket and the ability to wake Compute Module 4
STORAGRE MicroSD card socket for Compute Module 4 Lite (without eMMC) variants
FAN HEADER 5V/12V, allows speed adjustment and measurement
DIMENSIONS 145 × 90 × 40mm


Compute_Module 4
Compute Module 4 IO Board 5,png.png

Onboard Resource


Label Name Description
1 CM4 Connector Applies to all versions of Compute Module 4
2 HDMI port HDMI port, supports 4K 30fps output
3 USB 2.0 interface 3x 2.0 interfaces, support various USB device insertion
4 RJ45 Gigabit Ethernet port RJ45 Gigabit Ethernet port, supports 10/100/1000M network access
5 DC power supply port 7 ~ 36V DC power supply port
6 CM4 status indicator Red light (PWR): Raspberry Pi power indicator
Green light (ACT): Raspberry Pi working status indicator
7 4G/5G module status indicator Red light (STA): module enable indicator
Green light (NET): module running status indicator
8 PWR & USB interface 5V DC power supply interface or USB burning interface
9 M.2 B KEY Slot Communication module that supports access to 4G/5G or other USB channels
10 Nano-SIM Card Holder Can be connected to a standard Nano-SIM card for 4G/3G/2G Internet access
11 BOOT switch button ON: Compute Module 4 boots to USB Type-C port
OFF: Compute Module 4 boots to eMMC or Micro SD card
12 DC power supply port 7 ~ 36V DC power supply port
13 Dual non-isolated RS485 interface Dual RS485 interface, providing 600W lightning protection, surge protection and 15KV electrostatic protection (reserve 120R optional balance resistance jumper cap)
14 Non-isolated CAN interface Anti-static and transient spike voltage (reserve 120R optional balance resistance jumper cap)
15 Micro SD Card Slot Used to insert a Micro SD card with the system to start the Compute Module 4 Lite
16 FAN Power Supply Options You can choose 5V or 12V to drive the fan
17 CAM Interface MIPI CSI Camera Interface
18 RTC Battery Connector Can be connected to CR1220 button battery
19 M.2 VCC power supply selection Choose 3.3V or 4.2V power supply
20 RTC Interrupt Pin Switch PI-RUN: RTC Trigger Interrupt CM4 Restart
GN-EN: RTC Trigger Interrupt CM4 Power Off
D4: RTC Trigger Interrupt D4 Pin
21 IO-VREF selection CM4 IO logic voltage switch 3.3V or 1.8V
22 FAN Power Supply Options You can choose 12V (default) or 5V to drive the fan
23 System function switch BT_DIS: Bluetooth disabled, only for CM4 version with antenna
WiFi_DIS: WiFi disabled, only for CM4 version with antenna
WP_DIS: Boot mode switch, only For use without EMMC boot or SD boot
24 RTC/FAN I2C bus selection SDA0/SCL0: shared by I2C-10 and CSI/DSI
GPIO3/2: shared by I2C-1 and 40PIN
25 Part of the GPIO Headers Contains a set of I2C and 2x GPIOs and power

Writing Image


The RS485 interface is disabled by default, if you want to enable it, please modify the config.txt file.

sudo nano /boot/config.txt

Add the following lines and save.


The device ports in Raspberry of RS485 interfaces are:



The CAN interface is disabled by default, if you want to use it, please modify the config.txt file.

sudo nano /boot/config.txt

Add the following lines.


Reboot the CM4.

sudo reboot

Open a terminal and run the following command to check if the spi0 interface was initialized.

dmesg | grep spi0
Compute Module 4 PoE 4G Board 1.png

Run the following commands to config the can port.

sudo ip link set can0 up type can bitrate 1000000
sudo ifconfig can0 txqueuelen 65536
Compute Module 4 PoE 4G Board 2.png

The device number can0 appears indicating the driver is OK.


Install can-utils:

sudo apt-get install can-utils

Test to receive the data:

candump can0

Test to send can data:

cansend can0 000#
# is data to send
#if you want to send other data, you edit it, for example:
# cansend can0 000#
#Note that Chinese and English can not be used together, and the data format is two-digit code 

M.2 B Key

The M.2 B Key port features PCIe, USB2.0, GPIO, I2C, and the SPI interface.
It supports connecting the following modules:

A Mini-PCIe adapter is provided for connecting devices that use the Mini PCIe package interface. (Note that it is just the Mini PCIe interface but not pinout real PCIe pins, it doesn't support PCIe devices.)


To work with 4G/5G, you need to connect a wireless module to the M.2 B KEY for featuring corresponding functions. M.2 B KEY only extends USB 2.0 interfaces.
SIM card is required to work with the 4G/5G module.
If you want to disable the 4G/5G module, you can set the GPIO6 to High and enable it again by setting the GPIO6 to Low.
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


ON OFF Shutdown or Starting
ON ON Searching network
ON Flash Working
OFF Flash/ON Shutting down

Before you configure the 4G/5G module, please make sure that the module is working normally.

Configure 5G Modules

Configure 4G Modules

  • Install minicom.
sudo apt-get install minicom
  • Run the minicom to configure moudules
sudo minicom -D /dev/ttyUSB2
  • Configure the modules with the following command.
  • Exit from the minicom and run the following command to assign IP for the usb0 (it may be different if you connect another USB adapter).
sudo dhclient -v usb0
  • If the network cannot connect properly, please run one of the following AT commands to change the frequency and test it again.

AT commands

If your 4G modules cannot connect to the network properly, please try to troubleshoot by minicom and the AT commands.

sudo apt-get install minicom
sudo minicom -D /dev/ttyUSB2
Common AT commands
Command Description Return
AT AT test OK
ATE ATE1 enable echo
ATE0 disable echo
AT+CGMI Check manfacture OK
AT+CGMM Check module type OK
AT+CSUB Check module version OK
AT+CGMR Check firmware version OK
AT+IPREX Configure hardwara baud rate +IPREX:
AT+CRESET Reset module OK
AT+CSQ Check signal quanlity +CSQ: 17,99
AT+CPIN? Check SIM status +CPIN: READY
AT+COPS? Check the current supplier +COPS:
AT+CREG? Check network status +CREG:
AT+CPSI? Check UE information
AT+CNMP Configure network mode:
2: Automatic
13: GSM only
38: LTE only
48: Any modes but LTE
... ....

For more AT commands, please refer to: AT_Command_V2.00
You can also refer to: SIMCom


Use sx1302-868m-lorawan-gateway-b.
Note: LoRaWAN gateway module has multiple frequency bands, pay attention to whether the region supports the corresponding frequency bands.

There are differences between the use procedure and the default procedure for the SX1302 868M LoRaWAN Gateway (B), the routines are as follows:

sudo wget
unzip -o -d ./CM4-IO-WIRELESS-BASE-LoRaWAN
make clean all
make all
cp tools/ util_chip_id/
cp tools/ packet_forwarder/


  • Note 1: Please connect the cooling fan before you power the whole device, otherwise, the control chip will be damaged!
  • Note 2: Please check the voltage before you connect the cooling fan, it is default 12V.

Use Raspberry Pi system (2021-05-07-raspios-buster-armhf-full).
To use the RTC, you need to disable DSI or CSI interfaces.
If you want to use DSI and CSI interfaces at the same time, switch I2C to the I2C1 (right side):


All demos or drivers need to be modified after switching.
The default demo uses I2C10 (left).
For simple use, or if you need to add it to your program, refer to the C and Python demos click here. Here's how to add the driver to the kernel.

RTC test

sudo nano /boot/config.txt
#Add the following codes at the end:
#Add "#" before dtparam=audio=on 
#Save, exit and reboot
sudo reboot

Using Hwclock

  • Synchronize the system clock and the RTC.
sudo hwclock -w
  • Synchronize the hardware clock and the RTC.
sudo hwclock  -s

Note that it will be restored if the network is disabled.

  • Set hardware clock.
sudo hwclock --set --date="9/8/2021 16:45:05"
  • Check the hardware clock.
sudo hwclock -r
  • Check the version.
sudo hwclock --verbose

FAN test

When powered on, the fan will spin for 1 second, then stop for 2 seconds, and then spin again, this is a normal phenomenon.
There is currently no official configuration method for fans, there is a third-party configuration method:
This method is released by a third party, not an official release, and we are not responsible for any problems!

mkdir -p ~/src
cd ~/src
git clone
cd cm4io-fan
sudo chmod 777
sudo  ./
#The following is a 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 directly refer to the following:
The temperature is higher than 45 degrees Celsius and starts to accelerate, and the highest speed is higher than 50 degrees Celsius.


CSI and DSI are disabled by default. When using the camera and DSI, it will occupy three I2C devices: I2C-10, I2C-11, and I2C-0.

  • Open a terminal and run the following commands:
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 want to use both cameras and DSI0
 sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
 #If you want to ue both cameras and DSI1
 sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
  • And then connect the cameras and DSI display:

1: Please power off the IO Board first before your connection.
2: Connect the power adapter after connecting the cameras and DSI display
3: Wait a few seconds before the screen boots up.
4: If the DSI LCD cannot display, please check if you have added /boot/dt-blob.bin. If the dt-blob.bin is ready, just try to reboot.
5: The camera needs to be enabled by raspi-config, enter sudo raspi-config on the terminal, choose Interfacing Options -> Camera -> Yes -> Finish -> Yes, and reboot the system.

  • Test the Cameras:

Test camera0:

sudo raspivid -t 0 -cs 0

Test camera1:

sudo raspivid -t 0 -cs 1

For more information about the CSI camera and DSI display, please refer to:



3D Drawing

Demo codes




1. Please remove the line dtparam -audio - on from /boot/config.txt file.
2. Remove dt-blob.bin file from the boot directory if it exists.




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



The carrier board only features two GPIO from the CM4.
GPIO22 and the GPIO18, we do not make an example for it, you can just follow the common guide of how to use the GPIO of raspberry Pi like the bcm2835 libraries.



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)