Monday, January 31, 2011

Tutorial: Arduino and GSM Cellular – Part Two

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. Please note from November 1, 2010 files from tutorials will be found here.

Welcome back fellow arduidans!

Today we are going to harness the awesome power of the telephone network to control an Arduino board via a SM5100B Cellular Shield:

If you have not already done so, please review the first GSM shield article – chapter twenty-six, taking note of power supply, antenna issues and so on.

Are you using an Arduino Mega board?

Mega users – things will be slightly different for you. Please make sure the TX and RX pins of your GSM shield DO NOT plug into your Mega. Furthermore, run a jumper wire from GSM shield pin D2 to Mega pin 19, and a jumper from GSM shield pin D3 to Mega pin 18, as shown below:

Finally, the example sketches will be different. Mega will not use the NewSoftSerial library, instead we use the Serial1 port. Please use the following Mega-equivalent sketches for this article: Example 27.1 and 27.2.

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 answerthe 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.

Example 27.1 (Mega version)

/*  Example 27.1  Turn something on or off by telephoning the GSM shield for a set number of rings
tronixstuff.com/tutorials > chapter 27  CC by-sa-nc
NOT for Arduino Mega */
#include <NewSoftSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module
char inchar;       // Will hold the incoming character from the Serial Port
NewSoftSerial cell(2,3);    //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin
int numring=0; // used to count the number of 'rings' received by the GSM module
int comring=3; // this is the number of rings to wait for until calling the function doSomething();
int onoff=0; // used to track LED status - 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 doSomething()
{
if (onoff==0)
{
onoff=1;
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
}   else
if (onoff==1)
{
onoff=0;
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
}
}  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.

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:

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.

Example 27.2 (Mega version)

