跳转到内容

2007 CM4 LoRa and 4G EN

来自Mcuzone Wiki

切换语言为中文

Keywords

Raspberry Pi, LoRa, CM4 Core board, OS Flashing, 4G LTE, SSD, RPiOS

I. Introduction

The CM4_LoRa expansion board is designed based on the CM4 core board, featuring two Mini PCIe interfaces for connecting LoRa modules (while maintaining compatibility with 4G modules). It features one PCIe M-KEY interface supporting NVMe SSDs, and one RTC. Other resources are standard CM4-compatible, including CSI1, DSI1, native Gigabit Ethernet, standard HDMI, a TF card slot for booting, a 40-pin expansion interface, 3.3V and 5V fan connectors, and two USB 2.0-A ports (one of which is multiplexed with a 1.25mm 4-pin port for internal 4G device connectivity). It can be used for eMMC flashing via the USB-C port. The expansion board features a DC5.5 interface and supports 7-24V voltage input. For core boards with eMMC, booting the OS from eMMC is supported, for core boards without eMMC, booting from a TF card or an SSD is supported.

The Raspberry Pi CM4 communicates with the LoRa module via a USB port. The LoRa module also features on-board RS485, RS232, and UART interfaces, which are all independently accessible.

The CM4 LoRa Expansion Board supports Mini PCIe interface 4G modules, which are driver-free and require no dial-up setup. Under the Raspberry Pi OS/Ubuntu OS, no additional drivers need to be installed.

II. Hardware Spec

1) 1*native Gigabit Ethernet port.

2) 1*PCIe M.2 M-KEY slot, supporting NVMe SSD, compatible with 2242/2280 form factors, with 2280 mounting stud pre-installed.

3) 2*USB2.0 Mini PCIe interfaces supporting LoRa modules and 4G LTE modules.

4) 2*USB 2.0-A host ports, one of which is multiplexed with a 1.25mm-4Pin port.

5) 1*RTC, DS1307, with 1.5mm-2p interface (button cell battery not included).

6) 1*standard HDMI port supporting 4K resolution.

7) 1*4-lans CSI (22PIN, 0.5mm, flip-down connection).

8) 1*4-lans DSI (22PIN, 0.5mm, flip-down connection).

9) 2*Nano SIM card slots, used with 4G LTE.

11) Reserved SMA antenna mount.

12) TF card slot, used for booting the OS on CM4 core boards without eMMC.

13) 1*USB-C port, used for eMMC flashing and also capable of powering expansion boards, 5V3A.

14) Bring out 40-pin GPIO, fully compatible with Raspberry Pi 4B pins.

15) Power Supply: 7-24V DC5.5-2.1 wide voltage input.

16) Size: 111*135mm. PCB board immersion gold process, lead-free production, PCB material certified by UL and ROHS, flame retardant rating 94V-0.

2007_CM4_LoRa_4G_70.jpg

The pin definitions for the 40-pin connector, from left to right:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2pin 5V 5V GND G14 G15 G18 GND G23 G24 GND G25 G08 G07 IDSC GND G12 GND G16 G20 G21
1pin 3V3 G02 G03 G04 GND G17 G27 G22 3V3 G10 G09 G11 GND IDSD G05 G06 G13 G19 G26 GND

The MiniPCIe 4G models are as follows: Domestic solution CAT4 4G and ZTE CAT4 4G, Quectel EC20-GPS Voice Lite version (with call and SMS functions), Qualcomm 4G, and Qualcomm 4G-GPS version. There are also international versions, such as the Qualcomm 4G European version (NL668-EU), Australian version (NL668-EAU), and North American version (NL668-AM), among others.

0020_MP4GM_63.jpg

0030_MP4GM_23.jpg

Antenna connection instructions for 4G modules, applicable to all 4G modules tested in this document (GPS/GNSS is optional):

III. Flash OS

This document was tested using Raspberry Pi OS. The version of Raspberry Pi OS is 2024-10-22-raspios-bookworm-arm64.img.xz.

You can download it in:

https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit

Core boards with eMMC have the OS flashed into the eMMC, and the onboard TF card unusable. Core boards without eMMC have the OS flashed into the TF card or an NVMe SSD.

For core boards with eMMC, use a jumper cap to short the BOOT pins before flashing the OS. Connect the expansion board to the computer using a USB Type-C cable.

2007_CM4_LoRa_4G_82.jpg

After the flashing is completed, remove the jumper cap and power on again to start the OS.

The flashing method, please refer to: How to flash OS

IV. Work with Raspberry Pi OS

