Introduction: Reliable, Secure, Customizable SMS Remote Control (Arduino/pfodApp) - No Coding Required

Update 6th July 2018 : A 3G/2G version of this project, using SIM5320, is available here

Update: 19th May 2015 : Use the pfodParser library Version 2.5 or higher. It fixes a reported problem of not allowing enough time for the shield to connect to the network after powering up.


How is pfodSMS remote control different from other implementations:-

  • It is Reliable – commands are always responded to and lost messages are re-requested
  • It is Secure – uses 128 bit password protection
  • It does not require any third party web service accounts – only needs active SIM card (without a pin)
  • It is Customizable – you can use pfodDesigner to create you own custom menu
  • It is Easy – the pfodDesigner generates all the code. You don't need to do any coding.
  • It is Flexible – all the pfod screens are available via SMS, like sub-menus, multi and single selection list, text input, data logging and plotting.

See pfodSMS message design for how the SMS connection is made reliable.
See Challenge and Response Security for Internet connected pfodDevices for the details of the 128bit security.
See pfodDesigner, Android / Arduino menus made Simple for details on the designing your own custom menu.
See the pfodSpecification.pdf for the details of all the pfod messages and screens that you can add yourself.

Example Project – SMS Hot Water control

As an example project this instructable describes how to turn your hot water heater on and off via SMS and check if it is on or off. You will need an electrician to install it.

Step 1: Quick Start - SMS Remote Control

