GertDuino for Raspberry Pi

GertDuino board to expand Raspberry Pi

Pictured above is the new GertDuino board, developed by Gert van Loo – inventor of the popular Raspberry Pi add-on (GPIO extension) Gert Board.

The GertDuino is designed as a Raspberry Pi add-on, and gives the best of both worlds – the low power consumption and many input/output options of Arduino with the processing power and connectivity of the Raspberry Pi.

Gertduino board mounted to Raspberry PiThe image above shows the GertDuino connected to the Raspberry Pi.

The GertDuino is based around the popular Arduino Uno with a non-surface mounted ATmega328 microcontroller which can be programmed directly from the Raspberry Pi with code written and compiled on the Raspberry Pi. The GertDuino is compatible with all existing Arduino shields (Uno).

Once programmed GertDuino can be used as a standalone board or left coupled to a Raspberry Pi if the project calls for it. When connected to Raspberry Pi, it takes its 5V power supply directly from it, but as a standalone an external 5V power supply is required.

In addition to all the functionality and input/output of the Arduino Uno, a second microcontroller has been added to GertDuino (a surface mounted ATmega48) which gives an IrDA interface to the board (infrared receiver), a real time clock (with battery back up power supply – CR1025 3V button cell, not included – and high precision crystal). There is also an RS232 interface, and a couple of user push buttons and an array of six LEDs. And all this comes at a cost comparable with an original Arduino Uno board at £22.20 inc VAT available from Farnell / Element14.com.

Of most interest to us at REUK is the ability to use the GertDuino and its real time clock to wake up the Raspberry Pi only when it is needed – for example, the GertDuino could be used to monitor battery voltages or a solar water heating system, and turn on the Raspberry Pi for just a few minutes every 12 hours to process and publish the collected data. The overall power consumption of such a system would be far less than keeping the Raspberry Pi active all the time, making it much more economical to run everything from solar power. (See our article Solar Powered Raspberry Pi for details).

The user manual for GertDuino is full of information, schematics, and more on this new Raspberry Pi add-on. Click here to download and view the GertDuino User Manual (30 page PDF).

Arduino Solar Water Heating Pump Controller Design and Code

Following on from our recent blog posts Arduino Solar Water Heating Pump Controller and Arduino Introduction, we have received a few requests for the source code (sketch) and design for a very simple Arduino based solar water heating pump controller.

We thought it would be an interesting exercise to show how just a few components and twenty or so lines of code can be turned into quite an effective controller, so here it is.

REUK.co.uk Arduino simple solar water heating pump controller - Arduino nano

For the schematic (and our own testing) we used an Arduino Nano, but pretty much any Arduino board could have been used. To that we just need to add a couple of LM335Z temperature sensors, a relay, an NPN transistor (we used a BC547), a few resistors, and a diode.

Here is a screenshot of the source code (the link to download it is at the end of this blog post):

Sketch for REUK Arduino simple solar water heating pump controller

This really is about as basic an effective microcontroller based solar water heating pump controller as it is possible to make.

The two temperature sensors connect to the (arbitrarily chosen) A0 and A2 analog pins, and the relay which switches the pump on and off to the D12 digital pin through a transistor (to limit the current drawn from the pin).

The variables diffON and diffOFF are used to set the number of degrees Celcius by which the solar panel must be hotter than the hot water tank for the pump to turn on, and then to turn off respectively. We used 6 degrees for diffON and 3 degrees for diffOFF – you may choose to use different values. These give hysteresis which prevents the pump switching on and off repeatedly and rapidly (since the temperature difference has to fall before the pump is switched off, and then rise before it will be switched on again).

The temperatures are measured every quarter of a second – delay(250) causes the programme to pause for 250 milliseconds. If the solar panel temperature is more than diffON degrees hotter than the hot water tank, the pump will turn on; and then when the temperature difference falls to diffOFF or lower the pump will turn off. And that’s it – simple, but does the job.

These LM335Z temperature sensors output a voltage of 2.73V + (X * 0.01V) where X is the temperature in degrees Celcius. The analogRead command digitises this analogue voltage to a whole number in the range 0 to 1023 with 0 corresponding to 0.00V and 1023 corresponding to 5.00V.

The calculation done on those analogRead 0-1023 values converts them into temperatures in degrees Kelvin. To convert degrees Kelvin into degrees Celcius you just subtract 273.15. That was unnecessary in this example since we are only interested in the difference between the two temperatures, but if you wanted to display the measured temperatures by connecting the Arduino board via USB to a PC that is how you would get them in Celcius.