4.1 Peripheral test

4.1.1 Gigabit Ethernet test

Connect the Gigabit Ethernet port to the upstream router, and execute ifconfig -a on the terminal, which displays the following:

2007_CM4_LoRa_4G_81.jpg

The obtainable IP address is 192.168.8.101.

Install the speed testing software iperf3:

sudo apt install iperf3

Then we tested using iperf3:

Gigabit Ethernet speed test result: about 943Mbps in Client mode:

About 949Mbps in Server mode:

Note: The speed test results of Gigabit Ethernet are affected by network conditions and testing methods. The actual speed may vary, and this test is for reference only.

4.1.2 NVMe SSD test

NVMe SSDs can be used as an OS boot device. For usage methods, refer to "III. Flash OS". Here, SSD testing is intended for data storage purposes.

In the Raspberry Pi OS, enter the File Manager and then authorizing SSD partitions:

Enter ls /dev in the terminal to see the SSD mounted:

Install the hdparm software:

sudo apt install hdparm

Execute the command multiple times to test the SSD speed repeatedly:

sudo hdparm -t /dev/nvme0n1p1

The test result shows that the SSD's interface speed is around 350MB/s.

Note: Testing speeds are affected by various factors such as network conditions, SSD quality, and file storage status. The above test results are for reference only and do not represent the final parameters of the actual product.

4.1.3 DSI test

We tested using the 1st-gen Raspberry Pi LCD, which requires independent power supply. It is equipped with a 0.5mm-22P to 1.0mm-15P adapter board and corresponding FPC cables to connect with the expansion board.

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

2007_CM4_LoRa_4G_08.jpg

After saving and restarting the OS, you can use the Raspberry Pi 7-inch touchscreen.

4.1.4 CSI 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

2007_CM4_LoRa_4G_10.jpg

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

You will then see the video0 device (if one camera is connected, video0 will be displayed; if two CSI cameras are connected, video0 and video1 will be displayed, regardless of which CSI port they are plugged into).

Execute libcamera-hello --camera 0 in the terminal to open the corresponding camera for preview (camera 0 corresponds to video0 in dev).

2007_CM4_LoRa_4G_12.jpg

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:

2007_CM4_LoRa_4G_14.jpg

4.1.5 USB2.0 test

After the OS is powered on, insert the USB devices into the two USB 2.0 ports, as shown below:

In the terminal, execute lsusb, and the display is as follows:

The identification is normal. The corresponding device numbers will not appear when there are no external devices connected to the USB ports.

Then execute lsusb -t to check whether the USB ports are operating in the correct mode:

Bus 05: USB 2.0 port, 480M.

Working mode normal.

4.1.6 RTC(DS1307) test

Note: The RTC chip requires an external battery (the battery interface is located under the CM4 core board, to the right of the BOOT pin, 1.5mm-2p interface) to prevent data loss, as shown in the figure:

First, enable I2C:

Click the Raspberry Pi icon in the top-left corner - Preferences - Raspberry Pi Configuration - Interfaces, as shown in the figure:

Then edit config.txt:

sudo nano /boot/firmware/config.txt

Insert the following lines at the end of the file:

dtoverlay=i2c-rtc,ds1307

2007_CM4_LoRa_4G_16.jpg

After saving and exiting, restart the OS, then enter ls /dev/r* in the erminal to see the RTC device:

5012_CM5_SSD_14.jpg

The command to display the current system time is date;

The command to write the system time to DS1307 is sudo hwclock -w;

The command to read the system time from DS1307 is sudo hwclock -r.

As shown below:

5011_CM5_UART_16.jpg

If the RTC battery is not properly connected, restarting after a power outage will restore the OS to the default time (January 1, 1970), as shown in the figure below:

5009_CM5_3ETH_14.jpg

4.2 LoRa test

When using LoRa, the M0 and M1 pins must be shorted with a jumper cap to activate the LoRa module. The LoRa model we selected is the E22 400T30E, which supports USB communication and also features three communication interfaces: RS485, RS232, and TTL level.

E22 400T30E LoRa module manufacturer's test data:

RF and hardware parameters of the module:

Parameter Name Parameter Value Notes
Operating frequency band 410.125 - 493.12MHz
Transmission power 30dBm Software adjustable, requires user development and configuration.
Receiver sensitivity -124dBm Air data rate: 2.4kbps.
FIFO 240Byte Supports packet size configuration via commands: 32/64/128/240bytes.
Modulation method LoRa Next-generation LoRa modulation technology.
Air data rate 2.4k - 62.5kbps User-programmable control.
Measured distance 10km In clear and open environment, antenna gain: 5dBi, antenna height: 2.5m, air data rate: 2.4kbps.
Antenna form IPEX 1 Equivalent impedance is about 50 ohms.