/*    Example 27.2   Control four digital outputs via SMS
tronixstuff.com/tutorials > chapter 27   CC by-sa-nc
NOT for Arduino Mega   */
#include <NewSoftSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module.
char inchar;                //Will hold the incoming character from the Serial Port.
NewSoftSerial 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=='#') // OK - the start of our command
{
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. Once again that is all we have time for in this instalment. Thank you for your patience in awaiting this series of articles. Although getting it together was a little tricky, it was a lot of fun. I hope you enjoyed reading it as much as I did writing it for you.

If you have any questions about the processes or details in this article, please ask in our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, there is the odd competition or give-away –  and we can all learn something.

Otherwise, have fun, stay safe, be good to each other – and make something!

Friday, January 28, 2011

Kit Review - MDC Bare-bones Board Kit (Arduino-compatible)

Hello readers

Today we continue to examine Arduino-compatible products by assembling an interesting kit from Modern Device Company - their "Bare Bones Board" (to be referred to as BBB).The BBB kit is an inexpensive way to take advantage of the Arduino Duemilanove-compatible platform, and also fills some gaps in the marketplace. Unlike the usual Arduino and compatible boards, the BBB does maintain the recognisable form factor - that is, you cannot use the variety of Arduino shields. However, the BBB does have all the input and output connections, just in different positions.

So why would you use this kit? If you are looking to create a more permanent Arduino-based project that did not require a shield, and you are in a hurry - the BBB could be easily integrated into your design. Money is saved by not having the usual USB connection, so uploading your sketch is achieved using a 5V FTDI cable or using another Arduino board as the programmer. Furthermore, the PCB is designed in a way that allows you to plug the BBB into the side of a solderless breadboard, which allows prototyping more complex Arduino-based circuits very easy. But more about that later. For now, let's have a look at construction. An excellent set of instructions and a guide to use is available for download here.

In the spirit of saving money, the kit arrives in a plastic bag of sorts:

And upon emptying the contents, the following parts are introduced:

Regular readers would know that the inclusion of an IC socket makes me very happy. The PCB is thicker than average and has a great silk-screen which makes following instructions almost unnecessary. One of the benefits of this kit is the ability to connect as little or as many I/O or programming pins as required. And for the pins A0~A5, 5V, GND and AREF you are provided with header pins and a socket, allowing you to choose. Or you could just solder directly into the board. These pins are available on the bottom-left of the PCB. However there was one tiny surprise included with the parts:

This is a 15uH SMD inductor, used to reduce noise on the analog/digital section. According to the instructions, this was originally required with Arduino-style boards that used the ATmega168 microcontroller - however the BBB now includes the current ATmega328 which does not require the inductor. However, it is good to get some SMD practice, so I soldered it in first:

Well it works, so that was a success. Soldering the rest of the main components was quite simple, thanks to the markings on the PCB. The key is to start with the lowest-profile (height) components (such as that pesky inductor) and work your way up to the largest. For example:

As you can see from the PCB close-up above, you can have control over many attributes of your board. Please note that the revision-E kit does include the ATmega328 microcontroller, not the older '168. For more permanent installations, you can solder directly into I/O pins, the power supply and so on. Speaking of power, the included power regulator IC for use with the DC input has quite a low current rating - 250 mA (below left). For my use, this board will see duty in a breadboard, and also a 5V supply for the rest of the circuit, so more current will be required. Thankfully the PCB has the space and pin spacing for a 7805 5V 1A regulator (below right), so I installed my own 7805 instead:

Finally, to make my Arduino-breadboarding life easier I installed the sockets for the analogue I/O, the DC socket and a row of header pins for the digital I/O. Below is my finished example connected into a breadboard blinking some LEDs:

In this example, the board is being powered from the 5V that comes along the FTDI cable. If doing so yourself, don't forget that there is a maximum of 500 mA available from a USB port. If you need more current (and have installed the 7805 voltage regulator) make use of the DC socket, and set the PCB power select jumper to EXT. For a better look at the kit in action, here is a short video clip:

As you can see from the various angles shown in the video, there are many points on the PCB to which you can use for power, ground, I/O connection and so on. As illustrated at the beginning of this article, a variety of header pins are included with the kit. And please note that the LED on the board is not wired into D13 as other Arduino-type boards have been... the BBB's LED is just an "on" indicator. However if you are using this type of kit, you most likely will not need to blink a solitary LED. However some people do use the D13 LED for trouble-shooting, so perhaps you will need it after all. Each to their own!

In conclusion, the BBB is another successful method of prototyping with the Arduino system. The kit was of a good quality, included everything required to get working the first time, and is quite inexpensive if you have a 5V FTDI cable or an Arduino Duemilanove/Uno or compatible board for sketch uploading. It is available in Australia from Little Bird Electronics, or directly from Modern Device in the USA.

Once again, thank you for reading this kit review, and I look forward to your comments and so on. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, and if you have any questions – why not join our Google Group? It’s free and we’re all there to learn and help each other.

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

Thursday, January 27, 2011

The 555 Precision Timer IC

Hello readers

Today we revisit one of the most popular integrated circuits ever conceived – the 555 timer IC. “Triple-five”, “five-five-five”, “triple-nickel” … call it what you will, it has been around for thirty-eight years. Considering the pace of change in the electronics industry, the 555 could be the constant in an ever-changing universe. But what is the 555? How does it work? How can we use it? And … why do we still use it? In this introductory article we will try to answer these questions.

What is the 555?

The 555 timer is the solution to a problem found by the inventor – Hans Camenzind.  He saw the need through his radio work for a part that could act as an oscillator or a timer [1]; and working as a contractor for Signetics developed the 555. (Signetics was purchased by Philips in 1975, and their semiconductor division was spun off as NXP in 2006). The 555 has to be one of the most used ICs ever invented. It is used for timing, from microseconds to hours; and creating oscillations (which is another form of timing for the pedants out there). It is very flexible with operation voltage, you can throw from 4.5 to 18V at it; you can sink or source 200mA of current through the output; and it is very cheap – down to around nine cents if you order several thousand units. Finally, the 555 can achieve all of this with a minimum of basic components – some resistors and capacitors.

Here are some examples in the common DIP casing:

Furthermore a quick scan of suppliers’ websites show that the 555 is also available in surface-mount packages such as SOIC, MSOP and TSSOP. You can also source a 556 timer IC, which contains two 555 ICs. (What’s 555 + 555? 556…) Furthermore, a 558 was available in the past, but seems rather tricky to source these days.

How does the 555 work?

The 555 contains two major items:

  • A comparator – a device which compares two voltages, and switches its output to indicate which is larger, and
  • A flip-flop – a circuit that has two stable states, and those states can be changed by applying a voltage to one of the flip-flop’s inputs.

Here is the 555 functional diagram from the Texas Instruments data sheet:

… and the matching pin-out diagram:

Don’t let the diagrams above put you off. It is easier to explain how the 555 operates within the context of some applications, so we will now explore the three major uses of the 555 timer IC in detail – these being astable,  monostable, and bistable operations, in theory and in practice.

Astable operation

Astable is an on-off-on… type of oscillation – and generates what is known as a square wave, for example:


There are three values to take note of:

  • time (s) – the time for a complete cycle. The number of cycles per second is known as the frequency, which is the reciprocal of time (s);
  • tm (s) – the duration of time for which the voltage (or logic state) is high;
  • ts (s) - the duration of time for which the voltage (or logic state) is low.

With the use of two resistors and one capacitor, you can determine the period durations. Consider the following schematic:

Calculating values for R1, R2 and C1 was quite simple. You can either determine the length of time you need (t) in seconds, or the frequency (Hz) – the number of pulses per second.

t (time) = 0.7 x (R1 + [2 x R2]) x C1

f (frequency) = 1.4 / {(R1 + [2 x R2]) x C1}

Where R1 and R2 are measured in ohms, and C1 is measured in farads. Remember that 1 microfarad = 1.0 × 10-6 farads, so be careful to convert your capacitor values to farads carefully. It is preferable to keep the value of C1 as low as possible for two reasons – one, as capacitor tolerances can be quite large, the larger the capacitor, the greater your margin of error; and two, capacitor values can be affected by temperature.

How the circuit works is relatively simple. At the time power is applied, the voltage at pin 2 (trigger) is less than 1/3Vcc. So the flip-flop is switched to set the 555 output to high. C1 will charge via R1 and R2. After a period of time (Tm from the diagram above) the voltage at pin 6 (threshold) goes above 2/3Vcc. At this point, the flip-flop is switched to set the 555 output to low. Furthermore, this enables the discharge function – so C1 will discharge via R2. After a period of time (Ts from the diagram above) the voltage at pin 2 (trigger) is less than 1/3Vcc. So the flip-flop is switched to set the 555 output to high… and the cycle repeats.

Now, for an example, I want to create a pulse of 1Hz (that is, one cycle per second). It would be good to use a small value capacitor, a 0.1uF. In farads this is 0.0000001 farads. Phew. So our equation is 1=1.4/{(R1 + [2 x R2]) x C1}. Which twists out leaving us R1=8.2Mohm, R2=2.9MOhm and C1 is 0.1uF. I don’t have a 2.9MOhm resistor, so will try a 2.7MOhm value, which will give a time value of around 0.9s. C2 in astable mode is optional, and used if there is a lot of electrical noise in the circuit. Personally, I use one every time, a 0.01uF ceramic capacitor does nicely. Here is our example in operation:

Notice how the LED is on for longer than it is off, that is due to the ‘on’ time being determined by R1+R2, however the ‘off’ time is determined by R2 only. The ‘on’ time can be expressed as a percentage of the total pulse time, and this is called the duty cycle. If you have a 50% duty cycle, the LED would be on and off for equal periods of time. To alter the duty cycle, place a small diode (e.g. a 1N4148) over pins 7 (anode) and 2 (cathode). Then you can calculate the duty cycle as:

Tm = 0.7 x R1 x C1 (the ‘on’ time)

Ts = 0.7 x R2 x C1 (the ‘off’ time)

Furthermore, the 555 can only control around 200mA of current from the output to earth, so if you need to oscillate something with more current, use a switching transistor or a relay between the output on pin 3 and earth. If you are to use a relay, put a 1N4001 diode between pin 3 (anode) and the relay coil (cathode); and a 1N418 in parallel with the relay coil, but with the anode on the earth side. This stops any reverse current from the relay coil when it switches contacts.

Question – What is the maximum supply voltage for a TI NE555 IC?

Monostable operation

Mono for one – one pulse that is. Monostable use is also known as a “one-shot” timer.  So the output pin (3) stays low until the 555 receives a trigger pulse (drop to low) on pin 2. The length of the resulting pulse is easy to calculate:

T = 1.1 x R1 x C1;

where T is time in seconds, R1 is resistance in ohms, and C1 is capacitance in farads. Once again, due to the tolerances of capacitors, the longest time you should aim for is around ten minutes. Even though your theoretical result for T might be 9 minutes, you could end up with 8 minutes 11 seconds. You might really need those extra 49 seconds to run away…  Though you could always have one 555 trigger another 555… but if you were to do that, you might as well use a circuit built around an ATmega328 with Arduino bootloader.

Now time for an example. Let’s have a pulse output length of (as close as possible to) five seconds. So, using the equation, 5 = 1.1 x R1 x C1… I have a 10 uF capacitor, so C1 will be 0.00001 farads. Therefore R1 will be 454,545 ohms (in theory)… the closest I have is a 470k, so will try that and see what happens. Note that it you don’t want a reset button (to cancel your pulse mid-way), just connect pin 4 to Vs. Here is the schematic for our example:

How the monostable works is quite simple. Nothing happens when power is applied, as R2 is holding the trigger voltage above 1/3Vcc. When button S1 is pushed, the trigger voltage falls below 1/3Vcc, which causes the flip-flop to set the 555′s output to high. Then C1 is charged via R1 until the threshold voltage 2/3Vcc is reached, at which point the flip-flip sets the output low and C1 discharges. Nothing further happens until S1 is pressed again. The presence of the second button S2 is to function as a reset switch. That is, while the output is high the reset button, if pressed, will set the output low and set C1 to discharge.

Below is a video of my example at work. First I let it run the whole way through, then the second and subsequent times I reset it shortly after the trigger. No audio in clip:

Once again, we now have a useful form of a one-shot timer with our 555.

Bistable operation

Bistable operation is where the 555′s output is either high, or low – but not oscillating. So if you pulse the trigger, the output becomes and stays high, until you pulse reset. So you can basically make a nice soft-touch electronic switch for a project. So let’s do that now, it is so simple you don’t need one of my quality schematics. But here you are anyway:

In this example. pressing S1 sets the voltage at pin 2 (trigger) to below 1/3Vcc, thereby setting the output to high – therefore we call S1 our ‘on’ switch. As pin 6 (threshold) is permanently connected to GND, it cannot be used to set the output to low. The only way to set the output back to low is by pressing S2 – the reset button, which we can call the ‘off’ switch. Couldn’t be easier, could it? And that output pin could switch a transistor or a relay on or off, who knows? Your only limit is your imagination. And here’s one more video clip:

So there you have it, three ways in which we can use our 555 timer ICs. But in the year 2011, why do we still use a 555? Price, simplicity, an old habit, or the fact that there are so many existing designs out there ready to use. There will be many arguments for and against continued use of the 555 – but as long as people keep learning about electronics, the 555 may still have a long and varied future ahead of it.

Well that is all we have time for in this instalment. Stay tuned for more about the 555 in the near future, including some example circuits and so on.

If you have any questions about the processes or details in this article, please ask in our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, there is the odd competition or give-away –  and we can all learn something.

Otherwise, have fun, stay safe, be good to each other – and make something!

References

[1] “The 555 Timer IC – An interview with Hans Camenzind” (Jack Ward – semiconductormuseum.com)

Various diagrams and images from the Texas Instruments NE555 data sheet.

Friday, January 21, 2011

Kit review: Freetronics KitTen Arduino-compatible board

Hello everyone

Within this article we are going to examine another new kit available from Freetronics, a company formed to provide many interesting Arduino-based products after the publication of the book “Practical Arduino” by Jonathan Oxer and Hugh Blemings – which in itself is a good read, there are many interesting projects to make and learn from.

Today we examine their answer to “is there a kit version of the TwentyTen Arduino Duemilanove-compatible board?” – by assembling their KitTen. Some people may be wondering why one would want to build a KitTen instead of an assembled unit. Personally I could think of the following reasons:

  • It’s fun to make something and see it work;
  • You can save over Au$10;
  • There are a lot more smoothing capacitors in the KitTen design than normal boards;
  • There is a dedicated 3.3V 100 milliamp power regulator (twice the current of the usual board’s 50mA supply)  - ideal for running thirsty shields that need a native 3.3V;
  • The board is for a project that needs to use a modified version of the TwentyTen/Duemilanove;
  • You want a board with a native serial instead of USB interface;
  • All that lovely prototyping area above the microcontroller;
  • The power light and LED for D13 are always visible due to their location on the edge of the PCB;
  • You could solder in your microcontroller to avoid theft – great for school and public use (Yes, this has happened)…

And so on. Moving forward, opening the KitTen package reveals the following:

Once again with a Freetronics kit, all instructions are included in colour, as well as the circuit schematic and another sheet explaining how the KitTen will work with Arduino systems and the specifications. The PCB is solder-masked and silk-screened with a very informative layout:

The rest of the included components shipped in an anti-static bag, including labelled resistors and an IC socket for the microcontroller:

By following the included detailed instructions, everything went well. The layout on the PCB is detailed with all component values, which makes life easier. Starting with the low-profile components:

… followed by higher-profile components such as the IC socket and capacitors:

… and finally the shield sockets. Instead of trying to balance them, it is a lot quicker to place the sockets on an existing Arduino shield, turn it over, drop the KitTen on top then solder the pins in:

Then finally we are finished:

There are a couple of things to watch out for when using your KitTen. The first is to make sure you have the power-select jumper fitted correctly:

Place it on the left pins (as above) to power your KitTen from the FTDI cable; place the jumper on the right pins to power from the DC socket. You should use a power supply of between 9 to 12 volts DC at one amp. The second item to take care with is the blue power LED. The supplied model was so bright it was like staring into the sun. You may wish to test your own one and possibly replace it for a duller version, or use some fine sandpaper to reduce the brightness of the included LED. To upload sketches to your KitTen you will need a 5 volt FTDI cable. As mentioned above, this can also power your board as well.

Overall, this is an excellent kit, and considering the price of doing it yourself – good value as well. To get your hands on this product– visit Freetronics’ website, or your local reseller.

Remember, if you have any questions about these modules please contact Freetronics via their website.

Higher resolution images available on flickr.

Otherwise, have fun, stay safe, be good to each other – and make something! :)

