Category Archives: cellphone hacking

Tutorial: Control AC outlets via SMS

Learn how to control AC outlets via SMS text message. This is chapter thirty-three of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 02/03/2013

Assumed understanding for this article is found in part one. If you have not already done so, please read and understand it.

In this chapter we will continue with the use of the SM5100 cellular shield to turn digital outputs on and off via SMS. However please read chapters twenty-six and twenty-seven first if you are unfamiliar with using the GSM shield with Arduino. As an extension of chapter twenty-seven, we will use our Arduino to turn on or off AC outlets via a common remote-control AC outlet pack. Please note this is more of a commentary of my own experience, and not an exact tutorial. In other words, by reading this I hope you will gain some ideas into doing the necessary modifications yourself and in your own way.

Firstly, we need some remote-control AC outlets. Most electrical stores or giant retail warehouses may have something like this:


Nothing too original, just a wireless remote control that can switch on or off receiver outlets on a choice of four radio frequencies. Before moving forward I would like to acknowledge that this article was inspired by the wonderful book Practical Arduino – Cool Projects for Open Source Hardware by Jon Oxer and Hugh Blemings. In chapter two an appliance remote-control system is devised using a similar system.

At first glance the theory behind this project is quite simple – using the hardware in example 27.2, instead of controlling LEDs, activate the buttons on the wireless remote control for the AC outlets – leaving us with AC outlets controlled via SMS. However there are a few things to keep in mind and as discovered during the process, various pitfalls as well.

Before voiding the warranty on your remote control, it would be wise to test the range of the remote control to ensure it will actually work in your situation. I found this was made a lot easier by connecting a radio to the remote outlet – then you can hear when the outlet is on or off. If this is successful, make a note of the amount of time required to press the on and off buttons – as we need to control the delay in our Arduino sketch.

The next step is to crack open the remote control:


… and see what we have to work with:


Straight away there are two very annoying things – the first being the required power supply – 12 volts; and the second being the type of button contacts on the PCB. As you can see above we only have some minute PCB tracks to solder our wires to. It would be infinitely preferable to have a remote control that uses actual buttons soldered into a PCB, as you can easily desolder and replace them with wires to our Arduino system. However unless you can casually tear open the remote control packaging in the store before purchase, it can be difficult to determine the type of buttons in the remote.

As you can see in the photo above, there is an off and on pad/button each for four channels of receiver. In my example we will only use two of them to save time and space. The next question to solve is how to interface the Arduino digital outputs with the remote control. In Practical Arduino, the authors have used relays, but I don’t have any of those in stock. However I do have a quantity of common 4N25 optocouplers, so will use those instead. An optocoupler can be thought of as an electronic switch that is isolated from what is it controlling – see my article on optocouplers for more information.

Four optocouplers will be required, two for each radio channel. To mount them and the associated circuitry, we will use a blank protoshield and build the Arduino-remote control interface onto the shield. The circuitry for the optocoupler for each switch is very simple, we just need four of the following:

As the LED inside the optocoupler has a forward voltage of 1.2 volts at 10mA, the 390 ohm resistor is required as our Arduino digital out is 5 volts. Dout is connected to the particular digital out pin from the Arduino board. Pins 4 and 5 on the optocoupler are connected to each side of the button contact on our remote control.

The next consideration is the power supply. The remote control theoretically needs 12 volts, however the included battery only measured just over nine. However for the optimum range, the full 12 should be supplied. To save worrying about the battery, our example will provide 12V to the remote control. Furthermore, we also need to supply 5 volts at a higher current rating that can be supplied by our Arduino. In the previous GSM chapters, I have emphasised that the GSM shield can possibly draw up to two amps in current. So once again, please ensure your power supply can deliver the required amount of current. From experience in my location, I know that the GSM shield draws around 400~600 milliamps of current – which makes things smaller and less complex.

The project will be supplied 12 volts via a small TO-92 style 78L12 regulator, and 5 volts via a standard TO-220 style 7805 regulator. You could always use a 7812, the 78L12 was used as the current demand is lower and the casing is smaller. The power for the whole project will come from a 15V DC 1.5A power supply. So our project’s power supply schematic will be as follows:

Now to mount the optocouplers and the power circuitry on the blank protoshield. Like most things in life it helps to make a plan before moving forward. I like to use graph paper, each square representing a hole on the protoshield, to plan the component layout. For example:

It isn’t much, but it can really help. Don’t use mine – create your own, doing so is good practice. After checking the plan over, it is a simple task to get the shield together. Here is my prototype example:


It isn’t neat, but it works. The header pins are used to make connecting the wires a little easier, and the pins on the right hand side are used to import the 15V and export 12V for the remote. While the soldering iron is hot, the wires need to be soldered to the remote control. Due to the unfortunate size of the PCB tracks, there wasn’t much space to work with:


But with time and patience, the wiring was attached:


Again, as this is a prototype the aesthetics of the modification are not that relevant. Be careful when handling the remote, as any force on the wiring can force the soldered wire up and break the PCB track. After soldering each pair of wires to the button pads, use the continuity function of a multimeter to check for shorts and adjust your work if necessary.

At this stage the AC remote control shield prototype is complete. It can be tested with a simple sketch to turn on and off the related digital outputs. For example, the following sketch will turn on and off each outlet in sequence:

Now to get connected with our GSM shield. It is a simple task to insert the remote shield over the GSM shield combination, and to connect the appropriate power supply and (for example) GSM aerial. The control sketch is a slight modification of example 27.2, and is shown below

The variable pressdelay stores the amount of time in milliseconds to ‘press’ a remote control button. To control our outlets, we send a text message using the following syntax:

Where a/b are remote channels one and two, and x is replaced with 0 for off and 1 for on.

So there you have it – controlling almost any AC powered device via text message from a cellular phone. Imagine trying to do that ten, or even five years ago. As always, now it is up to you and your imagination to find something to control or get up to other shenanigans.


Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Tutorial: Arduino and GSM Cellular – Part Two

Continue to learn about connecting your Arduino to the cellular network with the SM5100 GSM module shield. This is chapter twenty-seven of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 02/03/2013

Assumed understanding for this article is found in part one. If you have not already done so, please read and understand it. In this instalment we continue with bare projects which you can use as a framework for your own creations.

Reach out and control something

First we will discuss how to make something happen by a simple telephone call. And the best thing is that we don’t need the the GSM module to answer the telephone call (thereby saving money) – just let the module ring a few times. How is this possible? Very easily. Recall example 26.1 – we monitored the activity of the GSM module by using our terminal software. In this case what we need to do is have our Arduino examine the text coming in from the serial output of the GSM module, and look for a particular string of characters.

When we telephone the GSM module from another number, the module returns the text as shown in the image below:


We want to look for the text “RING”, as (obviously) this means that the GSM shield has recognised the ring signal from the exchange. Therefore need our Arduino to count the number of rings for the particular telephone call being made to the module. (Memories – Many years ago we would use public telephones to send messages to each other. For example, after arriving at a foreign destination we would call home and let the phone ring five times then hang up – which meant we had arrived safely). Finally, once the GSM shield has received a set number of rings, we want the Arduino to do something.

From a software perspective, we need to examine each character as it is returned from the GSM shield. Once an “R” is received, we examine the next character. If it is an “I”, we examine the next character. If it is an “N”, we examine the next character. If it is a “G”, we know an inbound call is being attempted, and one ring has occurred. We can set the number of rings to wait until out desired function is called. In the following example, when the shield is called, it will call the function doSomething() after three rings.

The function doSomething() controls two LEDs, one red, one green. Every time the GSM module is called for 3 rings, the Arduino alternately turns on or off the LEDs. Using this sketch as an example, you now have the ability to turn basically anything on or off, or call your own particular function. Another example would be to return some type of data, for example you could dial in and have the Arduino send you a text message containing temperature data.

And now for a quick video demonstration. The first call is made, and the LEDs go from red (off) to green (on). A second call is made, and the LEDs go from green (on) to red (off). Although this may seem like an over-simplified example, with your existing Ardiuno knowledge you now have the ability to run any function by calling your GSM shield.

Control Digital I/O via SMS

Now although turning one thing on or off is convenient, how can we send more control information to our GSM module? For example, control four or more digital outputs at once? These sorts of commands can be achieved by the reception and analysis of text messages.

