We’re giving away 1,500 DJI Tello drones. Enter to win ›
By Mohamed Mahmoud Nour El-Din Hassan, Dina Sayed Ahmed, Nouran Attia | Published March 28, 2016 - Updated February 7, 2018
The Internet of Things (IoT) represents a new ecosystem of devices and applications, which are integrated in innovative ways to deliver smart services. A simple example would be an Internet-enabled coffee machine, or a refrigerator able to take inventory of its own contents. While these examples are popular consumer examples, IoT programming is applicable to a wide variety of industry domains, including business, agriculture, research, healthcare, and more.
In the following sections you will set up your IBM Cloud workspace, develop the demo application by using Node-RED, and successfully send an SMS from the application to your mobile phone by using Twilio.
If you’re ready to start programming for IoT, this tutorial will get you started by building an IoT app that automatically notifies a remote user if their computer or IT network is down. We’ll use these technologies:
Our sample app, pingGo, continuously pings network ports and computer ports to track the status of the computers. If a computer goes down, pingGo will notify a registered user by SMS. This type of IoT application is useful to any technical user who is responsible for monitoring a remote mission-critical server or a distributed computer network because the app alerts them to take the appropriate action in an emergency.
Try IBM Cloud for free
Build your next app quickly and easily with IBM Cloud Lite. Your free account never expires, and you get 256 MB of Cloud Foundry runtime memory, plus 2 GB with Kubernetes Clusters.
Get all the details and find out how to get started. And if you’re new to IBM Cloud, check out the IBM Cloud Essentials course on developerWorks.
Here’s what you’ll need to build the sample app. Go ahead and sign up for these accounts before you get started with the tutorial steps.
Get the code
If you don’t want to create the app yourself, you can deploy the simple, pre-built app to IBM Cloud. From there, you can edit and redeploy the code as many times as you like.
Deploy the app
You can read more about the IBM Cloud architecture and its key concepts, including the most current list of regions, in the IBM Cloud documentation.
Your application was started
Watch this Hands-on IoT video that introduces Node-RED, and then watch this other Hands-on IoT video that shows you how to create your first flow.
Or, you can review the Node-RED getting started documentation.
You’ll get started with Node-RED by developing a simple, two-node application.
Error: Lost connection to server
If your Node-RED is older than version 0.15, you must edit the JSON file named app/package.json and add in the new node to the required packages list in the dependencies section of the file.
Next, you’ll need to add a Ping node to the palette.
For a successful ping, the Ping node returns the trip time in the msg.payload property. If there is no server response within 5 seconds, the node returns false. You can set up a Function node to check the msg.payload value.
msg.tripTime = msg.payload;
msg.payload = msg.payload !== false ?
"Your server is running":
"Your server is down";
You’re very close to being done with your application. It’s time to add the Twilio node to your application flow.
If you want to send an SMS to a mobile number other than the one you verified when you created your account, you need to verify this number with Twilio first. This restriction applies only to trial accounts. You can verify a new number on your Twilio account page.
In the Name field, type SMS alert to admin and click Done. If you get the following error message:
SMS alert to admin
"Permission to send an SMS has not been enabled for the region indicated by the 'To'
Then, you probably need to update your GEO settings for your Twilio account and activate the permission for the region where the number you want to send messages to resides. You can update your GEO settings at this URL: https://www.twilio.com/console/sms/settings/geo-permissions.
Click Deploy in your flow editor.
Here is the final application flow for your reference:
In your flow editor, click Deploy.
Congratulations! You completed the sample application. You can now deploy this application to monitor your computer or network.
In this tutorial, you learned just how easy it is to create an IoT app with Node-RED, IBM Cloud, and Twilio. You used both standard and custom nodes and configured those connected nodes in your application flow. You deployed your application by using your own mobile phone as the SMS receiver of the alerts.
What IoT app will you create now?
Get the Code »
Back to top