Using SMS to control a device - recieve text/Native SIM

There is great documentation on sending a message from a device but not much on how to control device with SMS (with the native SIM).

I am trying to build a system in which a user text a Twilio or other SMS service phone number with a command such as, “Device1: Light1: on”. This would trigger a function on device 1 to turn light 1 on. As I’m seeing the system, I don’t think a webhook can directly work between Twilio and the device cloud since there has to be some processing of the message. Reading on the web, it seems to be possible to have twilio connect to a web app on Heroku/AWS which processes the SMS and then triggers the function on device cloud.

I am looking at the rules engine. In anyone’s opinion that has experience or knowledge, do you think the Rules engine could replace a third web app such as AWS/Heroku. A Twilio webhook upon receipt of a SMS from a real phone could send the SMS content to the rules engine and then a function in the rules engine could process and trigger the device function. The device reply/confirmation of action can go through the well documented webhook for sending a message to a phone from the device via Twilio.

High level, I am very amateur developer, but I’m trying to work on some control solutions for a project I can put together with my hunt, peck, copy, and research coding ability. Before I pour hours into exploring this (what might take someone else 30 min), I wanted to see what the community thought.

In absence of the rules engine, is controlling a device via a SMS message possible without a third party web app to parse the text and call the function.

Receive: Twilio -> Rules Engine-> Function ->Device Action
Send: Device -> Device Cloud -> Twilio

Thoughts?

Some time ago I wrote some test code to receive SMS and act upon the contents.
I’ll see if I can find that again.


Update:
This is what I’ve had success with 3G Electrons
https://go.particle.io/shared_apps/5c102976fcc071a552002237

2 Likes

Thanks for the quick reply. Quick question on LTE vs 3G

Before I dissect this code to see how it all works:
I was previously using an AT&T IOT starter kit and a sim card that uses LTE-M. I don’t think that sim card had an actual phone number you could dial or at least not that AT&T exposed. I have a E-Series LTE kit. Is it still true that I can’t directly contact the device with a regular phone to device SMS since it’s the LTE-M? If not, how do i find my device phone number so that I can utilize this code?

Also, any opinion on the Rules engine as a way to handle the incoming api from Twilio and relay to the device? In the case that I can’t text my device directly?

I can’t answer the LTE part since I’ve not got any LTE devices to test whether or not the used AT+ commands are supported on the LTE ublox modules.
I’ve also no idea whether or not your IoT starter SIM has a phone number - although I doubt it.

However, you may be able to plug that SIM into your phone and see if your phone gets a number.
Alternatively you could try sending an SMS from the device to your phone.
There are SMS send codes around too

(only tested on 3G again)

An update to this. I ended up using a Twilio, AWS Lambda, Particle cloud workflow. With Lambda, i was able to write python code using pyparticle package from github and easily interface with my devices. I set up a syntax that the Lambda code parses and then sends commands to the cloud through the API. For example, i could text my Twilio number, Function,Device1,Led,on, and it would turn the light on for Device 1. The system turns out to be really flexible in that I can text, Variable,Device1,status, and it will send me the value of all variables for that device. I used Twilio tutorials along with another AWS/Twilio tutorial written for Node.JS to guide the process. It’s a quick user interface that took a day to setup and works great.

2 Likes