Authors: Drew Johnson and Yixiang Chen
For this project, you will need the following:
You can find many Raspberry Pi starter kits both online and in electronics retail stores. An important aspect to consider in choosing a Pi kit for this project is power supply. Since we will be using a USB cellular modem, we need ample power supply for the USB ports on the Pi. A Pi 3B model can draw as much as 1.34 amps from the USB ports when all the ports are in use for keyboard, monitor and other peripherals. Therefore, we recommend a minimum 2.5 amps power supply.
A MicroSD Card
You need at least an 8GB MicroSD card to install an OS for the Pi.
USB Cellular Modem
We will use a ZTE MF 691 USB modem for this project. You can use other modems. A good way to check if an off-the-shelf modem can work with the Pi is to check if that modem is listed onthispage.
An Aeris SIM Card
You canorderan Aeris Neo SIM online. This low-cost SIM is tailored for small-scale IoT projects like this one.
You need to register a PubNub account for this project.
Follow the official OS image installation guide fromraspberrypi.orgto install Raspian on your Pi.
Occasionally, the installer may complain file system errors during OS installation. A quick way to get rid of those errors is to try a different MicroSD card.
Install Required Packages
DO NOTplug in your cellular modem yet. Install all required packages through the Wi-Fi or the Ethernet connection on your Pi to avoid unnecessary cellular charges.
The official Raspian image has a rather older version of NodeJs:
$ node --
We need to upgrade it to anES6compatibleversion of NodejS. But the default Debian repository used by Raspian usually doesn't contain the latest NodeJs binary distributions. Therefore, we first add the official NodeSource repository to the Pi:
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
Then we install the latest NodeJs binary distribution:
$ sudo apt install nodejs
We can check the version installed:
$ node --
Install the Node Package Manager so we can use it later to download required NodeJS packages to use PubNub:
$ sudo apt-get install npm
Check the NPM version installed:
$ npm --version3.10.10
PubNub NodeJS SDK
Create a new directory and install the PubNub SDK under that directory:
$ mkdir piday
$ cd piday
$ npm install pubnub
Download our collector client from Github:
$ curl https://github.com/aerisiot/secure-pubsub/blob/master/securePubNub.js
Finally, install network utilities used by the collector client to manage the cellular modem:
$ sudo apt-get network-manager usb-modeswitch modemmanager
Next Blog: Set Up