Obviously there are a lot of things which can be added to this controller to make it more effective and reliable – e.g. time delays before the pump turns on and off, user programmability, manual override, frost protection, maximum temperature shut off, data logging and processing, and real-time temperature and system status display etc, but this is a good starting off point. There are vast amounts of resources online to help you learn more about Arduino – start with the official Arduino website to find out more.

Click here to download the Arduino source code for the REUK Simple Arduino Solar Water Heating Pump Controller as pictured above.

If you have any questions about the above or if you would like to share your modifications or enhancements to the code or design, please email neil@reuk.co.uk.

Arduino Solar Water Heating Pump Controller

The REUK 2013 Solar Water Heating Pump Controller (pictured above) is one of the most popular products on the REUK.co.uk website. With a temperature sensor on the solar water heating panel, and a second on the hot water tank, this controller decides when to turn the pump on to circulate solar heated water from the panel to the tank.

This controller is based around a PICAXE-08M2 microcontroller which gives a good balance of programmability and simplicity. It does however have one large disadvantage – it can only do integer arithmetic, i.e. performing operations on whole numbers only.

Therefore when we come to make modifications to the controller for particular customer requirements – e.g. frost protection and maximum temperature shut offs etc – things get unnecessarily complicated. Additionally there is limited memory on a PICAXE-08M2 which becomes a serious problem as the complexity of the desired programming increases.

For this reason we are currently porting a lot of our PICAXE based controllers to Arduino which allows floating point arithmetic and far more memory space.

Pictured below is our latest Arduino solar water heating pump controller. It is functionally identical to the standard 2013 PICAXE controller, but offers much more flexibility for modifications and added features.

Arduino pro mini based REUK solar water heating pump controller

The Arduino board used here is the Pro Mini – the smallest of the Arduino range. The red board plugged on to the blue Arduino board in the above photograph is used to connect the Arduino to a PC via USB for programming and/or so that data can be outputted to a serial monitor in real time or for later analysis as shown below where the temperature of the solar panel and of the hot water tank is outputted once every second. If monitoring is not required then this break out board can be removed.

Serial terminal output for arduino solar water heating pump controllerIf you have any particular requirements for a solar water heating pump controller which are not met by our standard controller range, email neil@reuk.co.uk with details of what you need.

If you are interested in building and programming your own solar water heating pump controller as a project, click here for our simple Arduino Solar Water Heating Pump Controller Design and Code which should help you get started.

Arduino Introduction

We have been receiving a lot of questions about Arduino lately, so in this blog post I will attempt to briefly cover the topics about which we are most often asked – how to get started and which Arduino boards to use.

NEW – We are now publishing the full Arduino source code for many of our projects and products here: Arduino Projects.

The official Arduino website describes Arduino as an open-source electronics prototyping platform, and it is designed to be used by anyone interested in creating interactive objects or environments. We for example use Arduino primarily in a wide range of timers and controllers which act upon measurements made of the surrounding environment using sensors such as light detectors, temperature sensors, and many types of switches.

Arduino Uno board

For anyone getting started with Arduino we would recommend the Arduino Uno board pictured above which retails in the UK for around £20. It can be powered from the USB cable which is connected to a computer when uploading your sketch (Arduino program code) to the board from the Arduino IDE (see below), or via an external 7-12V DC power supply.

Click here to download the Arduino IDE (integrated development environment) software to your PC (Windows or Linux) or Mac. This is where you will write your sketches, communicate with your Arduino board, and find lots of useful example code.

There are a wide selection of alternative Arduino boards offering different features, numbers and types of inputs and outputs, and different physical sizes and prices. These are detailed on the Arduino website.

There are also a selection of Arduino Shields which connect to Arduino boards to give additional advanced functionality – e.g. Wifi, GSM, and ethernet connectivity, motor control, SD card slot for datalogging, real time clocks, LCDs, or simple prototyping boards for you to use for added external components and/or sensors.

arduino nano and pro mini

Pictured above are the Arduino Nano and Arduino Pro Mini. These small boards are excellent for embedding in projects thanks to their small size. The Pro Mini for example is a tiny 0.7″ x 1.3″ small.

The Arduino Nano retails in the UK for around £20-25, but as Arduino is open-source, much cheaper clones are available with prices starting at around £6 only including a USB cable and air mail delivery!