Doing so is similar to the method we used in example 27.1. Once again, we will analyse the characters being sent from the GSM module via its serial out. However, there are two AT commands we need to send to the GSM module before we can receive SMSs, and one afterwards. The first one you already know:

Which sets the SMS mode to text. The second command is:

This command tells the GSM module to immediately send any new SMS data to the serial out. An example of this is shown in the terminal capture below:


Two text messages have been received since the module was turned on. You can see how the data is laid out. The blacked out number is the sender of the SMS. The number +61418706700 is the number for my carrier’s SMSC (short message service centre). Then we have the date and time. The next line is the contents of the text message – what we need to examine in our sketch.

The second text message in the example above is how we will structure our control SMS. Our sketch will wait for a # to come from the serial line, then consider the values after a, b, c and d – 0 for off, 1 for on. Finally, we need to send one more command to the GSM module after we have interpreted our SMS:

This deletes all the text messages from the SIM card. As there is a finite amount of storage space on the SIM, it is prudent to delete the incoming message after we have followed the instructions within. But now for our example. We will control four digital outputs, D9~12. For the sake of the exercise we are controlling an LED on each digital output, however you could do anything you like. Although the sketch may seem long and complex, it is not – just follow it through and you will see what is happening:

And now for a video demonstration:

So there you have it – controlling your Arduino digital outputs via a normal telephone or SMS. Now it is up to you and your imagination to find something to control, sensor data to return, or get up to other shenanigans.

If you enjoyed this article, you may find this of interest – controlling AC power outlets via SMS.


Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Tutorial – Arduino Uno and SM5100B GSM Cellular

Shield is now obsolete. Contact your hardware supplier for support.

Kit Review – adafruit industries SIM reader (part two)

[Updated 18/03/2013]

Hello readers

Now for the second instalment of my kit review of the adafruit industries SIM card reader. In part one the kit was successfully assembled and the software installed. After some research and some very useful advice from the amazing people at adafruit, we can now move forward to the conclusion of this review.

First of all, a big thanks to adafruit support who pointed me in the direction of something very simple yet crucial: the kit FAQ. Once again I have exhibited the stereotypical behaviour of a male and not read all the instructions first! (Slow clapping from the females in the audience…)  The most crucial point being:

The reader and software looks in the default locations that cell phones use to store SMS and phonebook data – just like the professional forensics software. Some phones do not store any data on SIM cards, instead using their internal memory, and some do a good job of overwriting the data when it is erased. Thus it is not guaranteed that a particular message or phonebook entry will be accessable – it depends a lot on the phone used!


To cut a long story short another SIM card was acquired that had not been near my handsets, and this worked perfectly. Again, that wonderful feeling of something working filled me with warmth and happiness.

Now for the moment of truth! Insert the SIM card, plug in the cable, connect the PP3 battery if you’re using RS232, and execute:


which after starting up, and you clicking “connect reader” should result with this:


That’s more like it. Time to examine what the SIM holds… first – the phone book:


You can double-click on a listing (above left) and the edit entry box appears (above right) allowing you to … edit an entry!

Next we look at the SMS messages function. Unfortunately the SIM card I tested was deactivated and therefore couldn’t be used to receive SMSs. However an excellent demonstration is found in the video at Citizen Engineer (volume one). Finally, we can examine the details of the SIM card itself:


What are all those acronyms?

  • MSISDN – the phone number attached to that SIM card;
  • Serial number – the SIM serial number, usually printed on the SIM card;
  • IMSI number – a unique number sent by the phone to the network to identify the user;
  • SIM phase – SIM cards were originally ‘Phase 1’, and the phase number increased as the GSM standard was developed over time.

So there you have it. In conclusion, this is an easy to assemble kit which is fun and educational. This is the type of kit that would be good for those who are being introduced to the fascinating world of electronics (etc) as it is quick to build, and does something with the “real world” (i.e. mobile phones) that young people love so much. Or anyone else for that matter. High resolution photos are available on flickr.

In the meanwhile have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

[Note – this kit was purchased by myself personally and reviewed without notifying the manufacturer or retailer]

Kit Review – adafruit industries SIM reader (part one)

[Updated 18/03/2013]

In this review will cover the SIM reader from adafruit industries.

The result of this kit is a device that can read the data from a GSM SIM card, such as last-dialled numbers, SMS messages, the phone book, and so on. Although this may not sound like much, the concept of having this sort of technology at home really is amazing; that is – you can learn about the GSM SIM technology and hack into it.

