The purpose of this repository is to provide a use case specific demo using the Programmable Wireless product. The use case chosen is industrial/home monitoring using a temperature and humidity sensor.
- Use case overview
- Programmable Wireless concepts
- Registering a Twilio SIM card
- Installation
- Dashboard
- Hardware
Problem As businesses grow, they often have trouble tracking their inventory or monitoring their storage or production environment. If they had a low-cost, reliable, and technical remote inventory monitoring solution, they could predict production needs and protect their products, increasing both efficiency and profits.
Solution We will create a Twilio-powered easy-to-deploy device to track and log relative humidity level and temperature. This project will be of interest to anyone who wants to remotely monitor inventory or environment.
This demo uses Commands to send a payload to Twilio.
The Commands resource enables you to exchange simple machine-to-machine messages from SMS-capable devices. We use SMS to send a small payload to Twilio which gets picked up by our server running locally or in the cloud. SMS is the prefered method of data transport here because the payload is small and SMS is a low-cost option, so no need to increase unnecessary power drain on a battery when not required.
Commands can be sent and received using the SMS text mode or binary (PDU) mode. Text mode Commands have a maximum length of 100 single-byte characters. Binary mode Commands have a maximum length of 140 bytes. To process a Command when it reaches your Arduino, you will interface with the modem directly. From the perspective of the device, a Command is sent as a regular SMS message.
Resource | Definition |
---|---|
Sim | A Sim instance represents a physical SIM that is capable of connecting to a wireless network. |
Rate Plans | A Rate Plan describes the capabilities and restrictions of each and every SIM associated with it. |
Commands | The Commands resource enables you to exchange simple machine-to-machine messages with SMS-capable devices. |
Data Sessions | The SIM Data Sessions list resource returns Data Session information for a SIM over no more than a 30 day period, presented as an aggregated list. |
Usage Records | The SIM Usage Records list resource returns usage information for a SIM over a specified period, presented as a list, aggregated according to the user-provided granularity. |
This section is meant to serve as a high-level walkthrough on how to register a new Programmable Wireless SIM.
- Navigate to Register a Starter SIM
- Enter the registration code from the back of the SIM
- Enter a unique name
This name that will appear in this demo's dashboard. In the screenshots above, I used the unique name "Garage Monitor"
- Click the red + button to create a new Rate Plan
- Name your Rate Plan Home Sensors
- Enable the Rate Plan with Messaging
- Enable National Roaming if necessary
- Enable International Romaing if outside of the United States
- Data Limits can be set to any number.
This demo does not currently use data but there is no harm in enabling it.
Roaming | Definition |
---|---|
National | Allow SIM to roam onto other networks in the United States. With the current Twilio SIMs, this means roaming onto other US operators where possible. |
International | Allow SIM to roam on partner networks outside of US. Programmable Wireless does not currently support International Voice. |
Set your device's APN to wireless.twilio.com so that you can use data if you are outside of the United States.
- Click the red Activate button to bring your SIM card online.
- Navigate to the SIMs section of the Console
- Locate your newly created SIM
- Click on the SIM item
- Make note of your SIM Sid, you will use this in the next section.
Your SIM Sid starts with DE and 30+ alpha numeric characters.
This demo can be run locally without deploying to a cloud provider.
- Open
server/api/config.js
in a text editor - Update line 6 with your Account Sid
- Update line 7 with your Auth Token
- Save your changes
Updating your Account Sid and Auth Token are the only configuration changes required to run the demo. You will enter your Device Sid in the Dashboard of this team once it's running.
Using a Terminal:
- Make sure Homebrew is installed
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Type
brew install node
- Navigate to the server folder
- Type
npm install
- Type
npm start
- Point your web browser to localhost:5000
Your demo app is now running locally.
This step is optional. You can run this demo locally without the need of online hosting. Use the following steps if you want to upload this demo to Heroku.
- Follow the Getting Started on Heroku with Node.js steps
- Create a new Heroku App
- Click the Deploy tab in your new Heroku App
- Upload the root directory of this repository via git
The root directory contains app.json and Procfile.
- Click the Open app button at the top right hand side of your Heroku App
Your demo app is now running on Heroku.
This demo requires a Sim Sid to pull data into the web app.
See the full story below for more information on getting your Sim Sid.
- Copy your SIM's Sim Sid into the Sim Sid input field
A SIM Sid starts with DE
- Click Save
This screenshot demonstrates how a dashboard displays data from an active device.
After inserting your SIM Sid and clicking Save, your dashboard will be populated with:
- Sim Resource's unique name
- Temperature chart
- Humidity chart
- Data Sessions table
This demo does not use data (only Commands), but an online device can return the operator, radio access tower, and estimated geolocation coordinates of the device.
- Commands table
The Options dropdown provides you the ability to
- Change your Sim Sid
- Show/Hide the Data Sessions table
- Show/Hide the Commands table
- Visit Twilio's Programmable Wireless documentation
- Visit this demo's Github repository
The Seeed Wio LTE is used in this demo.
- Insert the Nano (4FF) SIM size in to the SIM card slot of the Seeed Wio
This demo uses the a grove temperature and humidity sensor.
- Plug the grove port into D38 on the Seeed Wio
The Seeed Wio LTE comes with 2 LTE antennas and a GPS antenna.
This demo does not use GPS, but feel free to insert the GPS antenna.
- Plug each antenna in an LTE port on the back of the Seeed Wio
- Insert the micro usb cable into the Seeed wio
- Plug the other end of the USB cable in your computer to install firmware in the next section
The end result should look like the following:
- Install Chrome Web Browser
- Click here to get Espruino Web IDE
- Run Espruino Web IDE from chrome's home screen or the App Launcher (type
chrome://apps
at the address bar)
- Copy the code from wio/main.js into the right-hand side text portion of the IDE
- Connect the Wio LTE board to computer using a micro USB cable
- Click the Send to Espruino button in the middle of the IDE
- Choose the Espruino board in the selction box.
The Send to Espruino button looks like a chip with an arrow in it
On device manager you can see a new COM Port device, on MacOS it is STM32 Virtual ComPort
, on windows it is STMicroelectronic Virtual COM Port
.
The format of the Command is simply "{temperature},{humidity}". Temperature is in celsius and relative humidity is a percentage. Relative humidity is the ratio of the current absolute humidity to the highest possible absolute humidity (which depends on the current air temperature).
That's it! The code should run and send a Command (over SMS) every 10 seconds with an updated temperature and humidity reading.
You can update the delay between commands by changing the interval delay on line 60 of wio/main.js.