[Note - the kit assembled in this article was received from Freetronics for review purposes]

Wednesday, January 19, 2011

Review – Fluke 233 Remote Display True RMS Multimeter

Hello readers

Several followers of my website have noticed the use of an interesting multimeter in a few of my articles, and were curious about it. So in this article we will discuss it in more detail. It is certainly novel in design, and has proven to be very convenient in use – the Fluke 233 remote-display true RMS multimeter. It arrives in a cardboard box that is easily recycled:

Upon tearing open the packaging we are presented with the following contents:

The contents of the box are as follows:

  • The meter itself;
  • a long (~1.2m) pair of Cat IV leads with very sharp points;
  • matching insulated alligator clip adaptors;
  • a K-type thermocouple;
  • a printed Getting Started manual, and the complete manual on CDROM;
  • a single, universal getting started sheet – explains how to remove battery isolation tabs.

However, a carry case was not included. Considering the cost of the meter here (Au$550 + tax), one would have expected a case. On the other hand, if you/your workplace can afford a 233, you can pay for your own case. So there’s two angles to the case perspective.

It is good to see that there isn’t too much of a printer manual, the less paper used the better. As others have said, if you have one of these meters the manual isn’t necessary apart from checking the specifications, and the same applied to myself. Thoughtfully the meter is supplied and fitted with 5 x AA Duracell alkaline cells, three in the meter body and two in the display unit. All one needs to do is pull out the plastic tabs from the battery compartments, and you’re ready to go.

