In this article we review the “Magpie” Arduino Uno-compatible board from Little Bird Electronics.
Introduction
Finally I’m back at the office and have a pile of things to write about. Starting with the subject of this review – the “Magpie” board from Little Bird Electronics in Australia. It seems that a new Arduino-compatible board enters the market every week, thanks to the open-source nature of the platform and the availability of rapid manufacturing. However the Magpie isn’t just any old Arduino Uno knock-off, it has something which helps it stand out from the crowd – status LEDs on every digital and analogue I/O pin. You can see them between the stacking header sockets and the silk-screen labels. For example:
and for the curious, the bottom of the Magpie:
At first glance you might think “why’d they bother doing that? I could just wire up some LEDs myself”. True. However having them on the board speeds up the debugging process as you can see when an output is HIGH or LOW – and in the case of an input pin, whether a current is present or not. For the curious the LEDs are each controlled by a 2N7002 MOSFET with the gate connected to the I/O pin, for example:
An LED will illuminate as long as the gate voltage is higher than the threshold voltage – no matter the status of the particular I/O pin. And if an I/O pin is left floating it may trigger the LED if the threshold voltage is exceeded at the gate. Therefore when using the Magpie it would be a good idea to set all the pins to LOW that aren’t required for your particular sketch. Even if you remove and reapply power the floating will still be prevalent, and indicated visually – for example:
Nevertheless you can sort that out in void setup(), and then the benefits of the LEDs become apparent. Consider the following quick demonstration sketch:
// LBE Magpie board LED demo - John Boxall 18 March 2013
// usual blink delay period
int d=100;
void setup()
{
// digital pins to outputs
for (int a=0; a<14; a++)
{
pinMode(a, OUTPUT);
}
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
}
void allOn()
// all LEDs on
{
for (int a=0; a<14; a++)
{
digitalWrite(a, HIGH);
}
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A4, HIGH);
digitalWrite(A5, HIGH);
}
void allOff()
// all LEDs on
{
for (int a=0; a<14; a++)
{
digitalWrite(a, LOW);
}
digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
digitalWrite(A2, LOW);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, LOW);
}
void clockWise(int r, int s)
// blinks on and off each LED clockwise
// r - # rotations, s - blink delay
{
allOff();
for (int a=0; a<r; a++)
{
for (int b=13; b>=0; --b)
{
digitalWrite(b, HIGH);
delay(s);
digitalWrite(b, LOW);
}
digitalWrite(A5, HIGH);
delay(s);
digitalWrite(A5, LOW);
digitalWrite(A4, HIGH);
delay(s);
digitalWrite(A4, LOW);
digitalWrite(A3, HIGH);
delay(s);
digitalWrite(A3, LOW);
digitalWrite(A2, HIGH);
delay(s);
digitalWrite(A2, LOW);
digitalWrite(A1, HIGH);
delay(s);
digitalWrite(A1, LOW);
digitalWrite(A0, HIGH);
delay(s);
digitalWrite(A0, LOW);
delay(s);
}
}
void anticlockWise(int r, int s)
// blinks on and off each LED anticlockwise
// r - # rotations, s - blink delay
{
allOff();
for (int a=0; a<r; a++)
{
for (int b=0; b<14; b++)
{
digitalWrite(b, HIGH);
delay(s);
digitalWrite(b, LOW);
}
digitalWrite(A0, HIGH);
delay(s);
digitalWrite(A0, LOW);
digitalWrite(A1, HIGH);
delay(s);
digitalWrite(A1, LOW);
digitalWrite(A2, HIGH);
delay(s);
digitalWrite(A2, LOW);
digitalWrite(A3, HIGH);
delay(s);
digitalWrite(A3, LOW);
digitalWrite(A4, HIGH);
delay(s);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
delay(s);
digitalWrite(A5, LOW);
delay(s);
}
}
void loop()
{
anticlockWise(3,50);
clockWise(3,50);
for (int z=0; z<4; z++)
{
allOn();
delay(100);
allOff();
delay(100);
}
}
… and the results are demonstrated in the following video:
Apart from the LEDs the Magpie offers identical function to that of an Arduino Uno R2 – except the USB microcontroller is an Atmel 16U2 instead of an 8U2, and the USB socket is a mini-USB and not the full-size type. For the curious you can download the Magpie design files from the product page.
Conclusion
If you’re often experimenting or working with the Arduino’s I/O pins and find yourself wiring up LEDs for testing purposes – the Magpie was made for you. Having those LEDs on the board really does save you if in a hurry to test or check something.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.
The Magpie board used in this article was a promotional consideration supplied by Little Bird Electronics.
In this post I would like to share a series of interviews conducted by Dave Jones from eevblog.com. Dave interviews Colin Mitchell from Talking Electronics. Throughout the 1980s and onwards, Colin published a range of electronics magazines, tutorials and a plethora of electronics kits – of which many are still available today. Personally I was a great fan of the TE products, and sold many of his books through my past retail career with DSE. I hope you enjoy these interviews, and if not – stay tuned for upcoming articles.
Once again, thanks to Dave Jones and of course Colin Mitchell from Talking Electronics for their interview and various insights.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.
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.
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:
void setup()
{
pinMode(9, OUTPUT); // 1 off
pinMode(8, OUTPUT); // 1 on
pinMode(5, OUTPUT); // 2 off
pinMode(4, OUTPUT); // 2 on
}
void loop()
{
// outlets on channel 1 on
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(8, LOW);
delay(5000);
// outlets on channel 1 off
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(5000);
// outlets on channel 2 on
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
delay(5000);
// outlets on channel 2 off
digitalWrite(5, HIGH);
delay(1000);
digitalWrite(5, LOW);
delay(5000);
}
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:
int aon = 8;
int aoff = 9;
int bon = 4;
int boff = 5;
int pressdelay = 1000; // duration to activate a button on remote
void setup()
{
// prepare the digital output pins
pinMode(aon, OUTPUT);
pinMode(aoff, OUTPUT);
pinMode(bon, OUTPUT);
pinMode(boff, OUTPUT);
//Initialize GSM module serial port for communication.
cell.begin(9600);
delay(30000); // give time for GSM module to register on network etc.
cell.println("AT+CMGF=1"); // set SMS mode to text
delay(200);
cell.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt
delay(200);
}
void loop()
{
//If a character comes in from the cellular module...
if(cell.available() >0)
{
inchar=cell.read();
if (inchar=='#')
{
delay(10);
inchar=cell.read();
if (inchar=='a')
{
delay(10);
inchar=cell.read();
if (inchar=='0')
{
digitalWrite(aoff, HIGH);
delay(pressdelay);
digitalWrite(aoff, LOW);
}
else if (inchar=='1')
{
digitalWrite(aon, HIGH);
delay(pressdelay);
digitalWrite(aon, LOW);
}
delay(10);
inchar=cell.read();
if (inchar=='b')
{
inchar=cell.read();
if (inchar=='0')
{
digitalWrite(boff, HIGH);
delay(pressdelay);
digitalWrite(boff, LOW);
}
else if (inchar=='1')
{
digitalWrite(bon, HIGH);
delay(pressdelay);
digitalWrite(bon, LOW);
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:
#axbx
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 tronixstuff.com. Why not follow things on twitter, Google+, 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.
Time yet again for another kit review. Today’s kit is the Larson Scanner from Evil Mad Science. What a different name for a company; their byline is “DIY and open source hardware for art, education and world domination”. Art? Yes. Education? Definitely. World domination? Possibly – you could use the blinking LEDs to hypnotise the less intelligent world leaders out there.
Anyhow, what is a Larson Scanner? Named in honour of Glen A. Larson the creator of television shows such as Battlestar Galactica and Knight Rider – as this kit recreates the left and right blinking motion used in props from those television shows. For example:
The kit itself is quite inexpensive, easy to assemble – yet can be as complex as you want it to be. More about that later, for now let’s put one together and see how it performs. There are two versions of the kit, one with 5mm clear LEDs and our review model with 10mm diffused red LEDs. The kit arrives inside a huge resealable anti-static bag, as such:
Upon opening the bag we have the following parts (there was an extra LED and resistor, thanks):
… the PCB:
… which is nicely done with a good silk-screen and solder mask. And finally:
A very handy item – a battery box with power switch. The kit is powered by 2 x AA cells (not included!). And finally, the instructions:
At this point you can see that this kit is designed for the beginner in mind. The instructions are easy to read, clear, and actually very well done. If you are looking for a kit to get someone interested in electronics and to practice their soldering, you could do a lot worse than use this kit.
Construction was very easy, starting with the resistors:
followed by the capacitor and button:
then the microcontroller:
… no IC socket. For a beginners’ kit, perhaps one should have been included. Next was the battery box. Some clever thinking has seen holes in the PCB to run the wires through before soldering into the board – doing so provides a good strain relief for them:
… and finally the LEDs. Beginners may solder them in one at a time:
however it is quicker to line them up all at once than solder in one batch:
… which leaves us with the final product:
Operation is very simple – the power switch is on the battery box. The button on the PCB controls the speed of LED scrolling, and if held down switches the brightness between low and high. Now for some action video of the Larson Scanner in operation:
Well that really was fun, a nice change from the usual things around here.
But wait, there’s more… although the Larson Scanner is a good training kit, it can also function in other interesting ways. The kit is completely open-source, you can download the PCB layout file, circuit schematic and microcontroller code. Get two or more and link them together to make a really wide LED display – expansion instructions are available from here. If you solder in a 6-pin PCB header to the area marked J1 on the PCB, you can reprogram the microcontroller using an STK500-compatible programmer.
After sitting my Larson Scanner next to the computer tower for a few minutes, I had contemplated fitting it into a 5.25″ drive bay to make my own Cylon PC, however that might be a little over the top. However my PC case has some dust filters on the front, which would allow LEDs to shine through in a nicely subdued way. Mounting the Larson Scanner PCB inside the computer case will be simple, and power can be sourced from the computer power supply – 5V is available from a disk drive power lead.
If you are going to modify your PC in a similar fashion, please read my disclaimer under “boring stuff” first.
The Larson Scanner can run on 3.3V without any alteration to the supplied components. What needs to be done is to use a voltage regulator to convert the 5V down to 3.3V. My example has used a 78L33 equivalent, the TI LP2950 as it is in stock. The power comes from a drive power cable splitter as such:
You may have a spare power plug in your machine, so can tap from that. 5V is the red lead, and GND is the adjacent black lead. Don’t use yellow – it is 12V. It is then a simple matter of running 5V from the red lead to pin 1 of the regulator, GND from the Larson Scanner and PC together to pin 2, and 3.3V out from the regulator to the PCB 3.3V. Insulation is important with this kind of work, so use plenty of heatshrink:
… then cover the whole lot up:
Now to locate a free power plug in the machine. It has been a while since opening the machine – time for a dust clean up as well:
Mounting the PCB is a temporary affair until I can find some insulated mounting standoffs:
However it was worth the effort, the following video clip shows the results in action:
So there you have it. The Larson Scanner is an ideal kit for the beginner, lover of blinking LEDs, and anyone else that wants to have some easy blinking fun. You can buy Larson Scanner kits in Australia from Little Bird Electronics, or directly from Evil Mad Science for those elsewhere.
As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, follow me on twitter or facebook, or join our Google Group for further discussion.
Time again for another kit review. Today we will examine the FreeduinoArduino Duemilanove-compatible board in a kit. It is always interesting to see how the different types and makes of Arduino-compatible boards present themselves, so this is review is an extension of that curiosity. This kit was originally designed by NKC Electronics and released under a Creative Commons license.
The packaging can either be classed as underwhelming or environmentally-friendly, as the kit arrives in several plastic resealable bags. Upon emptying them out we are presented with the following, the parts:
and the PCB:
Hopefully you noticed what ends up being the key features of this kit – the pre-soldered FTDI IC and mini-USB socket. This means the Freeduino can be used with a USB cable (not included) and not an expensive FTDI cable. The PCB itself is very solid, has a very descriptive silk-screen layer with all the component positions labelled, is solder-masked, and has nice rounded corners.
Reviewing the included parts did make me wonder why the supplier has used 5% carbon-film resistors and ceramic capacitors instead of polyesters (except for one). It turns out that Seeedstudio (the distributor for my example kit) claim 5% resistors are easier to read. Originally I claimed that this was an excuse to save a few cents, however a few people have said that such resistors are easier to read.
Furthermore, this one missed out on the polyfuse for USB overcurrent and short-circuit protection. And whether or not the larger tolerances affect the operation of the board, the cheaper components make the finished product look very 1977. However on a brighter note, an IC socket is included.
Assembly was quick and simple. There are excellent online instructions published by the Freeduino creator NKC available here. However you can also follow the silk-screen labels on the PCB as well. A good method is to start with the lowest-profile compontents, such as resistors and capacitors:
… then followed by the capacitors, crystal, LEDs and reset button:
Notice how the ceramic capacitors lead-spacing is too narrow for the holes on the PCB – this makes me think that the distributor has skimped out on the final product and been too lazy to update the PCB layout. The ATmega168 label is an example of this. Moving forward, the voltage regulator and sockets. The easiest way to solder in the shield sockets is to place them into the pins of an Arduino shield and solder – as such:
And there you have it, one Freediono v1.22 Arduino Duemilanove-compatible board:
The image above also displays another bugbear with this kit – the LED placement. When you have a shield inserted, all of the LEDs are covered up. Furthermore, unlike other Arduino board kits (such as the Freetronics KitTen) you are stuck with the maximum current output of 50mA for the 3.3V rail as there isn’t a dedicated 3.3V voltage regulator on board. Finally, the power switching between USB and the DC socket is controlled with a jumper and header pins between the USB socket and the 7805 voltage regulator.
Although I might have sounded a little harsh about this kit, it is relatively inexpensive, easy to assemble, and has the USB interface onboard. These are all good things. However the PCB layout could have been improved by correctly spacing the holes for the ceramic capacitors, and moving the LEDs to the end of the board so they are visible with shields inserted. What’s the point of having all those LEDs if you cannot see them…
So if you really get the urge to make your own board with the USB interface, or want to give someone some reasonable soldering practice, this isn’t a bad choice at all. Otherwise get a KitTen or save time and buy an Eleven.
As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, follow me on twitter or facebook, or join our Google Group for further discussion.
How many standard characters can be displayed on a DFRobot 4884 LCD shield? 84;
Which company manufactures the microcontroller used in our Arduino boards? Atmel;
Name five people from the Arduino development team - Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis;
Which IC is the equivalent to two 555 timer ICs? The 556.
Once again it was great to see all the entrants had correct answers for every question, nice work everyone. However there can only be two winners…
Congratulations to Paul G. and Stuart M. – both lucky winners of a $40 gift voucher from Little Bird Electronics.
What a month it has been. And keep an eye out for the April competition which will be announced in a few days – there are some really fun and interesting prizes up for grabs!
So as you can see you can win great prizes just for checking into tronixstuff.com on a regular basis. If you missed out this month, stay tuned as it all starts again in the next few days. Why not follow things on twitter, 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.
Today I am going to introduce something quite different, yet hopefully interesting to you out there. The renowned director and cinematographer Karl von Muller has just released the roll-call trailer for his upcoming documentary titled “State of Electronics” – a discussion on the Electronics Industry in Australia. Although the focus is on the Australian electronics scene, much of the content and discourse within the documentary can be related to by those from many other countries.
However, Karl can explain it better:
After several months of researching, interviewing and filming, I’m excited to present the first public Trailer to my new Documentary “State of Electronics” – A discussion on the Electronics Industry in Australia. Even though the documentary is focused on Australian Electronics Design and Manufacture, much of it applies to all countries from around the world.
The discussion is focused initially on the world of Hobby Electronics and how it’s decline could affect the Electronics Industry in the future. The Documentary then discusses many issues that face industry including the issue of “Repair and Recycle”, “Education”, “Surface Mount Technology”, “Globalisation”, “Opportunities” and many many more off the cuff & candid comments from Industry professionals.
The Documentary features interviews with famous Australians and Industry professionals including Dick Smith, Dave L Jones, Doug Ford, Leo Simpson, Grant Petty, Matthew Pryor, Jonathan Oxer, Andy Gelme, Andrew Griffiths, Eugene Ruffolo & Bill Petreski. In the future, I am planning to interview just a few more before the final release of the Documentary soon.
Shot completely on the Canon 5DMK2, using the Zoom H4N Audio recorder. Directed, Edited and shot by Karl von Moller, this version of the trailer is largely ungraded and only has an FCP sound mix applied. Music track is composed by Karl von Moller also. Enjoy!
Please visit karlvonmoller.com for more on the progress and information on “State of Electronics”
Here is the new roll-call trailer:
… and the original trailer for those unfamiliar with the project:
This will surely be a fascinating and insightful documentary that we are all looking forward to. Nice one Karl!
The March competition has now closed and the winners have been notified. The April competition will be announced shortly!
Another month has passed, so time for another competition!
To enter, find the five questions that will be spread across the articles published in tronixstuff.com between the first and last day of March. When you have answers to all five questions, email your answers to competition at tronixstuff dot com with “March″ in the subject line. Then in the first week of April, I will compile a list of people with the correct answers, and randomly select two winners…
Each winner will receive an Au$40 gift voucher to spend with Little Bird Electronics – Australia’s leading online retailer of fun stuff, including competitive prices on merchandise from Sparkfun, Seeed Studio, DF Robot and more!
As with any other competition, there needs to be some rules:
Prizes will be emailed upon confirmation of email address;
Winners outside of Australia will be responsible for any taxes, fees or levies imposed by your local Governments (such as import levies, excise, VAT, etc.) upon importation of purchased goods;
If you have won a previous competition you cannot enter;
If you know me in real life you cannot enter;
The Judge’s decision is final with regards to any dispute;
Entries will be accepted until 2359h GMT on 31st March 2011.
So have fun and keep checking into tronixstuff.com. Why not follow things on twitter, 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.
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 (click to enlarge):
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.
#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the Serial Port.
SoftwareSerial cell(2,3); //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.
int numring=0;
int comring=3;
int onoff=0; // 0 = off, 1 = on
void setup()
{
pinMode(12, OUTPUT);
pinMode(13, OUTPUT); // LEDs - off = red, on = green
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
//Initialize serial port for communication.
cell.begin(9600);
}
void loop()
{
//If a character comes in from the cellular module...
if(cell.available() >0)
{
inchar=cell.read();
if (inchar=='R')
{
delay(10);
inchar=cell.read();
if (inchar=='I')
{
delay(10);
inchar=cell.read();
if (inchar=='N')
{
delay(10);
inchar=cell.read();
if (inchar=='G')
{
delay(10);
// So the phone (our GSM shield) has 'rung' once, i.e. if it were a real phone
// it would have sounded 'ring-ring'
numring++;
if (numring==comring)
{
numring=0; // reset ring counter
doSomething();
}
}
}
}
}
}
}
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:
AT+CMGF=1
Which sets the SMS mode to text. The second command is:
AT+CNMI=3,3,0,0
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 (click to enlarge):
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:
AT+CMGD=1,4
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.
#include <SoftwareSerial.h>
char inchar; //Will hold the incoming character from the Serial Port.
SoftwareSerial cell(2,3); //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.
int led1 = 9;
int led2 = 10;
int led3 = 11;
int led4 = 12;
void setup()
{
// prepare the digital output pins
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
//Initialize GSM module serial port for communication.
cell.begin(9600);
delay(30000); // give time for GSM module to register on network etc.
cell.println("AT+CMGF=1"); // set SMS mode to text
delay(200);
cell.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt
delay(200);
}
void loop()
{
//If a character comes in from the cellular module...
if(cell.available() >0)
{
inchar=cell.read();
if (inchar=='#')
{
delay(10);
inchar=cell.read();
if (inchar=='a')
{
delay(10);
inchar=cell.read();
if (inchar=='0')
{
digitalWrite(led1, LOW);
}
else if (inchar=='1')
{
digitalWrite(led1, HIGH);
}
delay(10);
inchar=cell.read();
if (inchar=='b')
{
inchar=cell.read();
if (inchar=='0')
{
digitalWrite(led2, LOW);
}
else if (inchar=='1')
{
digitalWrite(led2, HIGH);
}
delay(10);
inchar=cell.read();
if (inchar=='c')
{
inchar=cell.read();
if (inchar=='0')
{
digitalWrite(led3, LOW);
}
else if (inchar=='1')
{
digitalWrite(led3, HIGH);
}
delay(10);
inchar=cell.read();
if (inchar=='d')
{
delay(10);
inchar=cell.read();
if (inchar=='0')
{
digitalWrite(led4, LOW);
}
else if (inchar=='1')
{
digitalWrite(led4, HIGH);
}
delay(10);
}
}
cell.println("AT+CMGD=1,4"); // delete all SMS
}
}
}
}
}
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.
Have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.
Connect your Arduino to the cellular network with the SM5100 GSM module shield. This is chapter twenty-six 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 18/03/2013
Introduction
The purpose of this tutorial is to have your Arduino to communicate over a GSM mobile telephone network using the SM5100B GSM Cellular Shield:
This is the first of several articles related to the SM5100B GSM shield. My goal is to illustrate various methods of interaction between an Arduino and the GSM cellular network using the shield, with which you can then use your existing knowledge to build upon those methods. Doing so isn’t easy – but it isn’t that difficult.
Stop! Please read first:
It is assumed that you have a solid understanding of how to program your Arduino. If not, start from chapter zero
Sending SMS messages and making phone calls cost real money, so it would be very wise to use a prepaid cellular account or one that allows a fair amount of calls/SMS
The GSM shield only works with “2G” GSM mobile networks operating on the 850, 900 and PCS1800 MHz frequencies. If in doubt, ask your carrier first
Australians – you can use any carrier’s SIM card, except for “Three”
Canadians – this doesn’t work with Sasktel
North Americans – check with your cellular carrier first if you can use third-party hardware (i.e. the shield)
I cannot offer design advice for your project nor technical support for this article.
If you are working on a college/university project and need specific help – talk to your tutors or academic staff. They get paid to help you.
Please don’t make an auto-dialler…
Getting started
As mentioned previously, we’re using the Sparkfun GSM shield with the SM5100B module. When you order the shield, don’t forget to order the stacking header pin set as they’re not included with the shield, and you’ll need to solder them on yourself. Power -the GSM shield can often require up to 2A of current in short bursts – especially when turned on, reset, or initiating a call. However your Arduino board can only supply just under 1A. It is highly recommended that you use an external regulated 5V power supply capable of delivering 2A of current – from an AC adaptor, large battery with power regulator, etc. Otherwise there is a very strong probability of damaging your shield and Arduino.
Ignore this at your own risk
When connecting this supply DO NOT use the DC socket on the Arduino. Instead, connect the 5V (positive) from the supply to the 5V pin on the GSM shield, and the negative to the GND pin.
If you’re looking for a more permanent or easy-to-wire solution, get yourself a DFRobot power shield:
This shield sits on top of your GSM shield (which sits on top of your Arduino). Before use you need to set it up:
The only jumpers that should be on the power shield are as shown in the image above;
Connect a power supply of between 9 and 35V DC to the blue terminal block at the bottom-left of the shield;
Connect a voltmeter/multimeter to the other blue terminal block at the top-left and adjust the potentiometer (blue thing between the terminal blocks) until the voltage measured is 5 volts; ignore the LEDs on the shield as they’re not that accurate;
Run a wire from the positive power output to the 5V pin on the shield, and run another one from the negative power output to a GND pin on the shield;
If you have the USB cable connected to your project while operating the GSM shield, remove the USB cable before turning off external power to the project.
Here’s what it looks like once assembled with the antenna:
Next – use an antenna! The wire hanging from the shield is not an antenna. YOU NEED THE ANTENNA! There are two choices. Either use the smaller one for areas where handheld mobile reception is acceptable, such as this one:
Or if you are in an area of weaker reception, use an external antenna such as that used on a motor vehicle. If you are using the larger vehicle-style aerial, you might find that the plug will not fit to the shield’s connector. For example, consider the following:
On the left is the end of the lead from the carphone aerial, the right is the lead from the GSM shield. Problem! The solution is in the centre: an FME male to SMA male adaptor. This one came from element-14, part number 1826209 (it is a Multicomp R23-014-00-002611000).
Furthermore, care needs to be taken with your GSM shield with regards to the aerial lead-module connection, it is very fragile:
And finally, download this document (.pdf). It contains all the AT and ERROR codes that will turn up when you least expect it. Please review it if you are presented with a code you are unsure about.
Wow – all those rules and warnings?
The sections above may sound a little authoritarian, however I want your project to be a success. With the previous iterations of the tutorial people just didn’t follow the instructions – so I hope you do
Are you using an Arduino Mega or Leonardo board?
Things are a little different for you. Those boards don’t support SoftwareSerial on digital pins 2 and 3 thus rendering the GSM shield a little trickier to use. Instead, bend back the D2 and D3 pins on the GSM shield as such (click image to enlarge):
Then run jumpers from D2 on the attached shield to D10 and another from D3 to D11. If you’re using the aforementioned power shield it would be on top of the GSM shield however the jumper wires would be the same. Finally in all the sketches, change the line SoftwareSerial cell(2,3); to SoftwareSerial cell(10,11); . If you have a Leonardo, get a Uno.
Initial check – does it work?
This may sound like a silly question, but considering the cost of the shield and the variables involved, it is a good idea to check if your setup is functioning correctly before moving on. From a hardware perspective for this article, you will need your Arduino board, the GSM shield with activated SIM card and an aerial, and a range of previously used components. Make sure your SIM card is set to not require a PIN when the phone is turned on. You can check and turn this requirement off with your cellphone. For our initial test, upload the following sketch:
char incoming_char=0; //Will hold the incoming character from the Serial Port.
SoftwareSerial cell(2,3); //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.
void setup()
{
//Initialize serial ports for communication.
Serial.begin(9600);
cell.begin(9600);
Serial.println("Starting SM5100B Communication...");
}
void loop()
{
//If a character comes in from the cellular module...
if(cell.available() >0)
{
incoming_char=cell.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}
//If a character is coming from the terminal to the Arduino...
if(Serial.available() >0)
{
incoming_char=Serial.read(); //Get the character coming from the terminal
cell.print(incoming_char); //Send the character to the cellular module.
}
}
Then connect the GSM shield, aerial, insert the SIM card and apply power. Open the serial monitor box in the Arduino IDE and you should be presented with the following:
It will take around fifteen to thirty seconds for the text above to appear in full. What you are being presented with is a log of the GSM module’s actions. But what do they all mean?
+SIND: 1 means the SIM card has been inserted;
the +SIND: 10 line shows the status of the in-module phone book. Nothing to worry about there for us at the moment;
+SIND: 11 means the module has registered with the cellular network
+SIND: 3 means the module is partially ready to communicate
and +SIND: 4 means the module is registered on the network, and ready to communicate
If your terminal returned a +SIND 8 instead of 4, that is OK, we’ll sort that out in a moment. From this point on, we will need to use a different terminal program, as the Arduino IDE’s serial monitor box isn’t made for full two-way communications. You will need a terminal program that can offer full two-way com port/serial communication. For those running MS Windows, an excellent option is available here. It’s free, however consider donating for the use of it. For other operating systems, people say this works well. So now let’s try it out with the terminal software. Close your Arduino IDE serial monitor box if still open, then run your terminal, set it to look at the same serial port as the Arduino IDE was. Ensure the settings are 9600, 8, N, 1. Then reset your Arduino and the following should appear:
The next step is to tell the GSM module which network frequency(ies) to use. Please download this document (.pdf), and view page 127. There is a range of frequency choices that our module can use. If you don’t know which one to use, contact the telephone company that your SIM card came from. Australia – use option 4. Choose your option, then enter
AT+SBAND=x
(where X is the value matching your required frequency) into the terminal software and click SEND. Then press reset on the Arduino and watch the terminal display. You should hopefully be presented with the same text as above, ending with +SIND: 4. If your module returns +SIND: 4, we’re ready to move forward.
Our next test is to call our shield. So, pick up a phone and call it. Your shield will return data to the terminal window, for example:
As you can see, the module returns what is happening. I let the originating phone “ring” twice, and the module received the caller ID data (sorry, blacked it out). Some telephone subscribers’ accounts don’t send caller ID data, so if you don’t see your number, no problem. “NO CARRIER” occurred when I ended the call. +SIND: 6,1 means the call ended and the SIM is ready.
Have your Arduino “call you”
The document (.pdf) we downloaded earlier contains a list of AT commands – consider this a guide to the language with which we instruct the GSM module to do things. Let’s try out some more commands before completing our initial test. The first one is:
ATDxxxxxx
which dials a telephone number xxxxxx. For example, to call (212)-8675309 use
ATD2128675309
The next one is
ATH
which “hangs up” or ends the call. So, let’s reach out and touch someone. In the terminal software, enter your ATDxxxxxxxx command, then hit send. Let your phone ring. Then enter ATH to end the call. If you are experimenting and want to hang up in a hurry, you can also hit reset on the Arduino and it will end the call as well as resetting the system. So by now you should realise the GSM module is controlled by these AT commands.
To use an AT command in a sketch, we use the function
A simple sketch to dial a telephone number, wait, then hang up. Replace xxxxxxxx with the number you wish to call.
#include <SoftwareSerial.h>
SoftwareSerial cell(2,3);
void setup()
{
cell.begin(9600);
delay(25000); // give the GSM module time to initialise, locate network etc.
// this delay time varies. Use example 26.1 sketch to measure the amount
// of time from board reset to SIND: 4, then add five seconds just in case
}
void loop()
{
cell.println("ATDxxxxxxxxx"); // dial the phone number xxxxxxxxx
// change xxxxxxx to your desired phone number (with area code)
delay(20000); // wait 20 seconds.
cell.println("ATH"); // end call
do // remove this loop at your peril
{
delay(1);
}
while (1>0);
}
The sketch in example 26.2 assumes that all is well with regards to the GSM module, that is the SIM card is ok, there is reception, etc. The delay function in void setup() is used to allow time for the module to wake up and get connected to the network. Later on we will read the messages from the GSM module to allow our sketches to deal with errors and so on. However, you can see how we can simply dial a telephone. You could now have a home alarm system that can call you upon an event happening, etc.
Send an SMS from your Arduino
Another popular function is the SMS or short message service, or text messaging. Before moving forward, download and install Meir Michanie’s SerialGSM Arduino library from here.
Sending a text message is incredibly simple – consider the following sketch:
void sendSMS()
{
cell.Verbose(true); // used for debugging
cell.Boot();
cell.FwdSMS2Serial();
cell.Rcpt("+xxxxxxxxx"); // replace xxxxxxxxx with the recipient's cellular number
cell.Message("Contents of your text message");
cell.SendSMS();
}
void loop()
{
sendSMS();
do // remove this loop at your peril
{
delay(1);
}
while (1>0);
}
It’s super-simple – just change the phone number to send the text message, and of course the message you want to send. The phone numbers must be in international format, e.g. Australia 0418 123456 is +61418123456 or USA (609) 8675309 is +16098675309.
Have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.