Clones of the Arduino Pro Mini are available from around just £3 each, but as the image above shows, this board does have a USB connection. In order to programme the Pro Mini you need a breakout board such as the one pictured below.

ftdi basic breakout board for arduino pro mini

This is an FTDI Basic Breakout For Arduino USB-TTL 6 PIN 3.3/5V. When you want to programme the Pro Mini, you connect it to this breakout board and connect that via USB to the computer. These boards are available from around £5.

FTDI board connected to Arduino Pro Mini board

Here are the labels on the Pro Mini terminals which are hidden in the image above to show what connects to the FTDI breakout board.

Connections for ftdi breakout board on arduino pro mini board

When programming is complete, you disconnect the Pro Mini and use it in your project, and you still have your breakout board. Therefore if you are doing a lot of embedded projects, the Pro Mini is the most cost effective Arduino board to use.

The other option for projects is to prototype using an Arduino development board, and then make an Arduino standalone. For this you programme the microcontroller on the board, and then remove it (possible with the Arduino Uno and older Duemilanove boards) and add it to your own circuitry. We detail this option here: Standalone Arduino on a Breadboard.

It is getting harder to find the Uno and Duemilanove boards now as they have been superseded with the latest Arduino boards which have surface mounted microcontrollers. But, you only need the one board for prototyping and programming, and when you have one, it is easy to get the ATmega328 chips with the Arduino bootloader pre-installed for your projects.

Here are some useful links to help you find the above described items:

Arduino Uno – Rev 3.0 boards with USB cable supplied. £17+ for official boards, or from £6 for compatible clones. Make sure to choose a ‘development board’ (not surface mounted microcontroller) if you want to remove and embed the microcontroller chip in your projects. See image below (development) compared to the surface mounted version at the top of this posting.

arduino uno development board

Arduino Nano – from £12 for official boards, and from £6 for compatible clones (mostly available with included USB cable). Note that headers are usually not soldered onto cloned nanos (so they do not spike through the package in the post), but will be included for you to solder.

Arduino Pro Mini – from under £3. Supplied with headers for you to solder.

FTDI Breakout – for the Arduino Pro Mini – you just need one which you can reuse. Prices from around £5.

Arduino Duemilanove – from £10 for clones, and up to £20 for official boards. Not many available now compared to the Uno.

ATmega328 – chip supplied pre-loaded with duemilanove bootloader or Uno bootloader (choose the correct one for your board). Comes with the clock crystal and capacitors required for an Arduino standalone.

Target Controller for Competitive Shooting

Pictured below is a controller we have just made for use in competitive shooting. The competitor has a line of five targets to hit, each of which has a microswitch which closes when the hit target flips over. When each target is hit, an LED lights up, and when all five targets have been hit and all five lights lit, the lights flash on and off five times before the system resets for the next competitor.

Controller for competitive shooting with five targets and five lights which turn on when targets are hit.

We made this as a standalone Arduino project with the ATmega328 microcontroller. This has more than enough IO (input/output) pins to cope with the five inputs (target microswitches) and five outputs (LED lights switched by MOSFETs). The lights are 12VDC powered, so the controller was also made to be powered by 12VDC.

Project of the Day – Multiple PIR Sensors to Control Multiple Lights

Today we finished work on the controller pictured below which was produced to control lighting in a Halloween maze using motion sensors.

Halloween PIR motion detecting lighting controller

The maze will be in the dark, but with three passive infrared (PIR) motion sensors located through the maze and used to turn on three lights when motion is detected nearby – the first PIR sensor controls the first light, the second sensor the second light, and so on, independent of each other. When motion is detected by a sensor, the relevant light turns on for just 3 seconds, and then that light will not turn on again for at least another 30 seconds.

PIR motion sensor module

The PIR modules chosen for this project were KC7783R PIR Modules which are very small and easy to hide, and have very low power consumption. As the light bulbs themselves have yet to be chosen, we fitted three 10A rated relays to switch the power supply to each bulb.

Halloween PIR lighting controller circuit connections

The controller board is fitted with three small red LEDs, each one reflecting the output of one PIR sensor. Therefore the status of each sensor can be checked even during the 30 second delays that lights do not turn on after a recent motion detection.

This circuit design is based around an ATmega328 microcontroller as an Arduino standalone.

If you need any electronic controllers taking inputs from a motion sensor or sensors, send an email to neil@reuk.co.uk.

