Review – Schmartboard SMT Boards
In this article we review a couple of SMT prototyping boards from Schmartboard.
Introduction
Sooner or later you’ll need to use a surface-mount technology component. Just like taxes and myki* not working, it’s inevitable. When the time comes you usually have a few options – make your own PCB, then bake it in an oven or skillet pan; get the part on a demo board from the manufacturer (expensive); try and hand-solder it yourself using dead-bug wiring or try to mash it into a piece of strip board; or find someone else to do it. Thanks to the people at Schmartboard you now have another option which might cost a few dollars more but guarantees a result. Although they have boards for almost everything imaginable, we’ll look at two of them – one for QFP packages and their Arduino shield that has SOIC and SOP23-6 areas.
QFP 32-80 pin board
In our first example we’ll see how easy it is to prototype with QFP package ICs. An example of this is the Atmel ATmega328 microcontroller found on various Arduino-compatible products, for example:
Although our example has 32 pins, the board can handle up to 80-pin devices. You simply place the IC on the Schmartboard, which holds the IC in nicely due to the grooved tracks for the pins:
The tracks are what makes the Schmartboard EZ series so great – they help hold the part in, and contain the required amount of solder. I believe this design is unique to Schmartboard and when you look in their catalogue, select the “EZ” series for this technology. Moving forward, you just need some water-soluble flux:
then tack down the part, apply flux to the side you’re going to solder – then slowly push the tip of your soldering iron (set to around 750 degrees F) down the groove to the pin. For example:
Then repeat for the three other sides. That’s it. If your part has an exposed pad on the bottom, there’s a hole in the centre of the Schmartboad that you can solder into as well:
After soldering I really couldn’t believe it worked, so probed out the pins to the breakout pads on the Schmartboard to test for shorts or breaks – however it tested perfectly. The only caveat is that your soldering iron tip needs to be the same or smaller pitch than the the part you’re using, otherwise you could cause a solder bridge. And use flux! You need the flux. After soldering you can easily connect the board to the rest of your project or build around it.
Schmartboard Arduino shield
There’s also a range of Arduino shields with various SMT breakout areas, and we have the version with 1.27mm pitch SOIC and a SOT23-6 footprint. SOIC? For example:
This is the AD5204 four-channel digital potentiometer we used in the SPI tutorial. It sits nicely in the shield and can be easily soldered onto the board. Don’t forget the flux! Although the SMT areas have the EZ-technology, I still added a little solder of my own – with satisfactory results:
The SOT23-6 also fits well, with plenty of space for soldering it in. SOT23? Example – the ADS1110 16-bit ADC which will be the subject of a future tutorial:
Working with these tiny components is also feasible but requires a finer iron tip and a steady hand.
Once the SMT component(s) have been fitted, you can easily trace out the matching through-hole pads for further connections. The shield matches the Arduino R3 standards and includes stacking header sockets, two LEDs for general use, space and parts for an RC reset circuit, and pads to add pull-up resistors for the I2C bus:
Finally there’s also three 0805-sized parts and footprints for some practice or use. It’s a very well though-out shield and should prove useful. You can also order a bare PCB if you already have stacking headers to save money.
Conclusion
If you’re in a hurry to prototype with SMT parts, instead of mucking about – get a Schmartboard. They’re easy to use and work well. Full-sized images available on flickr.
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 boards used in this article were a promotional consideration supplied by Schmartboard.
Tutorial: Arduino and the MSGEQ7 Spectrum Analyzer
This is a tutorial on using the MSGEQ7 Spectrum Analyser with Arduino, and chapter forty-eight 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 30/01/2013
In this article we’re going to explain how to make simple spectrum analysers with an Arduino-style board. (Analyser? Analyzer? Take your pick).
First of all, what is a spectrum analyser? Good question. Do you remember what this is?
It’s a mixed graphic equaliser/spectrum analyser deck for a hi-fi system. The display in the middle is the spectrum analyser, and roughly-speaking it shows the strength of different frequencies in the music being listened to – and looked pretty awesome doing it. We can recreate displays similar to this for entertainment and also as a base for creative lighting effects. By working through this tutorial you’ll have the base knowledge to recreate these yourself.
We’ll be using the MSGEQ7 “seven band graphic equaliser IC” from Mixed Signal Integration. Here’s the MSGEQ7 data sheet (.pdf). This little IC can accept a single audio source, analyse seven frequency bands of the audio, and output a DC representation of each frequency band. This isn’t super-accurate or calibrated in any way, but it works. You can get the IC separately, for example:
and then build your own circuit around it… or like most things in the Arduino world – get a shield. In this case, a derivative of the original Bliptronics shield by Sparkfun. It’s designed to pass through stereo audio via 3.5mm audio sockets and contains two MSGEQ7s, so we can do a stereo analyser:
As usual Sparkfun have saved a few cents by not including the stackable header sockets, so you’ll need to buy and solder those in yourself. There is also space for three header pins for direct audio input (left, right and common), which are useful – so if you can add those as well.
So now you have a shield that’s ready for use. Before moving forward let’s examine how the MSGEQ7 works for us. As mentioned earlier, it analyses seven frequency bands. These are illustrated in the following graph from the data sheet:
It will return the strengths of the audio at seven points – 63 Hz, 160 Hz, 400 Hz, 1 kHz, 2.5 kHz, 6.25 kHz and 16 kHz – and as you can see there is some overlap between the bands. The strength is returned as a DC voltage – which we can then simply measure with the Arduino’s analogue input and create a display of some sort. At this point audio purists, Sheldonites and RF people might get a little cranky, so once again – this is more for visual indication than any sort of calibration device.
However as an 8-pin IC a different approach is required to get the different levels. The IC will sequentially give out the levels for each band on pin 3- e.g. 63 Hz then 160 Hz then 400 Hz then 1 kHz then 2.5 kHz then 6.25 kHz then 16 kHz then back to 63 Hz and so on. To start this sequence we first reset the IC by pulsing the RESET pin HIGH then low. This tells the IC to start at the first band. Next, we set the STROBE pin to LOW, take the DC reading from pin 3 with analogue input, store the value in a variable (an array), then set the STROBE pin HIGH. We repeat the strobe-measure sequence six more times to get the rest of the data, then RESET the IC and start all over again. For the visual learners consider the diagram below from the data sheet:
To demonstrate this process, consider the function
readMSGEQ7()
in the following example sketch (download):
// Example 48.1 - tronixstuff.com/tutorials > chapter 48 - 30 Jan 2013 // MSGEQ7 spectrum analyser shield - basic demonstration
int strobe = 4; // strobe pins on digital 4 int res = 5; // reset pins on digital 5
int left[7]; // store band values in these arrays int right[7];
int band;
void setup()
{
Serial.begin(115200);
pinMode(res, OUTPUT); // reset
pinMode(strobe, OUTPUT); // strobe
digitalWrite(res,LOW); // reset low
digitalWrite(strobe,HIGH); //pin 5 is RESET on the shield
}
void readMSGEQ7()
// Function to read 7 band equalizers
{
digitalWrite(res, HIGH);
digitalWrite(res, LOW);
for(band=0; band <7; band++)
{
digitalWrite(strobe,LOW); // strobe pin on the shield - kicks the IC up to the next band
delayMicroseconds(30); //
left[band] = analogRead(0); // store left band reading
right[band] = analogRead(1); // ... and the right
digitalWrite(strobe,HIGH);
}
}
void loop()
{
readMSGEQ7();
// display values of left channel on serial monitor
for (band = 0; band < 7; band++)
{
Serial.print(left[band]);
Serial.print(" ");
}
Serial.println();
// display values of right channel on serial monitor
for (band = 0; band < 7; band++)
{
Serial.print(right[band]);
Serial.print(" ");
}
Serial.println();
}
If you follow through the sketch, you can see that it reads both left- and right-channel values from the two MSGEQ7s on the shield, then stores each value in the arrays left[] and right[]. These values are then sent to the serial monitor for display – for example:
If you have a function generator, connect the output to one of the channels and GND – then adjust the frequency and amplitude to see how the values change. The following video clip is a short demonstration of this – we set the generator to 1 kHz and adjust the amplitude of the signal. To make things easier to read we only measure and display the left channel:
Keep an eye on the fourth column of data – this is the analogRead() value returned by the Arduino when reading the 1khz frequency band. You can also see the affect on the other bands around 1 kHz as we increase and decrease the frequency. However that wasn’t really visually appealing – so now we’ll create a small and large graphical version.
First we’ll use an inexpensive LCD, the I2C model from akafugu reviewed previously. To save repeating myself, also review how to create custom LCD characters from here.
With the LCD with have two rows of sixteen characters. The plan is to use the top row for the levels, the left-channel’s on … the left, and the right on the right. Each character will be a little bar graph for the level. The bottom row can be for a label. We don’t have too many pixels to work with, but it’s a compact example:
We have eight rows for each character, and the results from an analogueRead() fall between 0 and 1023. So that’s 1024 possible values spread over eight sections. Thus each row of pixels in each character will represent 128 “units of analogue read” or around 0.63 V if the Arduino is running from true 5 V (remember your AREF notes?). The sketch will again read the values from the MSGEQ7, feed them into two arrays – then display the required character in each band space on the LCD.
Here’s the resulting sketch (download):
// Example 48.2 - tronixstuff.com/tutorials > chapter 48 - 30 Jan 2013 // MSGEQ7 spectrum analyser shield and I2C LCD from akafugu
// for akafugu I2C LCD #include #include "TWILiquidCrystal.h" LiquidCrystal lcd(50);
// create custom characters for LCD
byte level0[8] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111};
byte level1[8] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111};
byte level2[8] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111};
byte level3[8] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111};
byte level4[8] = { 0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte level5[8] = { 0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte level6[8] = { 0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte level7[8] = { 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
int strobe = 4; // strobe pins on digital 4 int res = 5; // reset pins on digital 5
int left[7]; // store band values in these arrays int right[7];
int band;
void setup()
{
Serial.begin(9600);
// setup LCD and custom characters
lcd.begin(16, 2);
lcd.setContrast(24);
lcd.clear();
lcd.createChar(0,level0); lcd.createChar(1,level1); lcd.createChar(2,level2); lcd.createChar(3,level3); lcd.createChar(4,level4); lcd.createChar(5,level5); lcd.createChar(6,level6); lcd.createChar(7,level7);
lcd.setCursor(0,1);
lcd.print("Left");
lcd.setCursor(11,1);
lcd.print("Right");
pinMode(res, OUTPUT); // reset pinMode(strobe, OUTPUT); // strobe digitalWrite(res,LOW); // reset low digitalWrite(strobe,HIGH); //pin 5 is RESET on the shield }
void readMSGEQ7()
// Function to read 7 band equalizers
{
digitalWrite(res, HIGH);
digitalWrite(res, LOW);
for( band = 0; band < 7; band++ )
{
digitalWrite(strobe,LOW); // strobe pin on the shield - kicks the IC up to the next band
delayMicroseconds(30); //
left[band] = analogRead(0); // store left band reading
right[band] = analogRead(1); // ... and the right
digitalWrite(strobe,HIGH);
}
}
void loop()
{
readMSGEQ7();
// display values of left channel on LCD
for( band = 0; band < 7; band++ )
{
lcd.setCursor(band,0);
if (left[band]>=895) { lcd.write(7); } else
if (left[band]>=767) { lcd.write(6); } else
if (left[band]>=639) { lcd.write(5); } else
if (left[band]>=511) { lcd.write(4); } else
if (left[band]>=383) { lcd.write(3); } else
if (left[band]>=255) { lcd.write(2); } else
if (left[band]>=127) { lcd.write(1); } else
if (left[band]>=0) { lcd.write(0); }
}
// display values of right channel on LCD
for( band = 0; band < 7; band++ )
{
lcd.setCursor(band+9,0);
if (right[band]>=895) { lcd.write(7); } else
if (right[band]>=767) { lcd.write(6); } else
if (right[band]>=639) { lcd.write(5); } else
if (right[band]>=511) { lcd.write(4); } else
if (right[band]>=383) { lcd.write(3); } else
if (right[band]>=255) { lcd.write(2); } else
if (right[band]>=127) { lcd.write(1); } else
if (right[band]>=0) { lcd.write(0); }
}
}
If you’ve been reading through my tutorials there isn’t anything new to worry about. And now for the demo, with sound -
That would look great on the side of a Walkman, however it’s a bit small. Let’s scale it up by using a Freetronics Dot Matrix Display - you may recall these from Clock One. For some background knowledge check the review here. Don’t forget to use a suitable power supply for the DMD – 5 V at 4 A will do nicely. The DMD contains 16 rows of 32 LEDs. This gives us twice the “resolution” to display each band level if desired. The display style is subjective, so for this example we’ll use a single column of LEDs for each frequency band, with a blank column between each one.
We use a lot of line-drawing statements to display the levels, and clear the DMD after each display. With this and the previous sketches, there could be room for efficiency – however I write these with the beginner in mind. Here’s the sketch (download):
// Example 48.3 - tronixstuff.com/tutorials > chapter 48 - 30 Jan 2013 // MSGEQ7 spectrum analyser shield with a Freetronics DMD
// for DMD #include // for DMD #include // SPI.h must be included as DMD is written by SPI (the IDE complains otherwise) #include #include "SystemFont5x7.h" // keep next two lines if you want to add some text #include "Arial_black_16.h" DMD dmd(1, 1); // creates instance of DMD to refer to in sketch
void ScanDMD() // necessary interrupt handler for refresh scanning of DMD
{
dmd.scanDisplayBySPI();
}
int strobe = 4; // strobe pins on digital 4 int res = 5; // reset pins on digital 5
int left[7]; // store band values in these arrays int right[7];
int band;
void setup()
{
// for DMD
//initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
Timer1.initialize( 5000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)
// for MSGEQ7
pinMode(res, OUTPUT); // reset
pinMode(strobe, OUTPUT); // strobe
digitalWrite(res,LOW); // reset low
digitalWrite(strobe,HIGH); //pin 5 is RESET on the shield
}
void readMSGEQ7()
// Function to read 7 band equalizers
{
digitalWrite(res, HIGH);
digitalWrite(res, LOW);
for( band = 0; band < 7; band++ )
{
digitalWrite(strobe,LOW); // strobe pin on the shield - kicks the IC up to the next band
delayMicroseconds(30); //
left[band] = analogRead(0); // store left band reading
right[band] = analogRead(1); // ... and the right
digitalWrite(strobe,HIGH);
}
}
void loop()
{
int xpos;
readMSGEQ7();
dmd.clearScreen( true );
// display values of left channel on DMD
for( band = 0; band < 7; band++ )
{
xpos = (band*2)+1;
if (left[band]>=895) { dmd.drawLine( xpos, 15, xpos, 1, GRAPHICS_NORMAL ); } else
if (left[band]>=767) { dmd.drawLine( xpos, 15, xpos, 3, GRAPHICS_NORMAL ); } else
if (left[band]>=639) { dmd.drawLine( xpos, 15, xpos, 5, GRAPHICS_NORMAL ); } else
if (left[band]>=511) { dmd.drawLine( xpos, 15, xpos, 7, GRAPHICS_NORMAL ); } else
if (left[band]>=383) { dmd.drawLine( xpos, 15, xpos, 9, GRAPHICS_NORMAL ); } else
if (left[band]>=255) { dmd.drawLine( xpos, 15, xpos, 11, GRAPHICS_NORMAL ); } else
if (left[band]>=127) { dmd.drawLine( xpos, 15, xpos, 13, GRAPHICS_NORMAL ); } else
if (left[band]>=0) { dmd.drawLine( xpos, 15, xpos, 15, GRAPHICS_NORMAL ); }
}
// display values of right channel on DMD
for( band = 0; band < 7; band++ )
{
xpos = (band*2)+18;
if (right[band]>=895) { dmd.drawLine( xpos, 15, xpos, 1, GRAPHICS_NORMAL ); } else
if (right[band]>=767) { dmd.drawLine( xpos, 15, xpos, 3, GRAPHICS_NORMAL ); } else
if (right[band]>=639) { dmd.drawLine( xpos, 15, xpos, 5, GRAPHICS_NORMAL ); } else
if (right[band]>=511) { dmd.drawLine( xpos, 15, xpos, 7, GRAPHICS_NORMAL ); } else
if (right[band]>=383) { dmd.drawLine( xpos, 15, xpos, 9, GRAPHICS_NORMAL ); } else
if (right[band]>=255) { dmd.drawLine( xpos, 15, xpos, 11, GRAPHICS_NORMAL ); } else
if (right[band]>=127) { dmd.drawLine( xpos, 15, xpos, 13, GRAPHICS_NORMAL ); } else
if (right[band]>=0) { dmd.drawLine( xpos, 15, xpos, 15, GRAPHICS_NORMAL ); }
}
}
… and here it is in action:
Conclusion
At this point you have the knowledge to use the MSGEQ7 ICs to create some interesting spectrum analysers for entertainment and visual appeal – now you just choose the type of display enjoy the results.
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.
Review: GorillaBuilderz LeoShield
Introduction
Some of you may be using an Arduino Leonardo board, taking advantage of the newer ATmega32U4 microcontroller for various reasons. And rightly so – there’s the extra analogue I/O, virtual USB and the microUSB socket so you can use your phone charger cable. However with the new microcontroller comes a few changes to the board pinouts – I2C and SPI have moved. So if you have a nice Ethernet shield or something using I2C – you’re basically out of luck… until now. The problem has been solved nicely by the team at GorillaBuilderz have created their LeoShield:
Use
You simply place it on the Leonardo, and then the older legacy shield on top. The LeoShield redirects the I2C pins back to A4 and A5, and also sends the SPI lines back to D11~D13. For example, our Ethernet shield:
The ICSP pins are also extended from the Leonardo to the LeoShield, for example:
however when inserting the LeoShield into your Leonardo, take care lining up all the pins before pushing the shield down. There is also the large prototyping area which has 5V , 3.3V and GND rails across the full width for convenience. The sticker on the rear of the shield is to insulate against any large items that may come in contact from the host board, however you can peel it off to realise the complete prototyping space.
Conclusion
It’s simple and it works – so if you need to use an older Arduino shield with a Leonardo the choice is simple – get yourself a Leoshield.
Disclaimer - The Leoshield was a review product received from GorillaBuilderz.
Thanks for reading tronixstuff.com. I’ve got some new tutorials coming up very soon, and a lot of existing posts are curently being updated – so 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
Kit Review – AVR ISP Shield
Introduction
In the last few weeks I needed to flash some ATmega328P microcontrollers with the Arduino bootloader. There are a few ways of doing this, and one method is to use an AVR ISP shield. It’s a simple kit to assemble and use, so let’s have look at the process and results.
As the kit is manufactured by Sparkfun, it arrives in typical minimalist fashion:
The kit includes the following items:
That’s it – no URL to instructions or getting started guide or anything. Luckily we have a bit of knowledge behind us to understand what’s going on. The PCB has all the components as SMT including the status LEDs, so the only soldering required is the shield header pins and the six or ten-connector for the programming cable. You receive enough header pins to fit everything except for both six and ten – you can have one or the other, but not both. Having some handy I thought adding my own socket would be a good idea, however the pins are placed too closed to the group of six, nixing that idea:
Assembly
After collecting all my regular soldering tools and firing up the ‘888 it was time to get to work:
The first thing to fit were the shield headers. A simple way to do this is to break off the required lengths:
… then fit them to a matching board:
… then you place the shield on top and solder the pins. After that I used some of my own headers to fit both six and ten-pin ISP headers – it never hurts to do both, one day you might need them and not have soldering equipment at the ready. Finally the zero-insertion force (ZIF) socket goes in last. Push the lever down so it lays flat before soldering. Then you’re finished:
Operation
Now to program some raw microcontrollers. Insert the shield into your board. We used Arduino IDE v1.0.1 without modifying the original instructions from the Arduino team. Now upload the “ArduinoISP” sketch which is in the Examples menu. Once this has been successful the PLS LED will breathe. You then insert the microcontroller into the ZIF socket and gently pull the lever down. The notch on the microcontroller must be on the right-hand side when looking at the shield. Finally – check the voltage! There is a switch at the bottom-left of the shield that allows 5V or 3.3V. This only changes the Vcc so programming a 3.3V microcontroller will still involve 5V via SPI – possibly causing trouble.
Next you need to select the target board for the microcontroller you’re programming. For example, if it’s going into a Uno – click Uno, even if you’re hosting the shield with an older board such as a Duemilanove. Next, choose the programmer type by selecting Tools > Programmer > Arduino as ISP. Now for the magic – select Tools > Burn bootloader. The process takes around one minute, during which time the “PROG” LED on the shield will blink and flicker. It turns off once finished, and the IDE also notifies you of this. For the curious, the process is in the video below:
As you hopefully noticed earlier a cable is included which allows in-circuit programming from the shield to your existing project or prototype. However we didn’t have use for it at this time, it will come in handy when doing more advanced work later on.
Conclusion
It’s simple and it works. So if you need to flash a whole tube of raw micros with the Arduino bootloader, this is an option. In Australia you can get the kit from Little Bird Electronics. Full-sized images available on flickr. This kit was purchased without notifying the supplier.
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.
Internet-controlled relays with teleduino and Freetronics RELAY8:
This is chapter forty-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 24/11/2012
In this article we’re going to look at controlling relays over the Internet. In doing so you will then be able to turn almost anything on and off as long as you have http access on an Internet-enabled device. Why would you want to do this? Connect an outdoor light – and turn it on before arriving home. Control the power to your TV setup – then you can control childrens’ TV viewing at a whim. Control farm water pumps without getting out of the truck. We’ll break this down into two stages. First we’ll explain how the RELAY8: relay control shield works and control it locally, then control it remotely using the teleduino service. We will be using Arduino IDE v1.0.1.
This tutorial will assume you have an understanding from three other articles – so please have a quick read of I2C bus, the MCP23017 I/O expander and teleduino. But don’t panic – we’ll try and keep it simple here.
The RELAY8: shield
First – our relay shield. We’ll be using the Freetronics RELAY8: shield:
Using the RELAY8: you can control eight relays using the I2C bus and the MCP23017 I/O expander – which saves your digital outputs for other purposes. There are three hardware settings you need to consider when using the shield:
- Power – how will you power the relay coils?
- You can directly connect between 5 and 24V DC using the terminal block on the right-hand side of the shield – great for stronger relay coils.
- You can power the relay coils using power from the Arduino. So whatever power is going to the Arduino Vin can power the shield. To do this jumper the two pins next to the Vin shield connector. In doing so – you must check that the combined current draw of all your relays on at once will not exceed what is available to the Arduino. Usually OK when using solid-state relays, as most examples use around 15mA of current to activate. However double-check your relay specifications before doing so.
- You can also power the Arduino board AND the shield by feeding in external power to the shield and jumpering the two pins described above
- Which I2C address to use for each shield? By default it is 0×20. However you can alter the last three bits of the address by changing the jumpers at the bottom-left of the shield. Each jumper represents one bit of the bus address – no jumper means zero, and a jumper means one. So if you jumper ADDR0, the address will be 0×21 – etc. Using this method you can then stack up to eight shields – and control 64 relays!
- Are you using an Arduino Leonardo board? If so – your shield I2C pins aren’t A4/A5 – they’re over near the top of the board:
However this isn’t a problem. Solder in some header pins to the shield’s SCL/SDA holes (next to AREF). Then turn over the RELAY8: board and you will see some solder pads as shown below. With a thin knife, cut the copper tracks shown with the blue lines:
Doing this will redirect the I2C bus from the microcontroller to the correct pins at the top-left.
Once you have decided on your power and I2C-bus options, it’s time to connect the relays. Doing so is simple, just connect the + and – from the relay coil to the matching position on your RELAY8: shield, for example:
Today we’re just using prototyping wires, so when creating a permanent installation ensure the insulation reaches the terminal block. When working with relays you would use a diode across the coil to take care of back-EMF – however the shield has this circuitry, so you don’t need to worry about that at all. And if you’re wanting to control more than one shield – they stack nicely, with plenty of clearance between shields, for example:
Now to test the shield with a quick demonstration. Our sketch will turn on and off each relay in turn. We use the addressing format described in table 1.4 of the MCP23017 data sheet, The relays 1 to 8 are controlled by “bank A” of the MCP23017 – so we need to set that to output in our sketch, as shown below (download sketch):
// Example 47.1 #include "Wire.h" // for I2C bus #define I2C_ADDR 0x20 // 0x20 is the address with all jumpers removed
void setup()
{
Wire.begin(); // Wake up I2C bus
// Set I/O bank A to outputs Wire.beginTransmission(I2C_ADDR); Wire.write(0x00); // IODIRA register Wire.write(0x00); // Set all of bank A to outputs Wire.endTransmission(); }
int period = 500;
void loop()
{
byte relay = 1;
for (int i=1; i<9; i++)
{
// turn on relay
Wire.beginTransmission(I2C_ADDR);
Wire.write(0x12); // Select bank A
Wire.write(relay); // Send value to bank A
Wire.endTransmission();
delay(period);
// turn off all relays Wire.beginTransmission(I2C_ADDR); Wire.write(0x12); // Select bank A Wire.write(0); // Send value to bank A Wire.endTransmission(); delay(period); relay = relay * 2; // move to next relay } }
The sketch simply sends the values of 1, 2, 4, 8, 16, 32, 64 and 128 to the shield – each value in turn represents relays 1 to 8. We send 0 to turn off all the relays. Here’s a quick video showing it in action – the LEDs on the shield show the relay coil power status:
Now there is one small caveat – every time you send a new command to the MCP23017, it overwrites the status of the whole bank of pins. For example if relay 3 is on, and we send the value 2 – this will turn on relay 2 and turn off 3. Why? Because the values are converted to binary when heading down to the relay shield. So if we send 1, in binary this is:
00000001
which turns on relay 1 – and turns off relays 2 to 7. But then if we send 4 to turn on relay 3, in binary this is:
00000100
which turns on relay 3, but turns off relays 1, 2, and 4 to 8. So how do we turn on or off all eight relays at once? Just do a little binary to decimal conversion. Let’s say you want relays 1, 3, 5 and 7 on – and 2, 4, 6 and 8 off. In binary our command value would be:
01010101
and in decimal this is 85. Want to turn them all on at once? Send 255. Then all off? Send zero.
Now let’s do it via the Internet…
You’re going to need an Ethernet-enabled Arduino board. This could involve adding an Ethernet shield to your existing board, or using an all-in-one board like the Freetronics EtherTen. We will now use the teleduino service created by Nathan Kennedy to send commands to our Arduino boards via the Internet. At this point, please review and understand the teleduino article – then, when you can successfully control a digital output pin – return here to continue.
First, get the hardware together. So ensure your relay shield is in the Arduino and you have uploaded the
TeleduinoEthernetClientProxy.ino
sketch. For the first couple of times, it’s good to still have the teleduino status LED connected – just to keep an eye on it. Plug your Arduino into your router and the power. After it connects to teleduino (four blinks of the status LED) we have to send three commands via http. The first tells teleduino that we’re sending I2C commands. You only do this once after every Arduino reset or power-up situation. It is:
https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999r=defineWire
Remember to replace 999999 with your teleduino key. Then we send:
https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%00%00
At this stage the relay shield is now ready to accept your bytes to turn on and off the outputs. Again, just like the sketch – we send two bytes. For example:
https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%FF
turns on all the outputs – however with the URL we need to send the byte representing the outputs in hexadecimal. So 255 is FF, 0 is 0, etc. For example to turn them all off, use:
https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%00
or to turn on outputs 1, 2, 3 and 4 use:
https://us01.proxy.teleduino.org/api/1.0/328.php?k=999999&r=setWire&address=32&bytes=%12%0F
Simple. You can simply bookmark your URLs for later use as well – and don’t forget to use a URL-shortener such as bit.ly to makes things simpler for you.
Conclusion
Now you have a way to control many relays either locally or remotely over the Internet. I hope you found this article useful or at least interesting. If you have any suggestions for further articles (and not thinly-veiled methods of asking me to do your work for you…) – email them to john at tronixstuff dot com. Thanks to Freetronics for the use of their hardware and Nathan Kennedy for teleduino, his support and advice.
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.
Results – February 2012 Competition
Now that February is over it’s time to announce the lucky winners of our February competition…
Prize One is a brand new Freetronics EtherMega board – the mother of all Arduino-compatible boards. As reviewed recently, the EtherMega combines the power and versatility of the Arduino Mega2560, a microSD card shield, a full Ethernet shield and power over Ethernet support:

Winner of the first prize is Rosemary H from the United Kingdom.
Prize Two is awesome – and a mystery no more. It is the new Freetronics LeoStick:
From the Freetronics website:
The LeoStick is just like the upcoming Arduino Leonardo, but given the “honey, I shrunk the kids” treatment!
Just pop it into your USB port (no cable required!) and upload straight from the Arduino IDE. We’ve even included on-board RGB LED lights and a speaker in this handy sized board. All the usual Arduino pins are present and each LeoStick comes with low profile header sockets for plugging in modules, shields and wires.
Winner of the second prize is Andrian from Moldova. Congratulations to the winners and thanks to everyone for entering.
For the curious, the questions and answers were:
- What frequency crystal would you use with the DS1307 RTC? – 32.768kHz
- How many LEDs are on an EtherMega board? Now I have two answers as the question should have been more specific. There are ten LEDs on the actual PCB, plus two more on the ethernet socket. So we accepted ten or twelve for the answer
- What are the dimensions (length x width) of an 0805 SMT component in mm? – 2.0 x 1.3 mm
- In what year was Ikea founded? – 1943
- What nationality is the Hakko company? Japanese
- Who came up with the name for the device known as the ‘transistor‘? - John R. Pierce
Once again, thanks to Freetronics for the EtherMega and LeoStick prizes!
In the meanwhile, 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.
February 2012 Competition
Update – The competition has now finished, and the winners will be announced shortly…
It’s that time of the month again so we are running another competition. This month we have two prizes. Let’s check those out then follow up with the rules of entry.
Prize One is a brand new Freetronics EtherMega board – the mother of all Arduino-compatible boards. As reviewed recently, the EtherMega combines the power and versatility of the Arduino Mega2560, a microSD card shield, a full Ethernet shield and power over Ethernet support:

From the Freetronics website:
The EtherMega is a 100% Arduino Mega 2560 compatible board that can talk to the world. Do Twitter updates automatically, serve web pages, connect to web services, display sensor data online, and control devices using a web browser. The Freetronics EtherMega uses the same ATmega2560 as the Arduino Mega 2560 so it has masses of RAM, flash memory, and I/O pins, and also includes the same Wiznet W5100 chip used by the official Arduino Ethernet Shield, so it’s 100% compatible with the Ethernet library and sketches.
Any project you would previously have built with an Arduino Mega 2560 and an Ethernet shield stacked together, you can now do all in a single, integrated board. We’ve even added a micro SD card slot so you can store web content on the card, or log data to it. But it gets even better: we found space to squeeze in a small prototyping area, so now it’s possible to build a complete, Internet-enabled Arduino device including your own custom parts all on a single board! You don’t even need to use a prototyping shield for many projects.
Prize Two is awesome – and a mystery no more. It is the new Freetronics LeoStick:
From the Freetronics website:
The LeoStick is just like the upcoming Arduino Leonardo, but given the “honey, I shrunk the kids” treatment!
Just pop it into your USB port (no cable required!) and upload straight from the Arduino IDE. We’ve even included on-board RGB LED lights and a speaker in this handy sized board. All the usual Arduino pins are present and each LeoStick comes with low profile header sockets for plugging in modules, shields and wires.Features of the LeoStick include:
- Native USB port built-in, no need for any USB or FTDI cables
- Two Full Color RGB LEDs on-board! Drive different colored outputs and fun feedback from your sketch right away. One RGB LED is completely programmable, the other does Power, USB RX and TX indication, the RX and TX LEDs can also be controlled.
- On-board Piezo speaker element, play sounds, tunes and beeps. Can also be used as a knock/vibration sensor
- Same I/O pins. The LeoStick provides all the same header connections as larger boards, you can connect all the same sensors, actuators, and other inputs and outputs as typical Arduino models.
- Breadboard compatible, has 0.1″ pitch pads and header pins can be fitted underneath
- 500mA polyfuse and protection on the USB port
- ATmega32U4 microcontroller, Arduino compatible with on-board USB, 32K Flash, 2.5K RAM, 1K EEPROM at 16MHz
- ISP 6-pin connector for advanced programming of the ATmega32U4 MCU
Please note: The LeoStick currently uses a modified beta version of the upcoming Arduino Leonardo bootloader. There are some known issues with Windows 7 64-bit drivers and some library functions don’t work perfectly yet. Any firmware or Arduino Leonardo compatible support should not be considered to be final release firmware or in any way an official Arduino. Don’t hassle the Arduino team with support or requests related to this board: they’re solely our responsibility. The LeoStick is also a very complete ATmega32U4 breakout and USB board by itself and the LeoStick can be programmed directly from the supplied standard ISP header by AVR Studio, Mac OSX-AVR, avrdude, WinAVR etc.
How to enter!
There will be six questions for you to answer spread across articles published between the 1st and 29th of February. So you will need to review older posts. At the end of February and once you have answers to all six questions, email the answers along with your full name, email address and postal address to competition at tronixstuff dot com with the subject heading February.
During the second week of March, all the correct entries will be collated and two randomly chosen. The first correct entry drawn will win first prize, and the second entry the second prize. Entries will be accepted until 03/03/2012 0005h GMT.
As with any other competition, there needs to be some rules:
- Incomplete entries will be rejected, so follow the instructions!
- The winners’ first name and country will be announced publicly;
- The winners’ name and mailing address will be passed to the prize supplier only for the purpose of prize delivery and not for any form of marketing.
- Entries that contain text not suitable for minors or insulting to the competition will be rejected (seriously – it happens);
- Prizes will be delivered via Australia Post domestic or regular international air mail. We take absolutely no responsibility for packages that go missing or do not arrive. If you live in an area with a “less than reliable” domestic postage system, you can pay for registered mail or other delivery service at your expense.
- 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;
- Prizes may take up to 45 days to be received;
- No disputes will be entered in to;
- Prizes carry no warranty nor guarantee – and are to be used or abused at entirely your own risk;
- Entries will be accepted until 03/03/2012 0005h GMT.
Thanks to Freetronics for the EtherMega and LeoStick prizes!
So have fun and keep an eye out for the four competition questions spread through the February posts… In the meanwhile, 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.
Results – January 2012 Competition
Hello Readers
The January 2012 competition has now closed. For the curious, the questions and answers were:
Q – What does the acronym PWM mean?
A – Pulse-width modulation
Q – How many LEDs are contained in the Freetronics DMD?
A – 512
Q – How many digital I/O pins on an Arduino Mega2560?
A – 54
Q – What type of processor core does the PIC32 (from the Uno32 review) use?
A – MIPS (or to be more precise, 32-bit MIPS M4K Core)
Congratulations to Jack M. from the interesting state of South Australia! Jack has won the following prizes:
One v1.0 Akafugu Akafuino-X board as reviewed recently:

Jack’s Akafuino-X will have a companion on its journey which will be the Mayhew Labs “Go Between” Shield, as reviewed recently:

Thanks to Akafugu for offering the Akafuino-X prize!
The February 2012 competition will be announced soon, so in the meanwhile have fun and 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.
January 2012 Competition
Hello Readers
The competition has now ended and the winning entry will be announced shortly. Thank you to all those who entered, and of course to Akafugu for their prize this month.
It’s that time of the month again so we are running another competition. Our prize for this month consists of two items:
One v1.0 Akafugu Akafuino-X board as reviewed recently:

The winner’s Akafuino-X will have a companion on its journey which will be the Mayhew Labs “Go Between” Shield, as reviewed recently:

— *** How to Enter *** —
There will be four questions for you to answer spread across articles published between the 1st and 31st of January. So you will need to review older posts. At the end of January and once you have answers to all four questions, email the answers along with your full name, email address and postal address to competition at tronixstuff dot com with the subject heading January.
During the second week of February, all the correct entries will be collated and one randomly chosen. The first correct entry drawn will win the prize. Entries will be accepted until 03/02/2012 0005h GMT.
As with any other competition, there needs to be some rules:
- Incomplete entries will be rejected, so follow the instructions!
- The winners’ first name and country will be announced publicly;
- Entries that contain text not suitable for minors or insulting to the competition will be rejected (seriously – it happens);
- Prizes will be delivered via Australia Post domestic or regular international air mail. We take absolutely no responsibility for packages that go missing or do not arrive. If you live in an area with a “less than reliable” domestic postage system, you can pay for registered mail or other delivery service at your expense.
- 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;
- Prizes may take up to 45 days to be received;
- No disputes will be entered in to;
- Prizes carry no warranty nor guarantee – and are to be used or abused at entirely your own risk;
- Entries will be accepted until 03/02/2012 0005h GMT.
So have fun and keep an eye out for the four competition questions spread through the January posts… In the meanwhile, 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.
Review: Mayhew Labs “Go Between” Arduino Shield
Hello readers
In this article we examine one of those products that are really simple yet can solve some really annoying problems. It is the “Go Between” Arduino shield from Mayhew Labs. What does the GBS do? You use it to solve a common problem that some prolific Arduino users can often face – how do I use two shields that require the same pins?
Using a clever matrix of solder pads, you can change the wiring between the analogue and digital pins. For example, here is the bare shield:
Now for an example problem. You have two shields that need access to digital pins 3, 4 and 5 as also analogue pins 4 and 5. We call one shield the “top shield” which will sit above the GBS, and the second shield the “bottom” shield which will sit between the Arduino and the GBS. To solve the problem we will redirect the top shield’s D3~5 to D6~8, and A4~5 to A0~1.
To redirect a pin (for example D3 to D6), we first locate the number along the “top digital pins” horizontal of the matrix (3). Then find the destination “bottom” pin row (6). Finally, bridge that pad on the matrix with solder. Our D3 to D6 conversion is shown with the green dot in the following:
Now for the rest, diverting D4 and D5 to D7 and D8 respectively, as well as analogue pins 4 and 5 to 0 and 1:
The next task is to connect the rest of the non-redirected pins. For example, D13 to D13. We do this by again bridging the matching pads:
Finally the sketch needs to be rewritten to understand that the top shield now uses D6~8 and A0~1. And we’re done!
Try not to use too much solder, as you could accidentally bridge more pads than necessary. And you can always use some solder wick to remove the solder and reuse the shield again (and again…). Now the genius of the shield becomes more apparent.
It is a small problem, but one nonetheless. Hopefully this is rectified in the next build run. Otherwise the “Go Between” Shield is a solution to a problem you may have one day, so perhaps keep one tucked away for “just in case”.
While we’re on the subject of Arduino shield pinouts, don’t forget to check out Jon Oxer’s shieldlist.org when researching your next Arduino shield – it is the largest and most comprehensive catalogue of submitted Arduino shields in existence.
[Note - the "Go Between" Shield was purchased by myself personally and reviewed without notifying the manufacturer or retailer]
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.













