Electrical parameters:

Electrical parameters Min. Typ. Max. Notes
Power supply voltage (V) 3.3 5.0 5.5 ≥5.0V ensures output power, exceeding 5.5V will permanently burn the module.
Communication level (V) 3.3 When using 5V TTL, it is recommended to add level conversion.
Transmit current (mA) 650 Instantaneous power consumption
Receive current (mA) 17
Sleep current (mA) 2 Software shutdown
Operating temperature (°C) -40 20 85 Industrial-grade design
Operating humidity (%) 10 60 90
Storage temperature (°C) -40 20 125

Note: When using the USB communication interface, the operating voltage is 3.7 - 5.5V.

This expansion board also supports LoRa module models such as E22 230T30E, E22 230T33E, and E22 400T33E.

4.2.1 Two modules transparent transmission mode (USB communication)

This article demonstrates by configuring two modules in transparent transmission mode.

After the two LoRa modules are assembled, power on the OS.

Enter ls /dev to check the two serial port devices, which are ttyUSB0 and ttyUSB1 respectively.

Install the serial port software CuteCom:

sudo apt install cutecom

Open two CuteCom windows, connect to ttyUSB0 and ttyUSB1 respectively. When information is entered in one window, the other window will output the entered information:

4.2.2 Two modules transmit data via RS232

Connect RS232_A and RS232_B to a PC via USB-to-RS232 modules respectively:

Then perform data transmission between these two interfaces. The results are as follows:

Explain that two originally independent RS232 interfaces have now established a transmission channel through two LoRa modules, enabling data transfer between them.

4.2.3 Two modules transmit data via RS485

Connect RS485_A and RS485_B to a PC via USB-to-RS485 modules respectively:

Then perform data transmission between these two interfaces. The results are as follows:

Explain that two originally independent RS485 interfaces have now established a transmission channel through two LoRa modules, enabling data transfer between them.

4.2.4 Two expansion boards transmit data via LoRa and serial port

Two expansion boards, each equipped with a LoRa module (with antennas attached), are connected to a PC via serial port converters, respectively. Each expansion board is powered independently (without inserting a CM4), as shown in the diagram:

Connect RS485_B on expansion board 1 to PC1 via a USB-to-RS485 module, and connect RS232_B on expansion board 2 to PC2 via a USB-to-RS232 module. Use serial port tools on the two PCs to send and receive data to each other:

PC1/PC2:

Two LoRa modules transmit and receive information between each other via their respective RS485/RS232 interfaces. At this point, the two LoRa modules are independent of the CM4 core board, and the expansion board merely provides power input to the modules.

The expansion board provides RS485/RS232/TTL interfaces, allowing us to select one interface from each of two expansion boards and use it to send and receive information between the two LoRa modules.

4.3 Test 4G module (driver-free)

4.3.1 Single 4G test

This expansion board's MiniPCIe interface supports 4G modules with driver-free, plug-and-play functionality and auto-identification. Our tests utilized Qualcomm 4G LTE modules. The corresponding 4G modules and SIM slots are shown in the diagram above. Both M0 and M1 positions have no short-circuit caps installed.

Note: This expansion board does not support SIM card hot-swapping.

Start the OS, execute ifconfig -a, and check the network status of the 4G module. It can be seen that the IP has been correctly obtained:

After obtaining the IP, ping the domain name:

We successfully ping domain name, indicating that the 4G module is functioning properly.

▶ When using the EC20 4G module, the OS may be able to ping IP addresses but fail to ping domain names, reporting a DNS error:

3012_CM4_5G_Mini_16.jpg

At this point, the OS needs to install the DNS switching software udhcpc.

Connect the Ethernet port of the expansion board to the upstream router, and then execute the following command in the terminal:

sudo apt install udhcpc

1005_Zero-DETH_DUSB_55.jpg

After installation, unplug the network cable and execute:

sudo udhcpc -i usb0

After the execution is completed, we ping the IP and domain name, and both are successful.

4.3.2 AT command operation

Install minicom:

sudo apt install minicom

In the terminal, execute the command lsusb, the section highlighted in the red box is the 4G module:

Record the ID value of the 4G module: 05c6 90b6.

Use the following command to open the ttyUSB serial port, where the value after echo is the ID recorded above:

sudo modprobe option

