SMS Messages - botletics/SIM7000-LTE-Shield GitHub Wiki

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, including the "+" symbol. For example, if in the US, use country code "+1" and type something like "+12223334444" without spaces or dashes. In this example we will send to "+447937405250", which is Hologram's cloud endpoint number:

NOTE: For Hologram SIM cards sending texts is $0.19/message per the Hologram pricing page. However, incoming texts are totally free! To avoid the outgoing SMS charges, consider using data to send the messages through the Hologram API instead!

Furthermore, all Hologram SIM cards have an outbox number with a +882 country code that appears on all outbound SMS messages. This country code may be blocked by certain carriers, and Verizon seems to be one of them (for more info please see this question on the Hologram forum). However, AT&T does not have this issue (at least in the US). If you are running into this issue with Verizon, either switch to AT&T instead, or you might need to ask the carrier that is blocking the SMS messages to whitelist the specific number. Furthermore, please see the "Hologram SMS Route" section at the end of this page for a workaround.

Manually Receiving Texts

Now to test receiving a text, go to the Hologram Dashboard, click on "Active SIMs" under the "SIMs" heading on the menu on the left, 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! Since here we didn't include a "From number", it will appear as being from the Hologram cloud number "+447937405250". To delete it from the SIM7000, use the command "d" and enter the one you want to delete (indexed from 0).

Automated SMS Replies

If you want your SIM7000 to do something special based on what SMS messages it receives and send a reply to that number, upload the SMS_Response example sketch. Whenever the shield receives an SMS it will reply with a response to the originator of the text, depending on what was in the text message. By default, the code looks for the magic password "OPEN SESAME!" for it to do something special and reply with a text message. However, you can spice it up with special commands to activate a relay or solenoid, read GPS location data, or trigger something else! If the password isn't in the text message (like if you texted it "test 123") it simply sends back arbitrary sensor data (from analogRead).

To test it out, go to the same Hologram Dashboard and this time send "OPEN SESAME!" to the SIM7000.

In the Arduino IDE serial monitor you should see the message being received, and an SMS response being sent back to the Hologram cloud number:

When sending a message from Hologram, you can also choose to include a "From number":

This time when you send the SMS the shield will send its reply SMS to that number instead of to Hologram's cloud number. Try sending "OPEN SESAME!" and you should get a text "Treasure chest unlocked!" because your text matches the password exactly. If you check your Hologram dashboard (Event history page under "Event monitoring"), you should see the device's response text! 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 you with random sensor data!

Hologram Dashboard Alerts

Another thing you can do is set up "Alerts" in the Hologram dashboard so that when something happens with your device, an action is triggered. To do this, click on "Alerts" under "Event Monitoring" on the panel on the left and click "Create Alert". Select "SMS/TCP/UDP Message" and select "Outbound SMS". This means that whenever your device sends out an SMS, this alert will trigger, and you can set it up to email or activate a webhook with a 3rd party service like IFTTT or Twilio. The possibilities are endless! When an alert is triggered, you should see a neon green label on the event in your event history page:

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 random text to the shield using the dashboard's SMS feature without specifying a return number. Shortly afterward, you should see a new sensor reading pop up in the event history and also receive an email with the sensor data in it!

Pretty cool huh? With this knowledge you could program your device to text Hologram cloud, connect it to an IFTTT webhook, and then have IFTTT turn on your smart lights in your home or something crazy!

⚠️ **GitHub.com Fallback** ⚠️