Skip to main content

4G/5G

This section introduces how to use the M.2 B KEY interface functions on the Raspberry Pi, laying the foundation for subsequent project development.

danger
  • The test uses the SIM7600. If using other modules, refer to the corresponding 4G/5G module's Wiki.
  • The board itself does not support 4G/5G; the module must be connected via the M.2 B KEY interface. The M.2 B KEY interface provides only a USB2.0 channel and does not support PCIe devices.
warning
  • To turn off the 4G/5G module, use GPIO6 (BCM pin 6). Output high to disable the module, output low to enable it.
  • Enabling or disabling the module takes some time (approximately 30 seconds).

Troubleshooting

No new ttyUSB device appears

  • Execute the following commands in the terminal to load the USB device descriptors:
    sudo modprobe option
    sudo sh -c 'echo "1e0e 9011" > /sys/bus/usb-serial/drivers/option1/new_id'
    sudo sh -c 'echo "1e0e 9018" > /sys/bus/usb-serial/drivers/option1/new_id'
    sudo sh -c 'echo "1e0e 901E" > /sys/bus/usb-serial/drivers/option1/new_id'

Setting up the AT command configuration environment

  • Install the text-based serial communication tool minicom:

    sudo apt-get install minicom
  • Connect to the 4G/5G module port (use ttyUSB2, which appears when the module is connected; adjust the port according to your actual situation):

    sudo minicom -D /dev/ttyUSB2
  • The following AT commands are common to both 4G and 5G modules:

    CommandDescriptionReturn Value
    ATTest commandOK
    ATEATE1 enables echo
    ATE0 disables echo
    OK
    AT+CGMIQuery module manufacturerOK
    AT+CGMMQuery module modelOK
    AT+CGSNQuery product serial numberOK
    AT+CSUBQuery module version and chipOK
    AT+CGMRQuery firmware version serial numberOK
    AT+IPREXSet module hardware serial port baud rate +IPREX:OK
    AT+CRESETReset moduleOK
    AT+CSQQuery network signal quality; returns signal value +CSQ: 17,99OK
    AT+CPIN?Query SIM card status; returns READY if the SIM card is recognized properly+CPIN: READY
    AT+COPS?Query current operator; returns operator information when connected to the network +COPS:OK
    AT+CREG?Query network registration status +CREG:OK
    AT+CPSI?Query UE system information
    AT+CNMPNetwork mode selection command:
    2: Automatic
    13: GSM only
    38: LTE only
    48: Any modes but LTE
    ... ....
    OK

ifconfig cannot find the device

  • Click here to set up the AT command configuration environment
  • Compare the newly added ttyUSB interfaces (if the new interfaces are ttyUSB0~ttyUSB4). If no new ttyUSB device appears, click here to configure.
  • Use the newly added ttyUSB interface for configuration changes (here we use the newly added ttyUSB2):
    sudo minicom -D /dev/ttyUSB2
  • Enter the following command and press Enter; the module will automatically restart to apply the settings (adjust according to the actual module requirements – each module supports different dial‑up methods; the following uses Qualcomm's RNDIS dial‑up).
  • This command needs to be set only once; the module will default to this mode on subsequent power‑ups.
    AT+CUSBCFG=USBID,1E0E,9011 # 1E0E: Vendor ID 9011: according to the actual module requirements
    Various module setting parameters
  • Rescan the devices:
    ifconfig

4G/5G Usage

  • Connect the 4G/5G module and the SIM card to the device, then power on.
  • Use ifconfig to scan for usb0 (USB network adapter – the exact device name may vary; it is not necessarily usb0). If ifconfig does not find the device, click here to troubleshoot.
    ifconfig
    Scan 4G/5G modules
  • If the SIM card is properly connected, the NET LED blinks normally but no IP address is obtained, verify that the SIM card is working.
  • If the SIM card is working but still no IP address is obtained, execute the following commands in the terminal to renew the IP address:
    sudo dhclient -v usb0
    sudo apt-get install udhcpc
    sudo udhcpc -i usb0
    sudo route add -net 0.0.0.0 usb0
  • Test whether the wireless network card can ping Baidu successfully; be sure to connect the antenna.
    ping -I usb0 www.baidu.com # Here the port added by the 4G/5G module is usb0; adjust the command according to your actual situation
  • If you are using an IoT SIM card that successfully registers on the network but dial‑up fails and ping does not work, try one of the following AT commands to select the optimal frequency band (click here to set up the AT command configuration environment):
    AT+CNBP=0x0002000000400183,0x000001E000000000,0x0000000000000021
    AT+CNBP=0x0002000000400180,0x480000000000000000000000000000000000000000000042000001E200000095,0x0000000000000021