Sorry, you need to enable JavaScript to visit this website.

You are here

Get environmental sensor data via SMS

BY Michelle Howie 15 July 2021

Learn how to set up on-demand SMS updates for your IoT devices. 

Potential use cases

If you have an environmental sensor set up in your home, office or farm, you don’t want to have to physically go and take a sensor reading every time you want to check the temperature. There are already handy dashboards you can connect your device to (such as the Arduino Cloud or Telstra IoT Platform), but if you're in a rush, you can now ask the device to update you via SMS on demand. We could potentially set this solution up to automate updates every hour, minute, week, or when a threshold is exceeded (like in the next example) but this project focuses on on-demand data. 

Using Arduino to send and receive SMS commands

This blog follows on from our earlier blog Use SMS to control your IoT device, in which we set up an Arduino board connected to Telstra's NB-IoT network, that flashes its LED light on or off based on an SMS command. I tweaked this slightly, to be able to send SMS commands as well as receive them, so we can get information off the device with remote sensors. This is the overall flow that handles inbound messages requesting specific sensor info, and uses the most up-to-date sensor readings from our Arduino ENV Shield via an IoT broker to send the response:

Our Arduino device is subscribed to an IoT broker that updates the latest sensor reading every minute. When an SMS is sent to our virtual mobile number (from Telstra’s Messaging API Free Trial), it's forwarded to the http endpoint here in Node-Red, where we then match the text payload to some expected keywords (i.e temp, humidity, UV) and create a reply message payload based on what data has been asked for.

Ask your device for the “temp”, for example, and it will send you back the last known temperature reading in Celsius.

We are able to map this process pretty easily using the low-code flow in Node-Red:

This code is all available in my GitHub repo for you to use, just replace your own credientials.

A similar flow could be used to get on-demand readings from any other critical system you want to check in on, like the water level of a drinking trough on your remote farm, or the location of your package travelling across Australia. Pretty handy to be able to poll for that data, rather than wait for an automatical alert (we'll get to those in our next blog).

Find out more

To see more detail or try this out yourself, check out my GitHub for the source code and detailed instructions.  

GitHub Repo + ReadMe: https://github.com/MichelleHowie/IoTSensorData_OnDemand

This tutorial was originally presented in a workshop at Call For Code with DeveloperSteve Coochin, June 2020: https://video.ibm.com/channel/23832688/video/cfc2020-telstradev-iotworkshop

To see how SMS alerts can be triggered by sensor input from your IoT device in emergencies, head to part 3 of this series.

Related Blogs

anonymous's picture

By Daniel Simpson

17/12/21

  • azure
  • microsoft

A code-first approach to digital twins

Find out how to use code-first digital twins with the Telstra Digital Twins library.   ...
anonymous's picture

By Michelle Howie

25/10/21

  • iot
  • arduino

AgTech and sustainable agribusiness

Our GovHack 2021 challege explored how AgTech can improve sustainable agribusiness.  ...
anonymous's picture

By Quinn Tran

25/9/21

  • iot
  • microsoft

Creative projects with Microsoft Azure

Get your creative juices flowing with the latest in computer vision innovation.   ...
anonymous's picture

By Michelle Howie

15/7/21

  • arduino
  • iot

Trigger an SMS alert when a device is dropped

Learn how Arduino can be used to trigger an SMS alert when a device has been dropped.  Autom...
anonymous's picture

By Michelle Howie

15/7/21

  • arduino
  • iot

Use SMS to control your IoT device

In this blog, we look at how to use SMS commands from the Telstra Messaging API to control your IoT...
anonymous's picture

By Michelle Howie

2/7/21

  • iot
  • arduino

Changes to our IoT Developer Kit offer

The IoT Marketplace and Developer Kit trial were retired in July 2021.    Where we...
anonymous's picture

By Tim McMahon

2/6/21

  • Telstra Messaging API
  • bushfire

Air quality SMS alerts during bushfire season

I woke up one morning in January 2020 to discover that the air quality in Melbourne had dropped...
anonymous's picture

By Alan Quayle

18/5/21

  • iot
  • REST API

Unlocking the IoT: Telstra Track and Monitor API

As Australia’s longest serving telco, Telstra is expanding their developer program to provide...
anonymous's picture

By Sri Amirthalingam

31/3/21

  • iot
  • regional

Your regional mobile coverage questions answered

When developing an IoT solution for your business, coverage and access to a reliable network is crit...
anonymous's picture

By Michelle Howie

23/12/20

  • TDev
  • documentation

TelstraDev End of Year Wrap: 2020

We made it! Welcome to the end of 2020, may it soon be just a distant memory. Though it wasn’t...
iot home garden project with arduino and azure
anonymous's picture

By keith coutlemanis

10/11/20

  • arduino
  • azure

Azure IoT garden project with Arduino

In this blog, I'll showcase some of the interesting things you can do with the Internet of Thing...
anonymous's picture

By Trent Steenholdt

10/11/20

  • iot
  • azure

A home IoT project using Azure

In this blog series, I'll explan how I used the Internet of Things (IoT) to enable my gate, gara...