sudo sh -c 'echo 05c6 90b6 > /sys/bus/usb-serial/drivers/option1/new_id'

After executing the above two commands, proceed with ls /dev/ttyUSB:

At this point, you should see three devices, ttyUSB0-2, under the dev directory:

Open the AT command serial port using minicom:

sudo minicom -D /dev/ttyUSB0

(Note: Typically, three ports (ttyUSB0 to ttyUSB2)will appear. In general, the AT port is ttyUSB0 under most OSs. If that doesn't work, you may try other ports such as ttyUSB1. If multiple USB-to-serial devices are present, further attempts will be needed until the correct AT port is identified.)

The first time you enter an AT command, there may be no echo. If you then input the command at and press Enter, and it returns "OK," it indicates that everything is working properly. If you need to check the echo, please type the command: ate1, then press Enter. After that, you can continue to type other commands and see the inputs.

If you need to change the 4G module's IP to directly obtain a public IP, please execute:

AT+GTIPPASS=1

Common AT commands:

1. Check if the SIM card is detected:

at+cpin?

Return ready to indicate the card has been recognized, if return error, you need to check the hardware.

2. Check antenna signal quality:

at+csq

Return values between 26 and 31 indicate a good signal, with 31 representing a full signal strength; return values between 20 and 25 indicate a barely acceptable signal; return values below 20 indicate a poor signal or that the antenna might not be connected.

3. Check network registration status:

at+cops?

Normally, it should return the network supporter's code: 7, where 7 represents 4G.

Note: The above command at+csq should not include a question mark, while the other two commands require a question mark.

4. View the SIM card's IMEI code:

at+cgsn

5. Reset 4G module (Sometimes, if you reinsert the SIM card, hot swapping may not work; in such cases, you can use this reset command to reset the module.):

at+reset

6. Disable radio frequency:

at+cfun=0

Enable radio frequency:

at+cfun=1

The two commands mentioned above can be used in pairs to allow the module to re-register with the network without restarting the 4G module.

4.3.3 Dual 4G test

Here, Qualcomm 4G LTE and ZTE CAT4 4G are used.

If two 4G modules are inserted simultaneously, the recognition status is as follows:

The first module is ZTE CAT4, and the second module is Qualcomm 4G LTE.

Execute ifconfig -a to check the network status of the 4G module. It can be seen that the IP has been correctly obtained, where eth1 is ZTE CAT4 and usb0 is Qualcomm 4G LTE:

Test pinging a domain name separately through these two 4G modules.

ping www.mcuzone.com -I eth1

ping www.mcuzone.com -I usb0

To use AT commands under dual 4G, please refer to the previous section and open the corresponding serial port using the ID value of the corresponding module for operation.

4.4 Application (remote control)

This section explains how to use remote control software with the expansion board connected to 4G and LoRa modules respectively.

4.4.1 Remote control with Raspberry Pi Connect

Raspberry Pi Connect is an official remote control software developed by Raspberry Pi, supporting both remote desktop and remote SSH. For more details, please refer to the following link:

Remote control of Raspberry Pi OS using Raspberry Pi Connect

After successful remote connection, you can perform the operations described in the previous sections of this chapter on the LoRa module through the remote interface.

4.4.2 Remote control with VNC

Download the corresponding Windows version from the official VNC website.

You can download it in:

https://manage.realvnc.com/en/download

Select Windows version:

After the download is complete, install the VNC by following the default settings:

After installation, register as a new user (new free users get a half-month trial, if you already have an account, please log in directly):

Please fill in the relevant information to complete registration:

After successful registration, note down this VNC Password in the pop-up window, then click "Launch":

This brings you to the main interface of VNC:

Start the Raspberry Pi OS and enter the Raspberry Pi OS desktop. Click the Raspberry Pi icon in the upper left corner, then go to Preferences - Raspberry Pi Configuration - Interfaces.

Enable the VNC option as shown in the figure:

In the PC's VNC window, click on the menu "Files - New connection...".

Enter the IP of the Raspberry Pi OS, customize a name, then click "OK":

Return to the VNC window and click on the newly established connection:

Click "Continue":

Enter the username and password for Raspberry Pi OS:

We have entered the desktop of the Raspberry Pi OS and can remotely control it from here. You can perform the operations described in the previous sections of this chapter on the LoRa module through the remote interface:

2007_CM4_LoRa_4G_49.jpg

Contact Us

0001_x.jpg 0002_fb.jpg 0004_ytb.jpg 0003_bb.jpg 0005_qq.jpg QQ:8204136

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