Physically the unit does not disappoint. Made in the USA. First class. Another solid Fluke design, clean lines, and a great fit and finish. Futhermore it is of a good weight, so you could always bang in a nail with it, or the pointy-head boss. The exterior has the rubber-moulded housing which is not removable, however this would be recommended for the target market – as the 233 would be more of a field work than a test-bench instrument. However, if you do sit it on the bench with the tilting bail, you can still operate it with one hand as it has enough friction to stay put. It is also good to see that the box and packaging are cardboard which is easily recycled.

After flicking the meter on the first thing to do was remove the display, plug in the thermocouple, and toss the body into the freezer:

Even with the meter in the freezer, I could still move the display around 1.5 meters away and it still received the data signal. Notice how the display is on the freezer door – it is magnetic. Immediately the benefits of the remote display come to mind. You can always have the display right where youwant it, and the meter where it needs to be… it’s win-win. After showing it to my auto-electrician friend, she didn’t want to give it back. The ability to set up a meter in a less than perfectly safe environment and take the display away is almost priceless. Furthermore, the backlight is a nice even blueish colour, and times out after around forty seconds.

Whilst in the kitchen, I tested out the external temperature of my tea:

Using the meter in general is very simple, you can hold it in one hand and select all of the functions with your thumb. Having the yellow shift key makes changing between associated readings very simple, for example after reading AC voltage:

Then pressing the shift key changes to frequency:

The meter has several useful indication functions – while working with high voltages the triangular market is illuminated; when changing to temperature you are prompted with “OPEN” for the thermocouple, and changing to current you are prompted with “LEAD” to change sockets. It is obvious after a short period of time this was designed by engineers for engineers, and not made to a ‘price’. Although this is not an electronics multimeter, it still has quite a few ranges that would suit at a pinch. Plus the one-touch data hold, minimum and maximum functions are included as with other top-end Flukes. Hopefully someone at Fluke is working on a remote display version of their 87V.

Now that I have had this meter for just over five months, it has already become a worthwhile addition to my bench. For the kind of work I do, it has already replaced another multimeter, my old frequency counter and thermometer. The ranges are quite useful, and the continuity beeper is in the display not the body. According to the manual the 233 is rated for a one meter drop onto any of the six surfaces. Out of respect to the meter I will not throw it into a river or from a moving car. The other factor that prevents me from going to such extremes is the clear plastic over the LCD – there is a small amount of ‘give’ or flexibility in that area. Otherwise the 233 is as solid as they come.

The specifications can be found in detail in the manual here, however a quick glance shows:

Range                                                             Accuracy

AC voltage: 0.1mV ~ 1000V                      1~2%+3

AC current: 1mA ~ 10A                               1.5%+3

