Review – LBE “Magpie” Arduino-compatible board
In this article we review the “Magpie” Arduino Uno-compatible board from Little Bird Electronics.
Introduction
Finally I’m back at the office and have a pile of things to write about. Starting with the subject of this review – the “Magpie” board from Little Bird Electronics in Australia. It seems that a new Arduino-compatible board enters the market every week, thanks to the open-source nature of the platform and the availability of rapid manufacturing. However the Magpie isn’t just any old Arduino Uno knock-off, it has something which helps it stand out from the crowd – status LEDs on every digital and analogue I/O pin. You can see them between the stacking header sockets and the silk-screen labels. For example:
and for the curious, the bottom of the Magpie:
At first glance you might think “why’d they bother doing that? I could just wire up some LEDs myself”. True. However having them on the board speeds up the debugging process as you can see when an output is HIGH or LOW – and in the case of an input pin, whether a current is present or not. For the curious the LEDs are each controlled by a 2N7002 MOSFET with the gate connected to the I/O pin, for example:
An LED will illuminate as long as the gate voltage is higher than the threshold voltage – no matter the status of the particular I/O pin. And if an I/O pin is left floating it may trigger the LED if the threshold voltage is exceeded at the gate. Therefore when using the Magpie it would be a good idea to set all the pins to LOW that aren’t required for your particular sketch. Even if you remove and reapply power the floating will still be prevalent, and indicated visually – for example:
Nevertheless you can sort that out in void setup(), and then the benefits of the LEDs become apparent. Consider the following quick demonstration sketch:
// LBE Magpie board LED demo - John Boxall 18 March 2013
// usual blink delay period
int d=100;
void setup()
{
// digital pins to outputs
for (int a=0; a<14; a++)
{
pinMode(a, OUTPUT);
}
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
}
void allOn()
// all LEDs on
{
for (int a=0; a<14; a++)
{
digitalWrite(a, HIGH);
}
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A4, HIGH);
digitalWrite(A5, HIGH);
}
void allOff()
// all LEDs on
{
for (int a=0; a<14; a++)
{
digitalWrite(a, LOW);
}
digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
digitalWrite(A2, LOW);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, LOW);
}
void clockWise(int r, int s)
// blinks on and off each LED clockwise
// r - # rotations, s - blink delay
{
allOff();
for (int a=0; a<r; a++)
{
for (int b=13; b>=0; --b)
{
digitalWrite(b, HIGH);
delay(s);
digitalWrite(b, LOW);
}
digitalWrite(A5, HIGH);
delay(s);
digitalWrite(A5, LOW);
digitalWrite(A4, HIGH);
delay(s);
digitalWrite(A4, LOW);
digitalWrite(A3, HIGH);
delay(s);
digitalWrite(A3, LOW);
digitalWrite(A2, HIGH);
delay(s);
digitalWrite(A2, LOW);
digitalWrite(A1, HIGH);
delay(s);
digitalWrite(A1, LOW);
digitalWrite(A0, HIGH);
delay(s);
digitalWrite(A0, LOW);
delay(s);
}
}
void anticlockWise(int r, int s)
// blinks on and off each LED anticlockwise
// r - # rotations, s - blink delay
{
allOff();
for (int a=0; a<r; a++)
{
for (int b=0; b<14; b++)
{
digitalWrite(b, HIGH);
delay(s);
digitalWrite(b, LOW);
}
digitalWrite(A0, HIGH);
delay(s);
digitalWrite(A0, LOW);
digitalWrite(A1, HIGH);
delay(s);
digitalWrite(A1, LOW);
digitalWrite(A2, HIGH);
delay(s);
digitalWrite(A2, LOW);
digitalWrite(A3, HIGH);
delay(s);
digitalWrite(A3, LOW);
digitalWrite(A4, HIGH);
delay(s);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
delay(s);
digitalWrite(A5, LOW);
delay(s);
}
}
void loop()
{
anticlockWise(3,50);
clockWise(3,50);
for (int z=0; z<4; z++)
{
allOn();
delay(100);
allOff();
delay(100);
}
}
… and the results are demonstrated in the following video:
Apart from the LEDs the Magpie offers identical function to that of an Arduino Uno R2 – except the USB microcontroller is an Atmel 16U2 instead of an 8U2, and the USB socket is a mini-USB and not the full-size type. For the curious you can download the Magpie design files from the product page.
Conclusion
If you’re often experimenting or working with the Arduino’s I/O pins and find yourself wiring up LEDs for testing purposes – the Magpie was made for you. Having those LEDs on the board really does save you if in a hurry to test or check something.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
The Magpie board used in this article was a promotional consideration supplied by Little Bird Electronics.
Introducing Goldilocks – the Arduino Uno-compatible with 1284p and uSD card
[Update 19/03/2013 - the project is now fully funded. When the boards arrive we'll do a full review]
Introduction
It’s a solid fact that there are quite a few variations on the typical Arduino Uno-compatible board. You can get them with onboard wireless, GSM, Zigbee and more – however all with their own issues and specific purposes. But what if you wanted a board that was physically and electrically compatible with an Arduino Uno – but with much more SRAM, more EEPROM, more flash, more speed – and then some? Well that (hopefully) will be a possibility with the introduction of the “Goldilocks” board on Pozible by Phillip Stevens.
What’s Pozible?
Pozible is the Australian version of Kickstarter. However just like KS anyone with a credit card or PayPal can pledge and support projects.
What’s a Goldilocks board?
It’s a board based around the Atmel ATmega1284p microcontroller in an Arduino Uno-compatible physical board with a microSD card socket and a few extras. The use of the ’1284p gives us the following advantages over the Arduino Uno, including:
- 16 kByte SRAM = 8x Uno SRAM – so that’s much more space for variables used in sketches – great for applications that use larger frame buffers such as Ethernet and image work;
- 2 kByte EEPROM = 2 x Uno EEPROM – giving you more space for non-volatile data storage on the main board;
- 128 kByte flash memory = 4 x Uno – giving you much, much more room for those larger sketches;
- Two programmable USARTS – in other words, two hardware serial ports – no mucking about with SoftwareSerial and GSM or GPS shields;
- Timer 3 – the ’1284p microcontroller has an extra 16-bit timer – timer 3, that is not present on any other ATmega microcontroller. Timer 3 does not have PWM outputs (unlike Timer 0, Timer 1, and Timer 2), and therefore is free to use as a powerful internal Tick counter, for example in a RTOS. freeRTOS has already been modified to utilise this Timer 3;
- JTAG interface – yes – allowing more advanced developers the opportunity to debug their code;
- better PWM access – the 1284p brings additional 8-bit Timer 2 PWM outputs onto PD, which creates the option for 2 additional PWM options on this port. It also removes the sharing of the important 16-bit PWM pins with the SPI interface, by moving them to PD4 & PD5, thus simplifying interface assignments;
- Extra I/O pins – the 1284p has additional digital I/O pins on the PB port. These pins could be utilised for on-board Slave Select pins (for example), without stealing on-header digital pins and freeing the Arduino Pin 10 for Shield SPI SS use exclusively;
Furthermore the following design improvements over an Arduino Uno:
- adding through-holes for all I/O – allowing you to solder directly onto the board whilst keeping header sockets;
- replicate SPI and I2C for ease of use;
- microSD card socket – that’s a no-brainer;
- link the ATmega16u2 and ATmega1284p SPI interfaces – this will allow the two devices to work in concert for demanding multi-processing applications, involving USB and other peripherals;
- Fully independent analogue pins, including seperate AVCC and GND – helps reduce noise on the ADC channels for improved analogue measurement accuracy;
- move the reset button to the edge of the board – another no-brainer
- clock the board at 20 MHz – that’s an extra 4 MHz over a Uno. And the use of a through hole precision crystal (not a SMD resonator) allows the use of after market timing choices, eg 22.1184 MHz for more accurate UART timings.
What does it look like?
At the moment the board mock-up looks like this:
If funding is successful (and we hope it will be) the Goldilocks will be manufactured by the team at Freetronics. Apart from being a world-leader in Arduino-compatible hardware and systems, they’re the people behind the hardware for Ardusat and more – so we know the Goldilocks will be in good hands.
Will it really be compatible?
Yes – the Goldilocks will be shipped pre-programmed with an Arduino compatible boot-loader, and the necessary Board description files will be available to provide a 100% compatible Arduino IDE experience.
Conclusion
If you think this kind of board would be useful in your projects, you want to support a good project – or both, head over to Pozible and make your pledge. And for the record – I’ve put my money where my mouth is
Please note that I’m not involved in nor responsible for the Goldilocks project, however I’m happy to promote it as a worthwhile endeavour. 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.
Exploring the TI Stellaris platform with Energia Arduino-compatible IDE
Introduction
In the same manner as their MSP430 development board, Texas Instruments also have another LaunchPad board with their powerful Stellaris LM4F120H5QR microcontroller. It’s an incredibly powerful and well-featured MCU – which offers an 80 MHz, 32-bit ARM Cortex-M4 CPU with floating point, 256 Kbytes of 100,000 write-erase cycle FLASH and many peripherals such as 1MSPS ADCs, eight UARTs, four SPIs, four I2Cs, USB & up to 27 timers, some configurable up to 64-bits.
That’s a bucket of power, memory and I/O for not much money – you can get the LaunchPad board for around $15. This LaunchPad has the in-circuit debugger, two user buttons, an RGB LED and connectors for I/O and shield-like booster packs:
However the good news as far as we’re concerned is that you can now use it with the Energia Arduino-compatible IDE that we examined previously. Before rushing out to order your own Stellaris board, install Energia and examine the available functions and libraries to make sure you can run what you need. And if so, you’re set for some cheap Arduino power.
Installation
Installation is simple, just get your download from here. If you’re running Windows 7 – get the USB drivers from here. When you plug your LaunchPad into the USB for the first time, wait until after Windows attempts to install the drivers, then install drivers manually after download via Device manager … three times (JTAG, virtual serial port and DFU device). Use the debug USB socket (and set the switch to debug) when installing and uploading code. If you get the following warning from Windows, just click “Install this driver software anyway”:
Once the drivers are installed, plug in your LaunchPad, wait a moment – then run Energia. You can then select your board type and serial port just like the Arduino IDE. Then go ahead and upload the “blink” example…
Awesome – check out all that free memory space. In the same manner as the MSP430, there are some hardware<>sketch differences you need to be aware of. For example, how to refer to the I/O pins in Energia? A map has been provided for front:
… and back:
As you can imagine, the Stellaris MCUs are different to an AVR, so a lot of hardware-specific code doesn’t port over from the world of Arduino. One of the first things to remember is that the Stellaris is a 3.3V device. Code may or may not be interchangeable, so a little research will be needed to match up the I/O pins and rewrite the sketch accordingly. For example, instead of digital pins numbers, you use PX_Y - see the map above. So let’s say you want to run through the RGB LED… consider the following sketch:
int wait = 500;
void setup()
{
// initialize the digital pin as an output.
pinMode(PF_1, OUTPUT); // red
pinMode(PF_3, OUTPUT); // green
pinMode(PF_2, OUTPUT); // blue
}
void loop()
{
digitalWrite(PF_1, HIGH);
delay(wait);
digitalWrite(PF_1, LOW);
digitalWrite(PF_3, HIGH);
delay(wait);
digitalWrite(PF_3, LOW);
digitalWrite(PF_2, HIGH);
delay(wait);
digitalWrite(PF_2, LOW);
}
Which simply blinks the red, green and blue LED elements in series. Using digital inputs is in the same vein, and again the buttons are wired so when pressed they go LOW. An example of this in the following sketch:
void setup()
{
// initialize the digital pins
pinMode(PF_1, OUTPUT); // red
pinMode(PF_3, OUTPUT); // green
pinMode(PF_2, OUTPUT); // blue
pinMode(PF_4, INPUT_PULLUP); // left - note _PULLUP
pinMode(PF_0, INPUT_PULLUP); // right - note _PULLUP
}
void blinkfast()
{
for (int i=0; i<10; i++)
{
digitalWrite(PF_1, HIGH);
delay(250);
digitalWrite(PF_1, LOW);
digitalWrite(PF_3, HIGH);
delay(250);
digitalWrite(PF_3, LOW);
digitalWrite(PF_2, HIGH);
delay(250);
digitalWrite(PF_2, LOW);
}
}
void blinkslow()
{
for (int i=0; i<5; i++)
{
digitalWrite(PF_1, HIGH);
delay(1000);
digitalWrite(PF_1, LOW);
digitalWrite(PF_3, HIGH);
delay(1000);
digitalWrite(PF_3, LOW);
digitalWrite(PF_2, HIGH);
delay(1000);
digitalWrite(PF_2, LOW);
}
}
void loop()
{
if (digitalRead(PF_4)==LOW) { blinkslow(); }
if (digitalRead(PF_0)==LOW) { blinkfast(); }
}
And for the non-believers:
Where to from here?
Sometimes you can be platform agnostic, and just pick something that does what you want with the minimum of time and budget. Or to put it another way, if you need a fast CPU and plenty of space but couldn’t be bothered don’t have time to work with Keil, Code Composer Studio, IAR etc – the Energia/Stellaris combination could solve your problem. There’s a growing Energia/Stellaris forum, and libraries can be found here. At the time of writing we found an I2C library as well.
However to take full advantage of the board, consider going back to the TI tools and move forward with them. You can go further with the tutorials and CCS etc from Texas Instruments own pages.
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.
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
Exploring the TI MSP430 platform with Energia Arduino-compatible IDE
Introduction
Over the last year or so Texas Instruments have been literally pushing their MSP430 development platform hard by offering an inexpensive development kit – their LaunchPad. For around ten dollars (not everyone could get it for $4.30) it includes a development board with flash emulation tool and USB interface, two of their microcontrollers, crystal, USB cable and some headers. It was (is?) a bargain and tens of thousands of LaunchPads were sold. Happy days.
However after the courier arrived and the parcel was opened, getting started with the LaunchPad was an issue for some people. Not everyone has been exposed to complex IDEs or university-level subjects on this topic. And to get started you needed to use a version of Code Composer Studio or IAR Embedded Workbench IDEs, which scared a few people off. So those LaunchPads went in the cupboard and gathered dust.
Well now it’s time to pull them out, as there’s a new way to program the MSP430 using a fork of the Arduino IDE – Energia. Put simply, it’s the Arduino IDE modified to compile and upload code to the LaunchPad, which makes this platform suddenly much more approachable.
Getting Started
You’ll need to download and install the appropriate USB drivers, then the IDE itself from here. To install the IDE you just download and extract it to your preferred location, in the same manner as the Arduino IDE. Then plug your LaunchPad into the USB. Finally, load the IDE. Everything is familiar to the Arduino user, except the only surprise is the colour (red as a nod to TI perhaps…):

Looking good so far. All the menu options are familiar, the files have the .ino extension, and the preferences dialogue box is how we expect it. Don’t forget to select the correct port using the Tools > Serial port… menu. You will also need to select the type of MSP430 in your LaunchPad. At the time of writing there is support for three types listed below (and the first two are included with the LaunchPad v1.5):
- MSP430G2553 - <=16 MHz, 16KB flash, 512b SRAM, 24 GPIO, two 16-bit timers, UART, SPI, I2C, 8 ADC channels at 10-bit, etc. Cost around Au$3.80 each**
- MSP430G2452 - <=16 MHz, 8KB flash, 256b SRAM, 16 GPIO, one 16-bit timer, UART, I2C, 8 ADC channels, etc. Cost around Au$2.48 each**
- MSP430G2231 - <=16 MHz, 2KB flash, 128b SRAM, 10 GPIO, one 16-bit timer, SPI, I2C, 8 ADC channels, etc. Cost around Au$3.36 each**
** One-off ex-GST pricing from element14 Australia. In some markets it would be cheaper to buy another LaunchPad. TI must really be keen to get these in use.
There are some hardware<>sketch differences you need to be aware of. For example, how to refer to the I/O pins in Energia? A map has been provided for each MSP430 at the Energia wiki, for example the G2553:
As you can imagine, MSP430s are different to an AVR, so a lot of hardware-specific code doesn’t port over from the world of Arduino. One of the first things to remember is that MSP430s are 3.3V devices. Code may or may not be interchangeable, so a little research will be needed to match up the I/O pins and rewrite the sketch accordingly. You can refer to pins using the hardware designator on the LaunchPad (e.g. P1_6) or the physical pin number. For example – consider the following sketch:
void setup() {
// initialize the digital pins as an output.
pinMode(P1_0, OUTPUT); // LED 1
pinMode(P1_6, OUTPUT); // LED 2
}
void loop() {
digitalWrite(P1_6, HIGH);
digitalWrite(P1_0, HIGH);
delay(100);
digitalWrite(P1_6, LOW);
digitalWrite(P1_0, LOW);
delay(100);
}
You could have used 2 (for physical pin 2) instead of P1_0 and 14 (physical pin … 14!) instead of P1_6. It’s up to you. Another quick example is this one – when the button is pressed, the LEDs blink a few times:
const int redLED = P1_0; const int greenLED = P1_6; const int button = P1_3; // button S2 (on the left)
int a = 0;
void setup()
{
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(button, INPUT_PULLUP); // note _PULLUP
digitalWrite(redLED, LOW);
digitalWrite(greenLED, LOW);
}
void loop()
{
if (digitalRead(button)==LOW)
{
for (a=0; a<10; a++)
{
digitalWrite(redLED, HIGH);
digitalWrite(greenLED, LOW);
delay(200);
digitalWrite(redLED, LOW);
digitalWrite(greenLED, HIGH);
delay(200);
}
digitalWrite(redLED, LOW);
digitalWrite(greenLED, LOW);
}
}
Due to the wiring of the LaunchPad, when you press the button, P1_3 is pulled LOW. For the non-believers, here it is in action:
So where to from here? There are many examples in the Energia IDE example menu, including some examples for the Energia libraries. At the time of writing there is: Servo, LiquidCrystal, IRremote, SPI, wire, MSPflash and Stepper. And as the Energia project moves forward more may become available. For help and discussion, head over to the 4-3-Oh forum and of course the Energia website. And of course there’s the TI MSP430 website.
Conclusion
Well that was interesting to say the least. If you have a project which needs to be low-cost, fits within the specifications of the MSP430, has a library, you’re not hung up on brand preference, and you just want to get it done – this is a viable option. Hopefully after time some of you will want to work at a deeper level, and explore the full IDEs and MSP430 hardware available from TI. But for the price, don’t take my word for it – try it yourself.
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.
Arduino, Android and Seeedstudio Bluetooth Bee
Introduction
In this article we examine the Seeedstudio ”Bluetooth Bee“ modules and how they can be used in a simple way in conjunction with Android devices to control the Arduino world. Here is an example of a Bluetooth Bee:
For the curious, the hardware specifications are as follows:
- Typical -80dBm sensitivity
- Up to +4dBm RF transmit power
- Fully Qualified Bluetooth V2.0+EDR 3Mbps Modulation
- Low Power 1.8V Operation, 1.8 to 3.6V I/O
- UART interface with programmable baud rate
- Integrated PCB antenna.
- XBee compatible headers
You may have noticed that the Bluetooth Bee looks similar to the Xbee-style data transceivers – and it is, in physical size and some pinouts, for example:
The neat thing with the BtB (Bluetooth Bee) is that it is compatible with Xbee sockets and Arduino shields. It is a 3.3V device and has the same pinouts for Vcc, GND, TX and RX – so an existing Xbee shield will work just fine.
In some situations you may want to use your BtB on one UART and have another for debugging or other data transport from an Arduino – which means the need for a software serial port. To do this you can get a “Bees Shield” which allows for two ‘Bee format transceivers on one board, which also has jumpers to select software serial pins for one of them. For example:
Although not the smallest, the Bees Shield proves very useful for experimenting and busy wireless data transmit/receive systems. More about the Bees Shield can be found on their product wiki.
Quick Start
In the past many people have told me that bluetooth connectivity has been too difficult or expensive to work with. In this article I want to make things as simple as possible, allowing you to just move forward with your ideas and projects. One very useful function is to control an Arduino-compatible board with an Android-based mobile phone that has Bluetooth connectivity. Using the BtB we can create a wireless serial text bridge between the phone and the Arduino, allowing control and data transmission between the two.
We do this by using a terminal application on the Android device – for our examples we will be using “BlueTerm” which can be downloaded from Google Play – search for “blueterm” as shown below:
In our Quick Start example, we will create a system where we can turn on or off four Arduino digital output pins from D4~D7. (If you are unsure about how to program an Arduino, please consider this short series of tutorials). The BtB is connected using the Bees shield. This is based on the demonstration sketch made available on the BtB Wiki page - we will use commands from the terminal on the Android device to control the Arduino board, which will then return back status.
As the BtB transmit and receive serial data we will have it ‘listen’ to the virtual serial port on pins 9 and 10 for incoming characters. Using a switch…case function it then makes decisions based on the incoming character. You can download the sketch from here. It is written for Arduino v23. If you were to modify this sketch for your own use, study the void loop() section to see how the incoming data is interpreted, and how data is sent back to the Android terminal using blueToothSerial.println.
/* BluetoothBee Demo Code - Flowcontrol Based Implementation 2010,2011 Copyright (c) Seeed Technology Inc. All right reserved. Author: Visweswara R Modified: John Boxall, April 2012 This demo code is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA For more details about the product please check http://www.seeedstudio.com/depot/ */
#include <NewSoftSerial.h> //Software Serial Port #define RxD 9 #define TxD 10 #define DEBUG_ENABLED 1
NewSoftSerial blueToothSerial(RxD,TxD); char incoming;
void setup()
{
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}
void setupBlueToothConnection()
{
blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
delay(1000);
sendBlueToothCommand("\r\n+STWMOD=0\r\n");
sendBlueToothCommand("\r\n+STNA=SeeeduinoBluetooth\r\n");
sendBlueToothCommand("\r\n+STAUTO=0\r\n");
sendBlueToothCommand("\r\n+STOAUT=1\r\n");
sendBlueToothCommand("\r\n +STPIN=0000\r\n");
delay(2000); // This delay is required.
sendBlueToothCommand("\r\n+INQ=1\r\n");
delay(2000); // This delay is required.
}
//Checks if the response "OK" is received
void CheckOK()
{
char a,b;
while(1)
{
if(blueToothSerial.available())
{
a = blueToothSerial.read();
if('O' == a)
{
// Wait for next character K. available() is required in some cases, as K is not immediately available.
while(blueToothSerial.available())
{
b = blueToothSerial.read();
break;
}
if('K' == b)
{
break;
}
}
}
}
while( (a = blueToothSerial.read()) != -1)
{
//Wait until all other response chars are received
}
}
void sendBlueToothCommand(char command[])
{
blueToothSerial.print(command);
CheckOK();
}
void loop()
{
// get character sent from Android device
incoming=blueToothSerial.read();
// decide what to do with it
switch (incoming)
{
case '1':
digitalWrite(4, HIGH);
blueToothSerial.println("pin 4 HIGH");
break;
case '2':
digitalWrite(5, HIGH);
blueToothSerial.println("pin 5 HIGH");
break;
case '3':
digitalWrite(6, HIGH);
blueToothSerial.println("pin 6 HIGH");
break;
case '4':
digitalWrite(7, HIGH);
blueToothSerial.println("pin 7 HIGH");
break;
case '5':
digitalWrite(4, LOW);
blueToothSerial.println("pin 4 LOW");
break;
case '6':
digitalWrite(5, LOW);
blueToothSerial.println("pin 5 LOW");
break;
case '7':
digitalWrite(6, LOW);
blueToothSerial.println("pin 6 LOW");
break;
case '8':
digitalWrite(7, LOW);
blueToothSerial.println("pin 7 LOW");
break;
}
delay(100);
}
Before using it for the first time you will need to pair the BtB with your Android device. The PIN is set to a default of four zeros. After setting up the hardware and uploading the sketch, wait until the LEDs on the BtB blink alternately – at this point you can get a connection and start communicating. In the following video clip you can see the whole process:
Where to from here?
There are many more commands that can be set using terminal software from a PC with a Bluetooth adaptor, such as changing the PIN, device name and so on. All these are described in the BtB Wiki page along with installation instructions for various operating systems.
Once again I hope you found this article interesting and useful. The Bluetooth Bees are an inexpensive and useful method for interfacing your Arduino to other Bluetooth-compatible devices. For more information and product support, visit the Seeedstudio product pages.
Bluetooth Bees are available from Seeedstudio and their network of distributors.
Disclaimer - Bluetooth Bee products used in this article are promotional considerations made available by Seeedstudio.
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.
RF Wireless Data with the Seeedstudio RFbee
Introduction
In this article we examine the Seeedstudio RFbee Wireless Data Transceiver nodes. An RFbee is a small wireless data transceiver that can be used as a wireless data bridge in pairs, as well as a node in mesh networking or data broadcasting. Here is an example of an RFbee:
You may have noticed that the RFbee looks similar to the Xbee-style data transceivers – and it is, in physical size and some pinouts, for example:
However this is where the similarity ends. The RFbee is in fact a small Arduino-compatible development board based on the Atmel ATmega168 microprocessor (3.3V at 8MHz – more on this later) and uses a Texas Instruments CC1101 low-power sub1-GHz RF transceiver chip for wireless transfer. Turning over an RFbee reveals this and more:
But don’t let all this worry you, the RFbee is very simple to use once connected. As a transceiver the following specifications apply:
- Data rate – 9600, 19200, 38400 or 115200bps
- Adjustable transmission power in stages between -30dBm and 10 dBm
- Operating frequency switchable between 868MHz and 915MHz
- Data transmission can be point-to-point, or broadcast point-to-many
- Maximum of 256 RFbees can operate in one mesh network
- draws only 19.3mA whilst transmitting at full power
The pinout for the RFbee are similar to those of an Xbee for power and data, for example:
There is also the ICSP pins if you need to reprogram the ATmega168 direcly with an AVRISP-type programmer.
Getting Started
Getting started is simple – RFbees ship with firmware which allows them to simply send and receive data at 9600bps with full power. You are going to need two or more RFbees, as they can only communicate with their own kind. However any microcontroller with a UART can be used with RFbees – just connect 3.3V, GND, and the microcontroller’s UART TX and RX to the RFbee and you’re away. For our examples we will be using Arduino-compatible boards. If Arduino is new to you, consider our tutorials first.
If you ever need to update the firmware, or reset the RFbee to factory default after some wayward experimenting – download the firmware which is in the form of an Arduino sketch (RFBee_v1_1.pde) which can be downloaded from the repository. (This has been tested with Arduino v23). In the Arduino IDE, set the board type to “Arduino Pro or Pro Mini (3.3V, 8MHz) w/ATmega168″. From a hardware perspective, the easiest way to update the firmware is via a 3.3V FTDI cable or an UartSBee board, such as:
You will also find a USB interface useful for controlling your RFbee via a PC or configuration (see below). In order to do this, you will need some basic terminal software. A favourite and simple example is called … “Terminal“. (Please donate to the author for their efforts).
Initial Testing
After connecting your RFbee to a PC, run your terminal software and set it for 9600 bps – 8 – None – no handshaking, and click the check box next to “+CR”. For example (click to enlarge):
Select your COM: port (or click “ReScan” to find it) and then “Connect”. After a moment “OK” should appear in the received text area. Now, get yourself an Arduino or compatible board of some sort that has the LED on D13 (or substitute your own) and upload the following sketch:
// RFbee demonstration sketch
int ledPin = 13; byte incoming=0;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void blinkLED(int i)
{
for (int a=0; a<i; a++)
{
digitalWrite(ledPin, HIGH);
delay(250);
digitalWrite(ledPin, LOW);
delay(250);
}
}
void loop()
{
if (Serial.available() > 0)
{
incoming = Serial.read();
switch(incoming)
{
case 'A':
blinkLED(1);
break;
case 'B':
blinkLED(2);
break;
case 'C':
blinkLED(3);
break;
default:
blinkLED(5);
}
Serial.println("Blinking completed!");
delay(2000);
Serial.flush();
}
}
Finally, connect the Arduino board to an RFbee in this manner:
- Arduino D0 to RFbee TX
- Arduino D1 to RFbee RX
- Arduino 3.3V to RFbee Vcc
- Arduino GND to RFbee GND
Although that was a very simple demonstration, in doing so you can prove that your RFbees are working and can send and receive serial data. If you need more than basic data transmission, it would be wise to get a pair of RFbees to experiment with before committing to a project, to ensure you are confident they will solve your problem.
More Control
If you are looking to use your RFbees in a more detailed way than just sending data at 9600 bps at full power, you will need to control and alter the parameters of your RFbees using the terminal software and simple AT-style commands. If you have not already done so, download and review the RFbee data sheet downloadable from the “Resources” section of this page. You can use the AT commands to easily change the data speed, power output (to reduce current draw), change the frequency, set transmission mode (one way or transceive) and more.
Reading and writing AT commands is simple, however at first you need to switch the RFbee into ‘command mode’ by sending +++ to it. (When sending +++ or AT commands, each must be followed with a carriage return (ASCII 13)). Then you can send commands or read parameter status. To send a command, just send AT then the command then the parameter. For example, to set the data rate (page ten of the data sheet) to 115200 bps, send ATBD3 and the RFbee will respond with OK.
You can again use the terminal software to easily send and receive the commands. To switch the RFbee from command mode back to normal data mode, use ATO0 (that’s AT then the letter O then zero) or power-cycle the RFbee.
RFbee as an Arduino-compatible board with inbuilt wireless
As mentioned previously the RFbee is based around an Atmel ATmega168 running at 8MHz with the Arduino bootloader. In other words, we have a tiny Arduino-compatible board in there to do our bidding. If you are unfamiliar with the Arduino system please see the tutorials listed here. However there are a couple of limitations to note – you will need an external USB-serial interface (as noted in Getting Started above), and not all the standard Arduino-type pins are available. Please review page four of the data sheet to see which RFbee pins match up to which Arduino pins.
If for some reason you just want to use your RFbee as an Arduino-compatible board, you can do so. However if you upload your own sketch you will lose the wireless capability. To restore your RFbee follow the instructions in Getting Started above.
The firmware that allows data transmission is also an Arduino sketch. So if you need to include RF operation in your sketch, first use a copy of the RFBee_v1_1.pde included in the repository – with all the included files. Then save this somewhere else under a different name, then work your code into the main sketch. To save you the effort you can download a fresh set of files which are used for our demonstration. But before moving forward, we need to learn about controlling data flow and device addresses…
Controlling data flow
As mentioned previously, each RFbee can have it’s own numerical address which falls between zero and 255. Giving each RFbee an address allows you to select which RFbee to exchange data with when there is more than two in the area. This is ideal for remote control and sensing applications, or to create a group of autonomous robots that can poll each other for status and so on.
To enable this method of communication in a simple form several things need to be done. First, you set the address of each RFbee with the AT command ATMAx (x=address). Then set each RFbee with ATOF2. This causes data transmitted to be formatted in a certain method – you send a byte which is the address of the transmitting RFbee, then another byte which is the address of the intended receipient RFbee, then follow with the data to send. Finally send command ATAC2 – which enables address checking between RFbees. Data is then sent using the command
transmitData(*byte data, byte length, byte sourceAddress, byte destinationAddress)
Where data is … the data to send. You can send a single byte, or an array of bytes. length is the number of bytes you are sending. sourceAddress and destinationAddress are relevant to the RFbees being used – you set these addresses using the ATMAx described earlier in this section.
If you open the file rfbeewireless.pde in the download bundle, scroll to the end of the sketch which contains the following code:
byte testData[4] = {'A','B','C','D'};
void sendTestData()
{
// send the four bytes of data in the byte testData[] from address 1 to address 2
transmitData(testData,4,1,2);
delay(1000);
}
This is a simple example of sending data out from the RFbee. The RFbee with this sketch (address 1) sends the array of bytes (testdata[]) to another RFbee with address 2. You can disable address checking by a receiving RFbee with ATAC0 – then it will receive any data send by other RFbees.
To receive data use the following function:
result=receiveData(rxData, &len, &sourceAddress, &destinationAddress, (byte *)&rssi , &lqi);
The variable result will hold the incoming data, len is the number of bytes to expect, sourceAddress and destinationAddress are the source (transmitting RFbee) and destination addresses (receiving RFbee). rssi and lqi are the signal strength and link quality indicator – see the TI CC1101 datasheet for more information about these. By using more than two RFbees set with addresses you can selectively send and receive data between devices or control them remotely. Finally, please note that RFbees are still capable of sending and receiving data via the TX/RX pins as long as the sketch is not executing the sendTestData() loop.
I hope you found this introduction interesting and useful. The RFbees are an inexpensive and useful alternative to the popular Xbee modules and with the addition of the Arduino-compatible board certainly useful for portable devices, remote sensor applications or other data-gathering exercises.
For more information and product support, visit the Seeedstudio product pages.
RFbees are available from Seeedstudio and their network of distributors.
Disclaimer - RFbee products used in this article are promotional considerations made available by Seeedstudio.
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.
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.
Is this the world’s smallest Arduino-compatible board?
Introducing the Freetronics LeoStick – one very small Arduino Leonardo-compatible** board, in the format of a typical USB memory stick – the board for integration into smaller projects, on-the-go fun when travelling, or minimalism-enthusiasts:
Whether or not the LeoStick is the world’s smallest Arduino-compatible board – it’s pretty darn tiny – for example:
Note that the length includes the USB plug extrusion on the PCB. A lot of small boards on the market may consider themselves to be fully Arduino-compatible, but with a few minor or major caveats – such as not having full USB interface, or using a cut-down MCU such as an ATtiny, or offer less current handling ability. After comparing their specifications with the LeoStick, you can see how much has gone into such a small board:
- 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
Here is the underside of the LeoStick , showing the piezo speaker:
And here is a quick video of the LeoStick in action:
** Although this is a newly-released product, it does rely on 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. At Freetronics’ request, please don’t hassle the Arduino team with support or requests related to this board – they’re solely the responsibility of Freetronics.
Nevertheless there is a growing and vibrant support forum where you can see examples of the LeoStick in action and discuss other subjects and issues. 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.
The LeoStick is also new to us here as well, and we look forward to integrating it into projects in the near future, as well as having a board to experiment with when travelling. As we always say – if it meets your needs or you want to try something new, you could do a lot worse than getting yourself a LeoStick. If you are interested in learning how to use Arduino in general – check out our tutorial here. For more discussion and support information for the LeoStick consult the forum or product web page.
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.
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.






































