Netuino: Sending SMSs based on events

Here’s a demo of sending SMSs from a Netduino Plus. The demo is intentionally bare bones to show the essentials. The background music was a bonus. See more at the end.

As seen in the video there’s no mobile phone involved in sending the SMSs, only on the receiving end. That’s because I use Infobip for the transmissions, the same service used in a couple of other Web applications of mine.

Benefits with Infobip, among others: the API is very simple, doesn’t require SSL/TLS (not supported by Netduino), has very fast round-trip, can send SMSs anywhere in the world for a low cost, and the support people are very nice. What more could you ask for? It’s of course not free, so you need to register and top up your account before using it.

By using a service like this, you also get a more compact product and you don’t need any SIM card (which is a clear benefit both cost- and logistics-wise). Other services provide receiving SMSs, also without a SIM card. E.g. Mobilt liv (Mobile Life) uses such a service.

Uses

Think burglar alarms, water leaks, machinery in need of service, daily status reports, your cat wanting attention etc. Still, in many cases you’d want to send such information first to a monitoring service / alarm center, that would then dispatch SMSs, phone calls, e-mails etc if needed. The benefit with a direct (or at least close to direct) SMS approach is the minimum of equipment and services involved.

Classes

During the work I created the following classes. They can directly be re-used in future projects. Especially HttpRequest is important, as the HTTP support in .NET Micro Framework is crippled compared to full .NET.

HttpRequest

  • bool Perform(string Url, string Args)
  • string EncodeUrl(Hashtable Args)
  • string EncodeUrl(string Value)

Util

Used by this project:

  • string Hex2(int Value)
  • string StrToHex(string Text)

ButtonBoard

  • bool Get()
  • bool Triggered()

SmsInfobip

  • bool Send(string Originator, string Destination, string Text)
  • string CompactNumber(string Number)

Main task

Use of the above classes resulted in this compact main task. The random value is only to secure that Infobip will not filter out messages. In practical use messages would most likely be different between transmissions.

using System;
using System.Threading;

namespace SmsSendTest
{
    public class Program
    {
        public static void Main()
        {
            SmsInfobip Sms = new SmsInfobip();
            Random Entropy = new Random();

            while (true)
            {
                LedStatus.Set(ButtonBoard.Get());

                if (ButtonBoard.Triggered())
                    Sms.Send("<originator>", "<destination>", "This is a message from NetduinoPlusAB1. Let's go entropic: " + Entropy.Next());

                Thread.Sleep(100);
            }
        }
    }
}

Unintended entertainment

The music in the background is courtesy of Symphony X from their latest album Iconoclast.