DC voltage: 0.1mV ~ 1000V                     0.25%+2

DC current: 1mA ~ 10A                               1.0%+3 ** no microamperes

resistance: 0.1 ~ 40 meg-ohm                   0.9~1.5%+2

frequency:  0.01 Hz ~ 50 kHz                    0.1%+2

capacitance: 1nF to 9999 uF                     1.9%+2

temperature: -40 ~ 400 degrees Celsius     1%+10

And there is also a diode test and continuity beeper function. Interestingly enough, I discovered by accident that the frequency counter function was slightly underrated. Some more testing showed it was good for up to 99.48 kHz:

Not bad at all. However as with the many pros, there are  a few cons to using this meter. The auto-zero time of the display is a little slow, sometimes it can take two seconds. That doesn’t sound like much, but when you’re measuring many components the time adds up. And the LCD is not protected as well as expected, you can push into it with your finger. For a Fluke meter, one would expect it to be much more solid – if the display unit fell from a height and landed on something pointy with the display facing down, it would be ruined. So be careful if you have one. Furthermore, the battery life is around eight to ten weeks of “daily use” (perhaps seven hours a week, usually with the backlight on). Some have said this is bad, however my opinion is that the convenience of the remote display makes up for the shorter battery life.

However at the end of the day – this is a great tool. Being able to measure something outside your field of vision, and having the results in front of you is incredibly useful. You could achieve the same functions by using a meter with a PC interface, but that can be overkill and time-consuming to set up. So if the specifications of the 233 meet your needs, this is a great tool that will serve you very well.