The kit was shipped to me via USPS First Class International postage – taking five days to arrive in Australia from New York. Frankly that’s good enough and therefore no need for a courier.


adafruit also set the standard with customs paperwork, with a full and honest declaration inside and out. By doing this I feel it speeds the parcel through Customs… a lot quicker than those packages from Chinese eBay sellers who always put “Gift, US$2” on everything. Opening up reveals the kit itself, in an anti-static resealable bag. Groovy, packaging I can reuse and not throw away…


Another smart move is to not include paper instructions, instead having a very detailed web site and a busy support forum. You can always print the instructions out if you don’t have a PC in your work area. The next thing I love to do is have a look at the components, and get a feel for the kit itself.


What stands out with adafruit kits compared to most others (I’m looking at you, Jaycar) is the quality of components. A decent PP3 battery snap that won’t break when you are tired and cranky, branded semiconductors, and a beautiful solder-masked, silk screened PCB. However, no IC socket. Grr. However, one can tell this has been designed by an enthusiast and not some bean-counter.




But that’s enough looking and talking – let’s build it…

My advice at this point is to check you have all the components on hand, and then line them up in order to make it easier while you are soldering. There was also a couple of parts that missed their photo shoot call…


If possible, the best way to make adafruit kits is to have your computer in front of you, as you can follow the detailed instructions as you go along. With the instructions up on the screen, the helping hands ready, the fume extractor on, and the tools at my side – it’s time to get cracking.


First the resistors, protection diode, LED and PP3 snap  …


Time for a quick test (excellent for confidence-building and troubleshooting) …


Excellent, the LED is working. The rest of the components are easily soldered… as there was no IC socket I soldered opposing pins in order to spread the heat load. The second-last part to fit was the SIM card reader. This had me worried, as if it was damaged, it would take a few days to replace. However, the instructions made it look simple – and it was. Taking a decent photo of it was more difficult…


And finally, the last part – DB9 fitting for the serial cable to the PC. The kit is supplied with a female connector… but silly me ordered the wrong serial cable, so I am using a male connector. Again, this was easy to fit – the PCB slid between the two rows of pins on the plug, and had large solder pads to make a good strong connection.




OK – we’re done. Now for a SIM card… Ms. Tronixstuff wouldn’t volunteer hers, so mine will be the first victim…


Now time to install the psySIMReader software. It is freely available here with instructions.  Originally my first attempt was with Ubuntu 9.1 and 10.04, but there were too many python errors, and I wasn’t in the mood for learning another language. Eventually I learned how to force the python software to look at COM1 – a good start. But no go – the zero error. Off to a windows xp machine. Seemed ok, but when I attempt to open the COM1 port an error says something about returning zero. This could possibly mean my SIM card is non-standard. *sigh* Went to the supermarket and bought a Vodafone SIM for $2, maybe they are different to my Virgin mobile SIM in some way. On the way back I stopped in again and tried the whole process on the windows xp machine, same error. Vodafone SIM card didn’t work either. Zero for both.

So home again. After reading the support forums, I resoldered all the joints, checked for continuity around the board, reinstalled python and the software, zero error again. Maybe SIM cards have changed a little since the kit was introduced? Then I looked at my serial cable – 3 metres. Perhaps it was too long? So I chopped off one end leaving about 150mm and soldered up another DB9 plug.


Tested the cable, tried again – still the zero error.

Another trawl through the forums and google revealed people having the same zero error, but it being fixed with a resolder job and/or plugging the PCB straight into the serial port on the computer. I cannot do this having originally soldered on a DB9 male to the PCB. Argh. Either it is my soldering or my dodgy serial cable hackup. Soon I will order up an FTDI cable, have someone else check my soldering with better eyes, and then try connecting again.

So at this stage, the verdict is still out. However, I must commend adafruit industries as a great organisation with respect to ordering, speed of delivery, quality and amount of detail on the website, and the support and enthusiasm offered throughout. Their other products have all received rave reviews and are supported much more than adequately.

At this point I will finish part one of the review, and return when the FTDI cable arrives.

[edit] – Click here to visit part two of this review.  High resolution photos are available on flickr.

In the meanwhile have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.