This might be a bit late but I have recently used 4G in combination with my Raspberry Pi. The usecase I had is somewhat different but should have the same steps to setup the 4G connection (I used a webserver on my Pi to have endpoints I could access from my PC).
First off, what I used:
- A Raspberry Pi LTE Hat (in my case equipped with the SIM7600E)
- Raspberry Pi 3b+
- A SIM card with an APN (provided by your provider).
Now for the steps to setup the connection, at first I thought aswell that I have to do a lot of AT commands to setup things. I wasted a lot of time by reading through all the commands and tutorials describing what to do, and for me that just didn't work. Eventually, I found this tutorial, which I tried on my Pi, but resulted in some errors. I found out the cause of these errors and fixed them with slight changes. The errors I encountered are explained by NOTE, but you can ignore them if you do not understand them).
So here we go:
0. Setting up the hardware
Setting up the hardware is quite simple. You attach the hat onto the pi and connect the usb from the pi to the (micro) usb
port on the hat (do not connect it to the usb-to-uart, that will not work).
I recommend to only connect the usb-to-usb connection whenever you are done with installing and updating the pi (so after 1.), just to be completely sure :)

1. Updating the Pi
First we make sure the Pi is up-to-date with everything by running the following commands:
sudo apt update -y
sudo apt dist-upgrade -y
sudo rpi-update
And then reboot.
Now we will install the libraries that we will use to setup the 4G connection:
sudo apt install libqmi-utils
sudo apt install udhcpc
(Note: in the tutorial this was sudo apt install libqmi-utils && udhcpc
, however for me this did not work as it treats udhcpc
as a command to be executed after sudo apt install libqmi-utils
, but udhcpc is not installed yet... So doing 2 seperate installs is safe.)
Some explanation for the libraries taken from the tutorial I mentioned:
libqmi-utils installs libraries that allow you to interact with Qualcomm-based modems. SIM7600 comes with a Qualcomm MDM9607 chipset. udhcpc is used for modem DHCP leasing. The cellular network gives a unique IP to the HAT and the Pi will have its own IP. This is used to solve IP addressing conflicts between the Pi and the HAT.
Now we enable UART to communicate with the device:
This should prompt an interface where you should the following:
- Go to
3 Interface Options
- Go to
P6 Serial Port
- Select
No
when asked Would you like a login shell to be accessible over serial?
and then select Yes
for the second question afterwards.
2. Configuring the SIM7600 module
Now we will configure our SIM7600E module. To turn on the module we will use the qmicli commands (installed before in step 1).
Activate the device with:
sudo qmicli -d /dev/cdc-wdm0 --dms-set-operating-mode='online'
We can now verify the status of our module (optional but recommended):
- To see if it is online:
sudo qmicli -d /dev/cdc-wdm0 --dms-get-operating-mode
- To see the signal strength and quality values:
sudo qmicli -d /dev/cdc-wdm0 --nas-get-signal-strength
- To see the carrier name:
sudo qmicli -d /dev/cdc-wdm0 --nas-get-home-network
You should now be able to see a wwan0 interface in net-stats (use ifconfig
), wwan0 is the default interface this device uses.
Now for the last steps, we configure the module to user raw-ip protocol:
sudo ip link set wwan0 down
echo 'Y' | sudo tee /sys/class/net/wwan0/qmi/raw_ip
sudo ip link set wwan0 up
And now we can connect to a mobile network:
sudo qmicli -p -d /dev/cdc-wdm0 --device-open-net='net-raw-ip|net-no-qos-header' --wds-start-network="apn='YOUR_APN', auth=BOTH,username='YOUR_USERNAME',password='YOUR_PASSWORD',ip-type=4" --client-no-release-cid
Don't forget to change the APN, username and password :)
(NOTE: In the tutorial the --device-open-net
had the value net-no-qosheader
which clearly misses -
, it should be net-no-qos-header
according to the documentation. Moreover, I had to set the authentication type to BOTH
, which was not configured in the tutorial I mentioned. This might depend on your provider.)
Finally, we set the default route and IP using udhcpc:
sudo udhcpc -i wwan0
And tell the udhcpc library to receive a DHCP lease from the network:
ip a s wwan0
And we are done, you should now be able to use 4G on your pi!
Some sidenotes
Now some notes, everytime you reboot your pi, you need to receive a DHCP lease again. So you would have to repeat some of the steps (which you can put in a script).
Steps should be:
sudo ip link set wwan0 down
echo 'Y' | sudo tee /sys/class/net/wwan0/qmi/raw_ip
sudo ip link set wwan0 up
sudo qmicli -p -d /dev/cdc-wdm0 --device-open-net='net-raw-ip|net-no-qos-header' --wds-start-network="apn='YOUR_APN', auth=BOTH,username='YOUR_USERNAME',password='YOUR_PASSWORD',ip-type=4" --client-no-release-cid
sudo udhcpc -i wwan0
ip a s wwan0
I, myself, have not yet tried automating this at startup, however I have seen some articles on the internet that do say it can be a bit tough. Apparently, a kernel uses the /sys/class/net/wwan0/qmi/raw_ip
file at boot, so we cannot temper with that at boot. And thus we cannot execute the first part of our steps that I mentioned above. If you manage to get this working on reboot, please let me know! :)
Additionally, I would like to say that I used this specific 4G hat because it was easily available. I am pretty sure you can do with a cheaper one (even without GSM), as long as you have the SIM7600 module.
Furthermore, I want to give big credits to the tutorial I mentioned, they really gave all of the information and I just fixed some things that did not work for me. So credits should go to them.
I hope this helped any of you, I have been struggling with finding much information on the internet about setting up a 4G connection and hope I will save some of your time!