Project of the Day – Fold up Car Mirror Controller

Pictured below is a project we have completed for a retro-fit automatic folding car door mirror controller.

Automatic car door mirror controller

The car in question is a Japanese 4×4 with fold up mirrors and an after market OEM mirror switch fitted to raise and lower the mirrors when buttons are pressed in the vehicle. The goal of our controller is to automatically fold up the mirrors when the car is central locked, and to automatically fold down the mirrors when the car is central unlocked.

As things stood, when the ignition is on, if the fold up button is pressed, +12V is sent from the mirror switch to turn the two mirror motors in one direction, and if the fold down button is pressed, +12V is sent to turn the mirror motors in the other direction. Our controller sits between the mirror motors and the mirror switch and replicates this behaviour detecting the +12V signals and outputting the same to the mirrors for as long as a signal is present. But, when the ignition is off, there was no way to fold or unfold the mirrors.

When the car is central locked (ignition off) a +5V signal is present for one second on the wiring loom, and when it is unlocked another +5V signal is present. Our controller is designed to detect these signals, and if the ignition is off, to output +12V to turn the mirror motors in the required direction for a user programmable number of seconds immediately after detecting that the vehicle has been locked or unlocked. This gets the mirrors to automatically fold down ready for driving when the car is unlocked, and fold up out of harm’s way when the car is locked.

This controller was built around the ATmega328 microcontroller as a standalone Arduino project. Email neil@reuk.co.uk if you have an automotive electronics project of this type.

Project of the Day – Special Programmable Timer

We had a special request for a modified version of our REUK Super Timer 2 for use setting dosing levels during plant development.

Our super timer can be programmed to close a relay for an interval from 1 second to 99 hours, and then open that relay for from 1 second to 99 hours repeating. It is a very useful and popular product, but in this particular application it was necessary to make the programming of the ON and OFF durations as simple as possible and to also display the current settings so that it was immediately obvious to anyone looking at it what those settings were.

simple relay timer with displayPictured above is our solution to this problem. The possible ON durations required were 1,2,3,4 or 5 seconds, and the OFF durations 1,2,3,4 or 5 minutes. Therefore there are two buttons – one to move through the ON options 1 to 2 to 3…etc seconds, and another button to move through the OFF options 1 to 2 to 3… etc minutes. The green LEDs show which ON option has been chosen, and the red LEDs show which OFF option has been chosen.

Because of the large number of inputs and outputs, 10 LEDs, two buttons, and a relay, we chose to use Arduino for this project, but as a standalone microcontroller as explained here: Standalone Arduino on a Breadboard so that everything could be put tidily on the one circuit board.

Project of the Day – Digital Competitive Shooting Range Timer

We have just finished working on a digital timer for competitive shooters to use at the range, but this type of timer could be turned to many different applications with minimal alteration.

In front of the shooter is a table with a pressure pad which detects the presence of a gun resting upon it. When the gun is lifted, the timer starts and the shooter attempts to hit each of five targets in turn. When the fifth and final target is hit, the target closes a micro-switch which stops the timer, and the time taken to hit the five targets is displayed.

Connecting diagram for arduino 7 segment 4 digit timerIn order to complete this project we needed an accurate timer and minimal wiring complexity, so we used the Arduino system but using its ATmega328 microcontroller chip as a standalone with external 16MHz clock crystal and capacitors, and an L7805 5V voltage regulator instead of using a full Arduino board.

The maximum time to be recorded by the timer is 90 seconds. (Typically shooters will have a limit of 50 seconds to hit all five targets, but may take up to 90 seconds initially.) We therefore needed a 4-digit display to show the seconds and hundredths of seconds of the elapsed time up to a maximum of 90:00.

Adafruit 7 segment 4 digit display with backpack

We chose the excellent Adafruit 7-segment 4-digit i2c display with Backpack. This device has its own chip which does all the hard work and means that only two output pins from the Arduino are needed to drive the display (clock and data) together with a 5V and 0V connection to power it.

The accuracy of the timer comes from using the Arduino millis() function which returns the number of milliseconds the sketch (program) has been running. The exact time when the gun is lifted from the pressure pad is noted, and each time the display is refreshed (every tenth of a second) the start time is subtracted from the current time to display the time elapsed since the shooter picked up the gun. When the final target is hit, the start time is subtracted from that time and left on the display until everything is reset for the next shooter.

If you need something like this please email neil@reuk.co.uk.