Here is a quick start guide to building your own SMS hot water control.

    1. Purchase the parts on this list.
    2. Install the Arduino IDE version 1.5.8 and download and install the pfodParser library.
    3. Download the free pfodDesigner
    4. Design your custom menu to turn a digital input on and off from a menu slider on your Android mobile
    5. Generate the code, selecting SeeedStudio SIM900 GPRS shield as the connection. (There is also an option for the IteadStudio SIM900 shield)
    6. Transfer the generated code from your mobile to the IDE (see the pfodAppForAndroidGettingStarted.pdf for details), add your secret password, compile and download to the Arduino Mega 2560
    7. Install your SIM card in the GPRS shield and plug the shield into the Mega 2560. Make sure the Serial links are set to Hardware Serial as shown above.
    8. Connect the digital output to the solid state, or normal, relay between D3 and GND (or which ever pin you chose in the pfodDesigner). See How to Add Relays to Arduino for more details on relays.
    9. Apply USB power to the Mega. The library code powers up the GPRS shield for you.
    10. Install pfodApp on your Android mobile and set up an SMS connection to the shield's sim phone no. (see the pfodAppForAndroidGettingStarted.pdf for details). Set the password for the connection if you added one.
    11. Connect and see your custom menu displayed via SMS. Click the button to turn the relay on or off.
    12. Get your electrician to install the relay in your Hot Water circuit and wire up the USB power supply to power the Mega and shield

    Step 2: More Details


    The pfodDesigner will generate all the code you need to turn the solid state or some other relay on and off, but the SMS connection in the pfodParser library supports all the pfod screens so once you get started you can add sub-menus, numeric sliders, multi-text sliders, text input screens, data logging and plotting all via SMS. Check out the pfodSpecification.pdf for all the screens and messages supported.

    The generated code is here. It has no prompt and just a single switch to keep the message short. Long menus are send via multiple SMS messages which take longer to arrive. If you have a long menu, the sms connection code in the pfodParser library handles all of this for you.

    To add a password to your SMS connection modify the line

    parser.connect(&pfodSMS); // connect parser to SMS stream
    to something like
    parser.connect(&pfodSMS, F("173057F7A706AF9BBE65D51122A14CEE"));

    but use your own password of up to 32 hex digits, 0..9 A..F. Passwords shorter then 32 hex digits are padded with 0's. See A Simple Wifi/Internet pfodDevice with 128bit security (Arduino) for how to generate a random password and output it to a QR code for easy input to your Android. Also see pfodAppForAndroidGettingStarted.pdf

    The pfodDesigner will also generate code for bluetooth and wifi connections via Serial and Ethernet via SPI all with optional 128bit security


    The first thing to realize is that SMS is sloooow and may not get there at all or arrive out of order. So when you connect with pfodApp there will be some delay before there is an SMS response. If the message got lost or delayed, pfodApp will automatically resend it after 3mins. After 5 such retries the pfodApp will tell you the connection is lost. You can adjust the 3mins time in the pfodApp's connection edit screen.

    If you add a password then there are an six SMS messages (three each way) before the main menu is received by the pfodApp. These extra messages only happen on the initial connection after which there are no extra messages when using a password. So start without a password to see that every thing is working and then add the password later.

    SMS/GPRS shield

    Possible problems are SIM cards protected by pin numbers or not authorized to connect to the network. The pfod library automatically powers up the GPRS shield and looks for the 'call ready' response. If that response does not arrive the library powers down and tries again, so if you see the power light on the GPRS shield go on for 20sec and then go off, there is a problem connecting to the network. Take out the SIM and try it in a normal phone. Check you are not prompted for a pin number.

    If that is not the problem then you will have to turn on the start-up debugging, as described below, to see what is happening.

    Powering the Mega / GPRS shield

    The shield draws up to 2A pulsed and up to 0.5A continuously. Assuming a 12V battery supply, the 0.5A exceeds the capacity of the Mega on board power supply. So this shield should NOT be powered from the 7V to 12V input on the Mega. The alternative is to power the Mega and shield via the USB connection. I used a 1A USB supply. For testing I used a Belkin powered hub (F4U020) to prevent drawing excessive current from my computer's USB port.

    For a 12V battery supply, I suggest using a quality Automotive USB 5V charger, 1A, or higher. A quality Automotive USB 5V supply should be designed to handle over voltage spikes the occur in car electrical systems and so should be suitable for most 12V charging systems.

    Solid State Relay

    Since this example project is controlling a Hot Water heater, (a resistive load), a Solid State relay is ideal. If you want to switch motors on or off, start generators etc, talk to your electrician about a suitable relay for the job. If you need a high power relay you can use a small relay drive by the arduino board to switch the power relay on and off.

    There are many versions solid state relay available. Make sure you purchase on that can handle the current and voltage of your heater and can be controlled by 5V dc and a few milliamps available from the Arduino output pin. The one used here, FOTEK SSR-40 DA, switches up to 380VAC at 40Amps and is controlled by any thing more then 3V dc and takes less than 7mA.

    You must use a heat sink and you must apply a THIN smear of heat sink compound or thermal grease on the back of the solid state relay before bolting it to the heat sink. The idea is to completely cover the surface with the thinnest layer of head sink compound to fill in the microscopic valleys in the metal's surface. When turned on the solid state switch drops 1.6V which generates 16Watts of heat at 10Amps. The heat sink is need to get rid of this heat so it needs to be mounted in free air not inside a plastic box.

    Delays are Evil

    The GPRS shield delivers SMS messages via the Serial connection at any time and your main loop() must call
    cmd = parser.parse();
    often to process the Serial data before the 64byte buffer in the Arduino library code fills up and data is lost.

    So you must keep your main loop() running quickly. You should never use delay() and should check that none of the libraries you are using have delays in them. Using the default 19200 baud rate of the SIM900 via Hardware Serial, I have not found it necessary to increase the buffer size in the Arduino library code. I don't use Software Serial, only Serial and Serial1, Hardware Serial connections, and almost all the messages the pfodApp sends are very small, 10 or 12 bytes. However you can increase the Arduino buffer size, if you wish, by modifying the define in HardwareSerial.h from
    #define SERIAL_BUFFER_SIZE 64
    #define SERIAL_BUFFER_SIZE 128

    However what I did find was that if I enabled debugging output, as described below, I had to have a very fast baud rate for the terminal connection otherwise the delay introduced by send debug messages to the terminal caused parts of the SMS messages to be missed.


    I added a screw terminal shield so I had something to connect the Solid State relay wires to. I have not had my electrician install the controller yet. It needs to be put in an insulated box, but with heat sink sticking out through a slot and wired into the hot water power lead.

    Step 3: Suggestions for Further Enhancements – Alerts, Data Logging and Plotting

    The example project above just displays is the how water is on or off and allows you to switch it. But the SMS connection handles all of the pfod messages (see pfodSpecification.pdf )

    If you add temperature sensor to your arduino you can also send monitor the temperature and send back readings at regular intervals. To send back a data reading is the same for bluetooth, wifi or SMS, just add the code like the sample below. See Data Logging and Plotting for more details and examples of data logging and plotting.


    When the pfodSMS library sees the new line from println(), it will send the raw data as an SMS. On your mobile, just leave pfodApp running in the background and your your mobile will notify you when an SMS is received. Open pfodApp again to bring it to the front and then open the Raw Data screen from the mobile's menu to see the data. Note: The pfodSMS messages are UTF-8 characters together with connection and message numbers, encode using a Base64 encoding so they don't look like normal text. See pfodSMS message design for all the details.

    You can use the same process to send an alert when something changes remotely. i.e.
    parser.println(F(“Outside Temperature below 0℃ ”));
    Note: the ℃ UTF-8 character in the string. pfodSMS passes all UTF-8 characters through to the pfodApp.

    Step 4: Debugging While Using the SMS Connection in the PfodParser Library

    The pfodDesigner generates code that works, but you may want to debug your own extra code or look at what is happening while the GPRS shield is starting up or receiving SMS messages. There are a couple of approaches you can take.

    Debugging your own code

    If you are debugging your own code your could your can just comment out the pfodSMS line and connect the parser to Serial and then remove the GPRS shield and run the Mega from the Arduino terminal. i.e. change the setup() to

    //pfodSMS.init(&Serial,9); // don't start up the GPRS shield
    parser.connect(&Serial); // connect parser to Serial instead of SMS stream

    Then from the Arduino terminal you can type in {.} to get the Mega to return the main menu and then send back command you want to execute, e.g. {A`1} to turn the relay on and {A`0} to turn it off. (The pfodApp usually sends these messages for you when you click the slider.) Then add extra debugging parser.println() to monitor what extra code you added is doing.

    Monitoring the GPRS shield

    If you want to see what the GPRS shield is doing. How it is starting up, receiving SMS msgs etc. Then you need to change the shield wiring connect it to the Mega Serial1 (serial one) and free up the Serial (USB) connection for debug output to the Arduino IDE Monitor.

    To connect the GPRS shield to the Mega 2560 Serial1, remove links shown above and and add the wires to the Mega's TX1 and RX1 pins.

    Then change the setup() code to

    void setup() {<br> Serial1.begin(19200); // change Serial to Serial 1
     Serial.begin(57600); // NOTE the fast baud rate for the USB Serial port <br>                      // to the Arduino IDE monitor.
      for (int i=3; i>0; i--) {
        // wait a few secs to see if we are being programmed
      pinMode(cmd_A_pin, OUTPUT); <br>
      pfodSMS.setDebugStream(&Serial); // need to do this before pfod_SMS.init <br>                                    // or any other pfod_SMS method call
       // initialize the SMS and connect the parser
       // change the next line to Serial1
      pfodSMS.init(&Serial1,9); // connect Seeed GPRS shield V2 to Serial1 instead of Serial
      parser.setDebugStream(&Serial); // need to do this before parser.connect <br>                                  // or any other parser method call
      parser.connect(&pfodSMS); // connect parser to SMS stream

    Now you can uncomment some of the Debug settings in the pfodParser library at the to of the pfodSMS_SIM900.cpp file.

    For example un-commenting
    #define DEBUG_SETUP
    will print out (to the debug stream) what is happening while powering up the GPRS shield and getting it ready to receive SMS msgs.

    #define DEBUG
    will give lots of information on the SMS messages being received.

    That's it !

    Protected Contest

    Participated in the
    Protected Contest