The Fluke 233 Remote Display True RMS Multimeter is available from your local element-14 (previously Farnell) or Fluke distributor.

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. Or join our Google Group.

[Disclaimer - the Fluke 233 is a review sample made available by Fluke via element-14]

Otherwise, have fun, be good to each other – and make something! :)

 

Tuesday, January 18, 2011

Tutorial: Arduino and GSM Cellular – Part One

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. Please note from November 1, 2010 files from tutorials will be found here.

Welcome back fellow arduidans!

Today we are going to start using our Arduino to communicate over a GSM mobile telephone network using the SM5100B Cellular Shield:

This will be the first of several articles related to the SM5100B GSM shield. The available documentation for this unit was abysmal, so please be patient.  My goal is to illustrate different ways of interacting using the shield, with which you can then use your existing knowledge to build upon those ways. For this article I want to get a few things out of the way first, which may sound a little harsh, but are necessary.

Firstly – telephone calls and text messages (SMS) can cost real money, so if your sketch goes bonkers and blasts out a few hundred text messages while you’re in the kitchen having tea, you will have to pay for them. It may be prudent to use a prepaid cellular account for testing purposes.

Secondly, the current draw. Sending an SMS (a tiny burst of data) will generally draw around less than 400 mA, which is within our normal Arduino specification. If you are using your shield to make or receive actual telephone calls, the shield can draw up to two amps of current. The actual current draw will vary depending on the strength of network reception in your location. For example, I live in direct line-of-sight of a network tower, use a carphone aerial and have full reception. When using the shield to make a call the current draw is around 420 mA. If in doubt, use the ammeter function of a multimeter to monitor current draw.

However if I was 25km east of Sydney Harbour**, the shield would use maximum transmit/receive power and pull the two amps. Therefore if communicating in this way you cannot run your Arduino and this shield from the USB port or the DC socket. And don’t be lazy by trying it anyway. Instead, power your project with a high-capacity 5V power supply to the 5V and GND pins on your shield.

** If I were 25km out to sea, it would be on the Queen Mary II and Arduino would be the last thing on my mind…

Thirdly, you will need an aerial. These can range from the small “rubber ducky” types, to full carphone models. 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 Farnell/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, please do not try to recreate the following:

http://simpsons.wikia.com/wiki/User:Jihem [CC by-sa]" src="http://images1.wikia.nocookie.net/__cb20091128195239/simpsons/images/1/1a/AutoDialer_AT5000.jpg" height="288" alt="" style="display: block; margin-left: auto; margin-right: auto; border: 1px solid #333333;" width="384" />

From a software perspective we will need the NewSoftSerial Arduino library, so please download and install that before moving on.

Now, on with the show…

Why would you want to connect your Arduino to the mobile phone network anyway? To send and receive data across the mobile network, and to transmit or receive instructions or commands. More specifically, within the scope of this article we will do so mainly using text or SMS messages.

When shipped as new, our shield does not include the 6-pin and 8-pin headers (though it should for the price – cheapskates). So you will need to source your own and solder them in by inserting them onto the pins of another shield and drop the shield on top, then solder the shield in nicely.

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. For our initial test, upload the following sketch :

Example 26.1

/* SparkFun Cellular Shield - Pass-Through Sample Sketch
SparkFun Electronics Written by Ryan Owens CC by v3.0 3/8/10
Thanks to Ryan Owens and Sparkfun for sketch */
#include <NewSoftSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module.
#include <string.h>         //Used for string manipulations
char incoming_char=0;      //Will hold the incoming character from the Serial Port.
NewSoftSerial 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.

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

cell.println()

for example, to dial a phone number, we would use

cell.println("ATD2128675309");

To demonstrate this in a sketch, consider:

Example 26.2

A simple sketch to dial a telephone number, wait, then hang up. Replace xxxxxxxx with the number you wish to call.

/*  Example 26.2  GSM shield making and ending a telephone call
http://tronixstuff.com/tutorials > chapter 26 */ #include <NewSoftSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module.
NewSoftSerial 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.
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.

Another popular function is the SMS or short message service, or text messaging.

Sending text messages from our Arduino…

The AT commands for sending text messages are a little more involved, but nothing to worry about. First, we need to tell the module our SMS will be ASCII text, this is done with:

AT+CMGF=1

Then we need to give the mobile phone number to send the message to:

AT+CMGS="xxxxxxxxx"

At this stage, there needs to be a small delay, around half a second. Then the module will expect the contents of the message (maximum 160 characters) followed by the ASCII equivalent of Ctrl-Z. After sending the message, the module needs around fifteen seconds to finalise the procedure, so if sending multiple messages, allow for this with a delay() function.

Example 26.3

So let’s send a text message. I have tried to simplify the process as much as possible, so the following sketch is my simple “Send an SMS” example:

/*  Example 26.3 GSM shield sending a SMS text message
http://tronixstuff.com/tutorials > chapter 26 */
#include <NewSoftSerial.h>
NewSoftSerial cell(2,3);  // We need to create a serial port on D2/D3 to talk to the GSM module
char mobilenumber[] = "xxxxxxxxx";  // Replace xxxxxxxx with the recipient's mobile number
void setup()
{  //Initialize serial ports for communication.
cell.begin(9600);
delay(35000); // 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("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS=");  // now send message...
cell.print(34,BYTE); // ASCII equivalent of "
cell.print(mobilenumber);
cell.println(34,BYTE);  // ASCII equivalent of "
delay(500); // give the module some thinking time
cell.print("They call me the count... because I like to count! Ah ha ha ha");   // our message to send
cell.println(26,BYTE);  // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
do // You don't want to send out multiple SMSs.... or do you?
{
delay(1);
}
while (1>0);
}

Now we can consider sending data and a fixed text message. To do so, we need to split the procedure of sending a text message into three parts: the sending data, the message and any data, and ending the procedure. This is done in the following example. The sketch generates a random number between 0 and 99. Then it counts from 0 to 99, and when the count reaches the random number, it sends the text message containing an initial note and the random number.

Example 26.4

/*  Example 26.4  Send a text message upon an event occurring
http://tronixstuff.com/tutorials > chapter 26 */
#include <NewSoftSerial.h>
NewSoftSerial cell(2,3);  // We need to create a serial port on D2/D3 to talk to the GSM module
char mobilenumber[]="xxxxxxxx";  // Replace xxxxxxxx with the recipient's mobile numberchar
textmessage[160]; // used to hold contents of message to send
int b=0;
void setup()
{  //Initialize serial ports for communication.
cell.begin(9600);
delay(35000); // 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
pinMode(13, OUTPUT); // use the LED for status
randomSeed(analogRead(0));
}
void startSMS()
// function to send a text message
{
digitalWrite(13, HIGH);
cell.println("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS=");
cell.print(34,BYTE); // ASCII equivalent of "
cell.print(mobilenumber);
cell.println(34,BYTE);  // ASCII equivalent of "
delay(500); // give the module some thinking time
}
void endSMS()
{
cell.println(26,BYTE);  // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
digitalWrite(13, LOW);
}
void loop()
{
b=random(0, 99);
for (int a=0; a<100; a++)
{
if (a==b)
{
startSMS();
cell.print("The random number is: ");
cell.print(b);
endSMS();
}
}
do
{
delay(1);
} while (1>0);
}

The result is shown in this quick video:

So now you can see the basic procedure for sending mixed data in a text message. For the purpose of the video, and to save my sanity – the GSM shield’s telephone number is stored as a phone book entry, that is why the sender is shown as Arduino GSM.

Well that is all we have time for in this instalment. Thank you for your patience in awaiting this series of articles. Although getting it together was a little tricky, it was a lot of fun. I hope you enjoyed reading it as much as I did writing it for you.

If you have any questions about the processes or details in this article, please ask in our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, there is the odd competition or give-away –  and we can all learn something.

Otherwise, have fun, stay safe, be good to each other – and make something!