Skip to content

SMS Messages

Timothy Woo edited this page Jan 8, 2018 · 19 revisions

A super cool feature of the shield is that you can also send and receive text messages! This can be very useful for SMS-initiated sensors, security system SMS alerts, etc. For this tutorial I'll be using the Hologram.io developer SIM card and I'll explain the different ways you can send and receive texts and automatic replies to certain text messages!

Sending Texts

The easiest way to send a test text message is to load the "LTE_Demo" sketch as described here. Enter the "s" command and then type in your phone number, making sure to also type the country code at the beginning without spaces or "+" sign. For example, I live in the United States so I would simply type "1XXXYYYZZZZ" without spaces or dashes. It should send the SMS and you should see it on your phone within a few seconds!

Manually Receiving Texts

Now to test receiving a text, let's first go to the Hologram Dashboard and click on the "Devices" tab on the left hand side. Click the device you're interested in and then click on the "SMS" tab:

Simply enter the message you want to send to the SIM7000 shield and press Send!

Using the same "LTE_Demo" sketch, enter the command "R" to read all SMS messages. You should see the test message appear! To delete it so that you don't stockpile messages, use the command "d" and enter the one you want to delete.

Automated SMS Replies

One thing that might be cool is to send an automated reply to a message. Upload the example sketch here that I've created based on an example sketch from Adafruit. This code allows the shield to send different responses based on the contents of an incoming text. Whenever the shield receives an SMS it will reply with a response to the originator of the text (your phone) depending on what was in the text message. For example, you could program it to look for a magic password like "OPEN SESAME!" for it to do something special. In the example sketch it will just reply with a text message but you can add things like a special command to activate a relay or solenoid, read GPS location data, or trigger something else! If the password isn't in the text message it simply sends back arbitrary sensor data (from analogRead).

To test it out, go to the same Hologram Dashboard and this time enter your phone number in the second field, including your country code (no special characters or spaces!). Type a random message and press Send.

This time when you send the SMS the shield will know where it's supposed to reply to and send the sensor data to the phone number you specified! Now send "OPEN SESAME!" and you should get a text "Treasure chest unlocked!" because your text matches the password exactly. You can also try sending "123 OPEN SESAME!" and it should now respond with "Opening secret door!" because the text message included the password but had other stuff in it. Lastly, try anything that doesn't have the password and it should text your phone with the sensor data!

Hologram Dashboard "Routes"

Another thing you can try is not including the return phone number in the SMS that you send from the Hologram Dashboard. In this case, instead of sending a reply to your phone it will send it back to the cloud. So if you send "testing 123" to the shield without specifying a return phone number, the shield will send the "Sensor reading: 349.25" to the cloud and you can see the value under the "Console" tab on the left hand side of the Hologram Dashboard.

Now that the data is being sent to the cloud instead of to your phone you can do some interesting things with it. Under the "Routes" tab you can set up email or SMS alerts, send an HTTP POST request to a URL of your choice, interface with IFFFT for even more options, etc. etc.! As you can see you can do a lot of cool stuff with this!

First of all, full documentation for Hologram Dashboard features can be found here but I'll attempt to summarize.

Let's begin by adding a new route under the Console tab. Enter a descriptive name like "Email alerts" or something. Now it's time to select a "topic" which is essentially where data is coming from. By selecting topics you are telling the route to listen to those data sources and perform the actions of the route you are creating. For now let's just choose our SIM7000 device, although note that there are more options that might be worth investigating!

Next up is to insert an operation if required. For example, you can add a "Heartbeat" operation that will trigger the route to send an alert (next section) when the device hasn't posted within the last 15 minutes. For now we'll skip this and go to the action section. For simplicity let's just choose the Email option and type in our email address and subject. This action will send an email and include the data in the body of the email if we use "<>". Note that if you are sending JSON data to the Hologram HTTP API you can do stuff like "<<decdata.temperature>>" and parse the JSON!

Send a text to the shield using the dashboard's SMS feature without specifying a return number. Shortly after sending you should see a new sensor reading pop up in the Console and you should receive an email with the data in it! Now experiment away and share your cool projects!