In this tutorial, you connect a CAT-M1 LTE-enabled IoT device to a 5G Edge API server on an Amazon EC2® instance in the Boston Wavelength Zone (us-east-1-wl1-bos-wlz-1).
Requirements and getting started
To build this tutorial, you will require a Verizon ThingSpace account for your IoT connectivity plan, the Monarch Go IoT device from our ThingSpace Marketplace, a Raspberry Pi® 4 device and an active Amazon Web Services® (AWS® ) account.
First, make sure your AWS account has Wavelength Zones enabled. If you have not submitted your request to get access, please complete the sign-up form here.
After purchasing the Raspberry Pi 4, make sure you have a USB-C charger (i.e., same as MacBook Pro 2017+) to power the device. You will also need a Monarch Go Pi Hat which includes everything you need—including the LTE module— to plug directly onto the Raspberry Pi board
While you wait for shipment, visit the ThingSpace Marketplace to activate your SIM card with a monthly data plan of your choice. Note: Since you already have a Verizon-certified SIM in your Monarch Go, you will need the ICCID and IMEI values on the module (see white sticker attached to Monarch Go module)
Upon shipment(s) arrival, follow the Raspberry Pi Getting Started Guide to boot the OS and then attach the Monarch Go Pi Hat to the board. For more information on configuring your board, visit a step-by-step guide here from the Avnet team
Configuring your headless Raspberry Pi setup
Plug your SD card into your laptop (you may need an SD-card-to-USB-C adapter), and then navigate to the boot directory on the SD card (cd ~/Volumes/boot)
Download vim from the package manager:
sudo apt-get install vim
Create an empty file named SSH in the boot directory of the SD card (vim SSH)
Create a new file named wpa_supplicant.conf, which tells the Raspberry Pi how to connect to your Wi-Fi network to enable a headless boot. Be sure to edit the ssid and psk with your Wi-Fi network name and its corresponding password:
Edit the cmdline.txt file to change the console universal asynchronous transmitter/receiver (UART) from primary UART to secondary UART (serial1), which the Monarch Go Pi Hat requires. Within that first line, change console=serial0 to console=serial1. After this step, eject the SD card from your laptop and plug it back into your Raspberry Pi
Use the native ARP protocol (arp -a) to find the address of your Pi on your local network. Alternatively, you can leverage ping (ping raspberrypi.local) to get the IP address if connected to your Wi-Fi network
Upon retrieving the address of your Pi, ssh into the board. Remember to supply the default password of raspberry:
Configure the UART.
Open the Raspberry Pi configuration page
- Select option Serial 5: Interfacing Options
Select option P6: Serial 5
At the prompt "Would you like a login shell to be accessible over serial?" answer No
At the prompt "Would you like the serial port hardware to be enabled?" answer Yes
Select Finish to exit, and Yes to reboot the Raspberry Pi
After rebooting, ssh into your Raspberry Pi as you did earlier.
Verify the connection to your LTE modem.
To get started, download the minicom package, which is a text-based modem control and terminal emulator program:
Next, configure the general-purpose input/output (GPIO) pins on your board, which adjusts the RTS/CTS signals you need for the Monarch Go to communicate over LTE:
Establish the communication to the modem using minicom:
Now that you have direct communication to the modem, verify that you can connect to the modem and that the modem can connect to the LTE network. Run the command AT+CEREG? and you should see an output generated that looks something like this:
Exit minicom (CTRL-A + X)
sudo apt-get update && sudo apt-get install minicom
echo 17 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio17/direction
echo 0 > /sys/class/gpio/gpio17/value
echo 16 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio16/direction
minicom --device /dev/serial0
+CEREG: 2,1 "150B","00539391",7
Configure point-to-point protocol for the Monarch Go.
To communicate over LTE, you need to enable the point-to-point (PPP) protocol by downloading the package (sudo apt-get install ppp) and adding a few additional files
Add a new file titled pp0 (sudo vim ppp0 /etc/network/interfaces.d/) with the following text, which creates the PPP network interface connection:
iface ppp0 inet ppp
Next, we need to create a new file named sequans in the /etc/ppp/peers/ folder with the following contents:
connect "/usr/sbin/chat -t6 -f /etc/chatscripts/connect"
disconnect "/usr/sbin/chat -t6 -f /etc/chatscripts/disconnect"
Next, add a new file connect in the /etc/chatscripts/ directory that provides the AT commands for the connect chatscript. Then, add a new file disconnect in the /etc/chatscripts/ directory that provides the AT commands for the connect chatscript:
# This is the chat script used to hang up the Sequans Module
Edit the /etc/network/interfaces file and add the line auto ppp0 to the end of the file
To configure ppp0 as the default network, find the IP address of the ppp0 interface (netstat -rn). The correct IP address will be the one with the Iface column indicating that it is of type ppp0 (not wlan0)
With the IP address of the pp0 interface, add the IP to the default route to your gateway:
sudo route add default gw XXX.XXX.XX.X
You’re all set! Your Raspberry Pi will now connect, by default, to the LTE modem
Configure your 5G Edge Flask server.
To communicate to 5G Edge, you’ll need to enable a Wavelength Zone in a public subnet within a virtual private cloud (VPC), attach a carrier gateway to the subnet, launch an EC2 instance, allocate a carrier IP address to our EC2 and run a Flask server to accept incoming HTTP traffic.
To provision your 5G Edge infrastructure, you’ll need the AWS CLI version 2 installed on your local machine. To launch an EC2 instance in a Wavelength Zone of your choice, view this tutorial using the CLI
After configuring your infrastructure, ssh into the EC2 instance in the Wavelength Zone and open a new file app.py to accept GET request traffic over the test endpoint:
from flask import Flask, jsonify
return "Hello from 5G Edge!"
Run the API server and terminate the session:
nohup python api.py &
- Next, ensure that your endpoint is configured correctly. From the Raspberry Pi shell, download python3 and connect to the /test endpoint. Note that in the request URL, the public IP address of your endpoint is the carrier IP that you attached to the EC2 instance in the Wavelength Zone:
Congratulations, your "Hello World!" application using ThingSpace and 5G Edge is complete!
sudo apt update
sudo apt install python3