Twilio Super SIM can empower a huge range of IoT devices. This guide focuses on just one of them: Waveshare's SIM7600G-H 4G Hat, a development board which equips a low-cost Raspberry Pi computer with a Simcom 7600G-H cellular modem.
This guide requires a configured Super SIM. If you haven't set up your Super SIM in the Console, please do so now. The Super SIM First Steps guide has help if you need it.
In addition to your configured Super SIM, you will need the following hardware to proceed with this guide:
The Raspberry Pi has its own setup procedure which involves downloading and installing its Linux operating system, called Raspberry Pi OS, onto the Micro SD card. The Raspberry Pi Foundation has a very good walkthrough of its own that covers this process — you should use this to get your Pi ready before proceeding to the next stage of this guide.
During setup you should connect your Pi 4 to your WiFi network as you will need to download extra software later. We'll disable WiFi in due course to demonstrate data access over cellular.
The SIM7600G-H 4G Hat ships with all you need to fit it onto the Pi. Just follow these steps to set everything up:
Fit your Super SIM into the SIM7600G-H 4G Hat's SIM retainer. This takes a full-size SIM, so take care removing your Super SIM from its mount, or use an adapter if you have removed the Super SIM as a 4FF Nano SIM:
Lock the SIM retainer in place to keep the Super SIM secure:
If it's powered up, turn off the Pi.
sudo shutdown -h
now.Slot the SIM7600G-H 4G Hat onto the Pi's GPIO header:
Connect the supplied USB cable to the micro USB port marked just USB on the SIM7600G-H 4G Hat and a USB port on the Pi:
Assemble and connect the bundled cellular antenna to the SIM7600G-H 4G Hat. Connect it to the LTE connector marked MAIN on the board:
Here's a close-up:
Finally, power up the Pi by re-inserting the power cable.
We now need to run through a few steps to get the Pi ready to talk to the SIM7600G-H 4G Hat. Some of these will require you to restart the Pi.
If you're at the Raspberry Pi desktop, select Accessories > Terminal from the Raspberry menu.
Run sudo raspi-config
.
Use the cursor keys to highlight Interfacing Options, then hit Enter:
Now highlight Serial Port and hit Enter:
When you are asked Would you like a login shell to be accessible over serial? select No and hit Enter:
When you are asked Would you like the serial port hardware to be enabled? select Yes and hit Enter:
Select Finish.
The raspi-config
utility will offer to restart the Pi — accept its suggestion.
When the Pi is back up, you should see that the SIM7600G-H 4G Hat's PWR LED is lit. Now press the PWRKEY button on the board — after a brief moment, the NET LED should light up.
At the command line or in a desktop Terminal run:
ls /dev/ttyUSB*
You should see a list of items all beginning with ttyUSB
and including ttyUSB2
, which is the device you'll use in subsequent steps. If you don't see a list of TTYs, first check that the SIM7600G-H 4G Hat's PWR and NET LEDs are lit. Make sure your USB cable is not connected to USB TO UART on the Hat.
The SIM7600G-H 4G Hat can be controlled using AT commands issued through a command-line serial console tool which communicates with the Hat's cellular module. We'll use Minicom here, but if you prefer to use an alternative tool, such as Screen, that's fine. At the command line or in a desktop Terminal run:
1sudo apt update2sudo apt install minicom -y
Enter minicom -D /dev/ttyUSB2
to open a connection to the modem. If Minicom posts an error indicating that /dev/ttyUSB2
is inaccessible, please check your SIM7600G-H 4G Hat setup.
The SIM7600G-H may not be set to echo back what you type in, so you won't be able to see your side of the conversation. Type in ATE1
and hit Enter . You'll get an OK
back, and when you follow the remaining steps you'll see what you type!
Just hit Enter after keying in each of the following commands. Wait for the modem to respond before moving on to the next command.
1AT+CGDCONT=1,"IP","super"2AT+COPS?
You should see something like +COPS: 0,0,"Vodafone UK Twilio",7
which tells you which network you're connecting through. You should also see the Hat's NET light flashing.
Now you know you have a cellular connection, you can connect to the Internet. You need to install the PPP (Point-to-Point Protocol) software the PI will use to establish the connection, and to configure it. First run the following commands at the command line:
1sudo apt install ppp -y2sudo cp /etc/ppp/peers/provider /etc/ppp/peers/provider.bak3sudo nano /etc/ppp/peers/provider
The last of these commands opens the primary configuration file in a text editor so you can make the required changes. Make sure the file contains the following lines. Some may be missing, others may be present depending on the version of ppp
you've installed:
1nocrtscts2debug3nodetach4ipcp-accept-local5ipcp-accept-remote
In the same file, look for lines like these and update them so they match what's shown here:
1connect '/usr/sbin/chat -s -v -f /etc/chatscripts/gprs -T super'23/dev/ttyUSB2
The last line above is the value you determined earlier.
To initiate an Internet connection, at the command line or in a desktop terminal run:
sudo pon
You'll see a stack of lines displayed at the command line.
Meantime, open a fresh terminal and enter:
sudo route add -net "0.0.0.0" ppp0
When the prompt is back, you're ready to try out the Internet connection:
If you're at the desktop, select Turn off Wireless LAN from the network menu at the top right.
If you're at the command line, run sudo ifconfig wlan0 down
.
At the command line or in a desktop terminal, enter ifconfig
and look for the ppp0
entry — it should have a valid IP address listed under inet
:
Open up a browser and navigate to twilio.com/docs/iot:
Well done! You now have a Raspberry Pi computer that's connected to the Internet via Twilio Super SIM. You can now start experimenting with cellular Internet connectivity, or begin developing your own IoT application proof-of-concept.
Your Raspberry Pi and Waveshare SIM7600G-H 4G Hat are now able to access the cellular network. Over to you: what are you going to build? We can't wait to find out.
In the meantime, here are some suggestions for things to try: