Friday, 16 November 2012

Remote Controlled Eight-Relay Board


- Using the RF12 Board by Jeelabs

Eight-Relay Module: control the relays using a Blue-tooth smart-phone or tablet.

I am making a remote control device. It allows me to independently switch eight relays and control various  items. When I press buttons on a small keypad, instructions will be decoded and transmitted via a microwave RF packet transceiver (@868 MHz). At the other end (up to 100m away!)  another transceiver decodes the message and switches the relays ON or OFF.

I'm using a pair of RF12 modules (which uses the Si4420 RF chip) on boards by Jeelabs.  They are small (4 x 2cm), inexpensive (£10 ea.) and easy to use:- libraries and code freely available for the Arduino.

Deepgeek link:

 Deepgeek link:  Si4420 RF chip datasheet 

Q. Why RF and not IR? 

Ans. I want to use the RC device through walls and outside, so it's got to be RF - you get about 100m in line of sight, and @869 MHz you get penetration through walls.

Instructions typed on a small keypad will be transmitted via the first RF12 microwave RF packet transceiver. At the other end the second RF12 handles the packet and another Arduino switches the relays on the x8 relay board, ON or OFF.

How I'm knitting it:  device visualisation

To avoid some of the pitfalls I fell into, I recommend you following the geekery recipe below.

Geekery Recipe: Using the RF12 board with Arduino Uno

As mentioned above, the RF12 boards are available from Jeelabs9.33). These enable data sharing among common network groupings. I am just using them for RC, although they are capable of much more. I am working at 5v so I need all the components for the board.

Assembling and connecting RF12 boards. 

 Useful links before starting:

Jeelabs article
Jeelabs hardware reference
RF12 datasheet

For a guide on soldering see this link:

1.      Start by soldering on the surface mount module. The way I found best, was to lightly flux all the parts I'm going to solder (using a flux pen) and tin the SMD mounts on the module. Then use a small croc-clip to hold the module in place on the board and reheat the tinned contacts until solder flows. Then pull away the soldering tip, allowing cooling. Be careful not to overheat the module – proceed slowly to allow proper cooling.

2.     Solder the rest of the components starting with the smallest or lowest profile first. This order worked for me: small capacitors, resistors, voltage regulator, electrolytic capacitor, and finally the header strip.

3.      Note the PCB has the connecting Arduino pins marked on it.

4. Connect the RF12 boards to the Arduinos according to the above diagram. At this point I have two RF12 Arduino transceivers all wired up.

Setting Up and Testing the Transceivers

I don’t pretend to understand how all this code and library works, but it works ok and that’s good enough for me, at least for now.

1.      Download and install the RF12 Arduino library

2.      Open the RF12 demo sketch.
Note I had to change the Baud rate of the serial connection to get it to work  ie
void setup() {
    Serial.begin(57600); CHANGE to Serial.begin(9600);
........ others may work too..........

Load the sketches to the Arduinos and refer to this page: I got something that looks like this when I opened the serial monitor(s): some other stuff I didn’t need to worry about.

I set my RF12’s to 868 MHz working in group 10 and each node ID labelled in sequence 1, 2 etc... The RF12 demo stores these data in memory so the nodes remember what the freq is and their ID’s.

It’s tricky keeping track of which nodes are on which serial COM and which Arduino. I am uploading to or sending / receiving serial data from at least two. Obviously the more Arduinos connected the worse it gets, so I label the Arduino with tape and write the COM number on it.

9. I typed this into the serial monitor for node 1:


and this for node 2:


10. For each node, I tried sending max-size packet with ack [acknowledge]

and in return I got in return something like this for node 1, group 10:

Current configuration:
 A i1 g10 @ 868 MHz
> 0t
test 0
 -> 66 b
OK 193

and in return I got in return something like this for node 2, group 10:

B i2 g10 @ 868 MHz
> 0t
test 0
 -> 66 b
OK 193

That tells me the nodes are successfully transmitting and receiving data-packets – huzzah!

It’s not absolutely necessary, but I could go ahead and test further by playing with the packetbuf demo (remember to change baud rate if you get a problem). I am using packetbuf code in my RC device.

To avoid some of the pitfalls and frustrations I got into, I recommend steps 2. through to 9. are followed if you use your Arduino or AVR chips for other things, because the memory may get overwritten. This happened to me on a few occasions. Also label which Arduino is using which COM connection. It will save lot’s of grief as the number of nodes increase, especially if you are loading different sketches to different Arduinos.

Beware of using delay() with RF12 modules. They use interrupts to operate, hence Arduino pin 2 is used, which is one of the external interrupt pins. Arduino delay() plays havoc with interrupts so it can't be used. Use blink-without-delay, which is given as an example with the Arduino IDE. Alternatively, I  use delayMicroseconds() which does not interfere with the packet buffer code I am using. I think purists may prefer blink-without-delay, however.

Sunday, 11 November 2012

Remote Controlled Eight-Relay Board


- Analogue Keypad as Input Device

I am making a remote control device. It allows me to independently switch eight relays and control various  items. When I press buttons on a small keypad, instructions will be decoded and transmitted via a microwave RF packet transceiver (@868 MHz). At the other end (up to 100m away!)  another transceiver decodes the message and switches the relays ON or OFF.

The remote control incorporates a small inexpensive analogue keypad, connected to an Arduino Uno. The Arduino handles the scanning and decoding of the keys pressed on the pad.

Note how the keypad pins are wired to the Arduino. Details of how to work this out can be found here:
keypad datasheet and here: using the Arduino keypad library, but it can be tricky.

If you are using the Sparkfun or RVFM keypad it should work using the wiring diagram above and the  code below. Note I may change around some of the pins in later posts if I need them for other things. For instance arduino Pin 2 is can be used for interrupts, which are required by some devices.

There are some web pages that show external pull-up resistors in the wiring diagram. These are not necessary if you use the latest version of the Keypad library.

Making the Code 
I don't want to write all the code for scanning the keypad and decoding the inputs from scratch. I can use the Arduino keypad library instead and some sample code they provide. See this link: using the Arduino keypad library.

See code here:  Keypad.txt

Keypad available here: Rapid Electronics

I will not be posting how it is possible to link relays to AC mains devices. I will be using low power DC examples. If you go ahead yourself and try mains stuff, remember I told you it can be very dangerous. Playing with mains power can kill you, and the people around you, not just by electrocution but also by starting a fire.

Saturday, 10 November 2012

 Digital LOGIC: the truth often hurts (your Brain)  

I created this single-page reference to help me with digital logic GATES and wanted to share it. It was created from a screen-shot in New-Wave-Concepts Circuit Wizard which simulates circuits in real time.  I use circuit Wizard a lot, so it will feature a lot in my blog - it's really useful to get you quickly prototyping your circuits. You can get Circuit Wizard from Maplins in the UK or contact the publisher (New-Wave-Concepts).

The symbols represent the types of logic gate and the tables are called truth tables. A and B are inputs and Q is the output. Logic values are often called boolean values and represent two conditions TRUE (1) and FALSE (0). Very simply put, logic 1 can be represented by five volts and logic 0 by zero volts. This isn't the full story in real circuits, because each logic gate is composed of electronic switches called transistors (usually MOSFETS).   

Here is a logic gate chip, containing 6 NOT gates or inverters often called a Hexinverter:

The NOT gate or inverter

This gate "inverts" the input so a 1 becomes a 0, a 0 becomes a 1. TRUE => FALSE, FALSE => TRUE. 

The output Q is the logical inverse of the input A, ie NOT A. In  boolean algebra it is written as the symbol:

The NOT gate is the simplest form of logic gate. Note there six inverters on the chip above. You can see how the inverters are arranged with their inputs and output pins. Vcc is the power pin for the chip and is commonly +5 volts. GND is ground, or commonly zero volts. The notch in the pin tells you the correct way up to read the pins and connect them. The letter Y was used to distinguish outputs from inputs.

I can also recommend this inexpensive book I recently bought: Digital Logic Gates and Flip Flops by Ian Robertson Sinclair, which delves into this subject with a lot of depth. But, for a quick overview, here is a reference to LOGIC gates on Wikipedia. 

Logic gates form the foundations of digital circuits, all the way up to complex microprocessors. 

Thursday, 8 November 2012

Diamond Flashing LED's (no MCU required) 

A bit of fun and very pretty. It might be good as a baby mobile or a calming mood light - it's quite relaxing and almost hypnotic. I decided to make it as a "pick-me-up project" for those long winter nights.

The video speaks for itself. A very simple circuit with no MCU - the arrangement of led's makes the flashing pattern. 

You can get the led's here:

The design is copyright of Craig Turner 2012, 2013. But feel free to make some PCBs for personal use and enjoy them. No PCB copies should be made for sale or any commercial use.

 Dance-off Robot 

Check out my Arduino Motor Shield, it's on a 4WD Robot car controlled by an Arduino Uno. This is part of an ongoing robot project, using bumper sensors (microswitches), scanning ultra-sonic sensors (SRF05), WiFi camera, bluetooth, RC and lots more. Note it is advisable to cool the shield's main chip (eg heatsink).

Code is Here:
Gampa Geek's Google Drive

Showcased Here:

Lots's more robot code to come as I crack on with this project.

Monday, 5 November 2012

Arduino Rev 3
Arduino Uno Rev 3
After years of working in Biology, Environmental Science and informatics, I took a right turn and discovered micro-electronics. As a complete beginner, with a little Java, it was going to be tricky. I was struggling with assembly language and C for RISC chips.

That's when I found the Arduino IDE and it's boards. Open source hardware and software that's so easy to get into. It is supported by a great network of volunteers on the Arduino Forum and on the main Arduino site and covers a very wide range of topics in physical computing

Topics range from interactive e-textiles and art to robotics, device hacking, engineering and beyond.

Sunday, 4 November 2012

Gampa Geek goes online



Gampa Geek is an old guy who likes electronics and micro-controllers, and basically any cool science stuff.

"I will be sharing my geekery recipes and webfinds from the Wide World Wonder of my comfy armchair, and my beautifully knitted computers..." GG.

Facebook:  Gampa Geek

Look out for Gampa Geek's:

Geekery recipes
A bit like cookery but geekery :) Whilst doing stuff I have fallen into loads of pitfalls, become confused, wasted loads of time fannying around, blown components and destroyed stuff by mistake (sometimes expensively). I want others to avoid these if possible so I create Geekery recipes to follow. Also I hope others will offer constructive comment to improve these recipes.

Gampa Geek is really Dr Craig Turner, born in the 1960's, a life-long scientist who has recently been studying electronics and microelectronics online. Craig (Gampa Geek) is committed to learning. He firmly believes that older people should share their knowledge and experience. He set up this site to share findings, links and projects, and other cool stuff from a Wide World of Wonder.

Work published in this blog is subject to copyright laws. Most is provided free,as is, and without support, except I will try to answer constructive comments and questions on this blog. There may be exceptions to this rule and these will be clearly stated where appropriate.

 Also Arduino help can be found here: 

and here is my membership at;u=48270 you will have to resister to view this

Programming esp. JAVA, ANDROID help here:

    Facebook:  Craig Turner

Destined to be a geek, he got his first Chemistry set at age 5. A Thomas Salter set This is an example of set 3, but set 1 was suitable for a 5 year old.