Getting Started with Cellular HAT + Twilio Super SIM

Before we jump into the tutorial, let us check all the items required for this is available with us and prepare our hardware.

Hardware Prerequisites

Most of these are the parts you will receive when you order the Sixfab Cellular IoT HAT. The goes as follows:

Note: If the SIM is purchased from the Sixfab store, please follow Sixfab SIM Getting Started.

Hardware Setup

1. Insert the Twilio Super SIM to the Cellular IoT HAT.

2. Attach the antenna, Make sure you are using the right antenna port. LTE goes to LTE port and GPS to the GNSS port.

3. Attach the HAT to the Raspberry Pi.

4. Connect the USB cable to the HAT and Raspberry Pi.

5. Finally, power up the Raspberry Pi and then press the PWRKEY button of the HAT or pulling the GPIO 24 to HIGH for around 2 sec which will power up the module. You may confirm it when the STAT LED lits. You can’t communicate with the module unless the module is turned on.

Software Setup

Enabling serial console

By default, the primary UART is assigned to the Linux console. If you wish to use the primary UART for other purposes, you must reconfigure Raspberry Pi OS. This can be done by using raspi-config:

  1. Start raspi-config: sudo raspi-config.
  2. Select option 3 - Interface Options.
  3. Select option P6 - Serial Port.
  4. At the prompt Would you like a login shell to be accessible over serial? answer 'No'.
  5. At the prompt Would you like the serial port hardware to be enabled? answer 'Yes'.
  6. Exit raspi-config and reboot the Pi for changes to take effect.

Checking Driver

In order to check the drivers, first press the PWRKEY button of the HAT which will power up the module.

Then open up a terminal and run the commands below. Expected outputs are as follows:

pi@raspberrypi:~ $ lsusb Bus 001 Device 003: ID 2c7c:0296 Quectel Wireless Solutions Co., Ltd. BG96 CAT-M1/NB-IoT modem Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspberrypi:~ $ ls /dev/ttyUSB* /dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2  /dev/ttyUSB3
Warning: Kernel versions between 5.4.66 - 5.4.81 have an issue with the driver of the Quectel module. The easiest way to solve the issue is by downgrading the kernel to 5.4.65 or by upgrading the kernel to 5.10+.

Library Installation

  1. Download the Cellular IoT HAT repository.
git clone https://github.com/sixfab/Sixfab_RPi_CellularIoT_Library.git
  1. Goto directory Sixfab_RPi_CellularIoT_Library.
cd Sixfab_RPi_CellularIoT_Library
  1. Complete the installation.
sudo python3 setup.py install

Configure the HAT for CAT-M1

Now change directory to the sample.

cd ./sample/

Here run the configureCATM1.py.

python3 configureCATM1.py

If the location of your device doesn't cover the CATM1 network, then you should try with GPRS. For this, run the configureGPRS.py.

python3 configureGPRS.py

🌐 Internet connection

PPP

PPP(Point-to-Point Protocol) is a data layer communication protocol that is established through the serial port of the modem. These Serial port communication could be either the UART(/dev/ttyS0) or the serial exposed to USB(/dev/ttyUSB3). This serial is also used for both modem commands (AT commands) and responses. This connection is established by dial-up (ATD*99#)

PPP is easy to establish, widely used protocol, and flexible with the devices. PPP may show a drop of the connection while using the AT command set for other functionality of modem.

The LTE radio protocol has native support of TCP/IP and IPv6, so there is no need to actually wrap TCP/IP into PPP over the radio interface. The PPP protocol is just used between the computer and the modem to make the connection look like a legacy dial-up modem-based network connection.

If you need to establish an internet connection for a short period of time and the date to be transferred is not high, you may stick to PPP.

Now we can proceed to establish an active internet connection.