Review: the PiFace Real-Time Clock

Unhook a Raspberry Pi from the mains and it forgets the time and date. It’ll only get them back again if you re-connect it to the Internet or enter the data manually. As a Pi user who doesn’t keep his kit connected – I usually wire and power it up when I need it – and doesn’t always bother with the Ethernet cable when he does, I’ve been after a decent real-time clock (RTC) add-on for quite a while. An RTC allows your Pi to keep time, even when the Pi’s power is cut.

I’ve tried several RTCs, but until now none of them have provided quite the right fit-and-forget functionality I wanted. They were either too bulky to fit into my Pi casing, or didn’t allow me to continue using the Pi’s GPIO ports. Others had an overly complex software install, sometimes requiring you to obtain an non-standard Linux distro.

Well, goodbye to all that nonsense. Now I have a real-time clock that fits the bill perfectly.

Ladies and Gentlemen, let me introduce you to the PiFace RTC:

PiFace RTC

You’ll have guessed from the name that it comes from Dr Andrew Robinson, the boffin behind the PiFace, an add-on that simplifies connecting all sorts of peripheral devices to the Pi. The PiFace is undoubtedly a clever bit of kit, but the PiFace RTC is an altogether smarter piece of design.

What Andrew clearly realised is that folk who need an RTC don’t expect it to be their Pi’s only add-on. He could have integrated an RTC into the PiFace, but a better approach was to design a separate unit that works alongside his main offering. And therefore, of course, with anything else you might want to connect to your Pi’s GPIO.

So, the PiFace RTC was designed to fit underneath other add-ons without restricting their access to the GPIO pins in any way, physically or electrically. What we have here is a board drops onto the Pi’s pins, which pass through holes in the board so that other kit can be clipped to them too.

The RTC’s back-up battery, a CR1220 coin cell, is small and the board itself incredibly thin, in order both to minimise the add-on’s vertical height but to ensure there is still plenty of pin left for devices placed on top of it. Pushed onto the pins, the PiFace RTC doesn’t even extend vertically as far as the Pi’s camera connector. Now, this thinness makes the PiFace RTC seem less than robust, but since it can be left in place on the Pi, that shouldn’t matter: it’s not a gadget you should be taking on and off.

PiFace RTC

The PiFace RTC drops right on to the Pi’s pins and leaves plenty of room for other devices
Pictures from PiFace

You might be wondering how Dr Robinson has managed to make a Pi add-on without the customary chunky female GPIO connector. Other RTCs I’ve tried had just that: a thick plastic adaptor below and pass-through pins – usually much thinner and more readily bendable than the Pi’s own – above. Here comes the really clever bit: two of the PiFace RTC’s 26 metal-lined holes have been drilled fractionally off axis – you can just see this in in the photo at top. While the board still fits onto the Pi’s pins, it’s sufficiently distorted to force contact between each hole and its pin.

I’ve been using the PiFace RTC for about four months now, and I’ve not once had a mis-read when the Pi boots up and updates its own clock from the value proved by the battery backed board. Which communicates with the PI via I²C, by the way.

Software installation is easy: there’s no need to compile kernels or anything like that, just download and run a shell script to enable update the Pi’s system files to enable I²C and make it accessible to devices at start-up. Once the script has been run, you use the Unix date command to set the RTC’s own clock, reboot and… er… that’s it.

CR1220 batteries cost a pound or so and, says Dr Robinson, will last a couple of years in the RTC board. I’ve not had mine quite that long, so I’ll have to take his word for it. I can say it works as well with a Pi B+ is it does with a Pi. I’ll be trying it with a Pi 2 soon.

Verdict

The PiFace RTC only costs £8.40 including VAT from Farnell/Element 14, which is cheaper than most other Pi RTCs. Even if it weren’t, the PiFace RTC would be worth a look for its ease of use and negligible impact on your ongoing use of your Pi.

I spotted the RTC quite a while back on the PiFace site. It had nothing but a ‘not yet available’ message, even though Farnell was selling the thing. This fact I discovered by accident. The PiFace site has since been updated, but the company should more of a noise about this small, useful, genius device.

Price £8.40 including VAT
More Info PiFace

Review: the GrovePi+ Starter Kit

When it comes to hacking hardware there’s an easy way and there’s a hard way.

The hard way involves connecting peripherals direct to one of the standard buses supported by your Raspberry Pi, Arduino, Beaglebone or whatever. Buses like I²C, SPI, UART and 1-Wire. You’ll need to take care with your wiring: have you got the right pull-up or pull-down resistor? Is there too much capacitance in the line?

Now you have to swot up on the peripheral’s datasheet and write the code that will get your platform to successfully communicate with the gadget you’ve connected to it. The standard buses are different, and have their pros and cons. But whichever one you pick, it usually takes a bit of debugging to read the sensor data right, or display the correct text on the OLED display. That done, you’re ready to focus on your application code: the part of the control program that uses the peripherals to solve the problem you’re addressing.

GrovePi+ Starter Kit

Dexter Industries and Seeed Studios’ GrovePi+ Starter Kit

These days, a fair few of the most commonly used data sources – light-level sensors, temperature and pressure readers, motion detectors and such – are well supported with open source driver libraries written by the many companies who mount the raw components on break-out boards, add some interface logic and sell the result as a unit rather than a raw component.

Adafruit and SparkFun, for example, both offer dozens of such modules, all accessible in your project software through driver code you cut and paste out of code repositories on websites like GitHub. Add them wholesale to your project, or use fine-tune for the needs of your specific application. Most libraries are written for the Arduino, but if you’re basing your device on another popular platform, the code is usually sufficiently well commented for you to work out what’s going on and adapt it accordingly.

GrovePi+ Starter Kit

The GrovePi+ board

The really hard way, of course, is to grab a component and its datasheet, and work it into your project without the help of folk with a greater knowledge and experience of electronics and/or software than you. That’s where you want to get to, of course, because it allows you to work with any off-the-shelf sensor or display. But it’s difficult, and a less time-consuming approach is to limit your choice of device and pay a little extra for it, but get a nice, well-supported module.

Or you can go the really easy way, and use a product that integrates a bunch of sensors (light, sound, ultrasonics, temperature and pressure), readouts (LED and LCD) and inputs (button and potentiometer) and control (relay); hooks them all up through a common connector to a board that drops right onto your platform’s GPIO pins – and makes all the modules accessible through a simple software interface.

GrovePi+ Starter Kit

The Grove modules that come with the Starter Kit. Clockwise from top left: ultrasonic ranger, character LCD with RGB backlight, potentiometer, buzzer, button, red LED, relay, light sensor, temperature/pressure sensor, blue LED, sound sensor

That’s what China’s Seeed Studios and America’s Dexter Industries would like you to do, and they’ve jointly devised the Grove system to provide what they call a Lego-like approach to developing electronics projects: just build it up, functional block by functional block. All of the component modules designed by Dexter and sold by Seeed connect to a board, the GrovePi+, using the same type of four-wire cable: two wires for data, one for power, the fourth for Ground. That means you can grab any Grove cable, fix it to any Grove sensor and plug in into pretty much any port on the GrovePi+ board.

No prizes for guessing this product is for the Raspberry Pi, but there’s an equivalent Shield for Arduino and Cape for Beaglebone. The plus symbol indicates this is issue two of the GrovePi: a new board with revised, cheaper-to-manufacture electronics.

GrovePi+ Starter Kit

All Grove modules connect to the GrovePI+ using the same type of four-wire cable and connector

The GrovePi+ board has seven digital, three analogue, three I²C and two serial ports, all designed to take said standard four-wire cable. On the base of the board is a female connector the fits onto the original Pi’s 26 GPIO pins, and it rises sufficiently high for B+ and Pi 2 owners to access those products’ extra GPIO pins, though not easily. However, the board does include 26 GPIO pass-through pins on its upper surfaces, though the pins are thin and easily bent. That said, I was was able to connect without difficulty both the GrovePi+ and the Pimoroni PiGlow I use as a system monitor.

The Grove modules themselves are notionally standard across all platforms, though Seeed says all of them have been tested with the GrovePi+. Seeed’s wiki lists 12 out of 93 that have been, but since the GrovePi+ Starter Kit reviewed here contains modules not on that list, it’s probably safe to assume that most of them will work.

GrovePi+ Starter Kit

The GrovePi+ mounted onto a Pi B+. As you can see, there are (thin) GPIO pass-through pins

The Starter Kit includes a reasonable set of basics: RGD-backlit character LCD, red and blue LEDs, buzzer, button, ultrasonic ranger, variable resistor, relay switch, light sensor and a combined temperature and pressure sensor (the widely used DHT11). Some, like the light sensor, use an analog port on the GrovePi+, others, such as the LCD, I²C. The rest use any of the five side facing or two upward facing digital ports.

Dexter Industries has a custom Linux distro pre-loaded with the GrovePi+ software, but I chose – and I suspect most users will select – to clone the library files from the Dexter GitHub repo. This provides you with plenty of example scripts, and the necessary Python libraries. Depending on the module(s) you want to utilise in your project, you just need to import one or two libraries at the start of your application code. All the heavy lifting has been done for you: all you need to add to your code are the some basic port configuration commands – is it an input or an output? – and lines to read and write data from the module, as appropriate. The documentation is meagre, but the Python library files should be sufficient to get you going.

GrovePi+ Starter Kit

Assemble your project hardware by connecting the modules you need. Easy

It’s quick and easy. I built a simple Pi protection system with the ultrasonic ranger and a red LED in just a few minutes and with a handful of lines of code. Then I plugged in the buzzer and set that to sound when the LED lit up – and pretty pronto a button to reset the system and turn off the noise. It took me longer to wrack my brains for Python’s string formatting syntax than it did to hook up and code the character LCD as a simple time-stamped alarm incident log.

The Starter Kit costs £38.99, the GrovePi+ on its own £15.60. Most of the modules cost around £1.24. All the bits used in my test project came to more than the price of the Starter Kit, so the bundle is certainly a good place to start. And if adopting the Grove systems ties you in to the board and module selection, at least that selection is extensive and the modules inexpensive. It does seem good value.

GrovePi+ Starter Kit

Hands off that Pi! The test project assembled and running

That said, the jury is still out. I tested a pre-release version of the GrovePi+, which communicates with the Pi via I²C. I experienced a number of IO errors, all related to I²C communications, during the time I spent with the Kit. Dexter Industries Forum posts relating to the GrovePI+’s predecessor suggest this is not uncommon but at least can be caught and managed in the core Python code. Dexter reckons that’s a job for the application developer – only you know how much of a problem such errors are for your specific project. Still, given that GrovePi+ is pitched as the easy approach, Dexter really should have made this more intuitive or worked to eliminate the problem altogether.

Verdict

So, the easy way or the hard way? For me, the GrovePi+ way is too easy: it’s all done for you, so you learn nothing that will help you when you come to connect a peripheral that isn’t included in the selection of GrovePi sensors. Hooking up an LCD via one of the GrovePi+’s I²C ports tells you nothing about how that LCD is controlled, or about how to make use of the I²C bus. Surely that is what the Pi is all about: learning how devices work?

The other side of the coin cell is that if you have a gadget you want to build and you just want to get it made and working as quickly as possible, the GrovePi+ system’s ease of use will be really attractive. It’s good for schools who want to teach how programs affect the real world but don’t want to get bogged down in electronics.

Price £38.99 (TBC)
More Info Seeed Studio

(Retro) Review: Raspberry Pi B+

Better late than never. An edited version of this review appeared in The Register in August 2014. I intended to reproduce the original here, but never got round to it. At long last – and a tad late now the Pi 2 is out, of course – here for the record…

You might think that were you a purveyor of a nifty compact computer selling by the millions, you’d consider two years after the debut of your first offering that it was high time you tempted back buyers with a go-faster, more capacious and shinier model. Heck, Apple and others don’t even wait that long: they upgrade products year in, year out.

Raspberry Pi B+

The B+

Continue reading

Review: Pimoroni/Cyntech Pibrella

There is no shortage of clip-on boards designed for the Raspberry Pi, almost all designed to make the tiny computer’s GPIO pins more accessible in order to ease the connection of devices to it, particularly ones that operate at voltages that are not Pi friendly.

Pibrella

Electronics kit: Pimoroni/Cyntech Pibtrella

Continue reading

The Sinclair ZX81: a Raspberry Pi retro restyle – Part 2

Previously on ‘ZX81: a Raspberry Pi retro restyle’: I used a headerless Arduino Leonardo to connect a ZX81 microcomputer keyboard to a Raspberry Pi via USB, using code to handle normal, shifted and function-shifted key presses.

After some searching on eBay, I found an old ZX81 going cheap because it lacked cables, though when it arrived, I found the computer itself to be in excellent condition. Possibly it has never been used, though how if that were the case the cables were lost and the box got so tatty is a mystery I will probably never solve.

ZX keyboard controller

A new ZX keyboard connected to the USB controller – an Arduino Leonardo

Continue reading

The Sinclair ZX81: a Raspberry Pi retro restyle – Part 1

I love the design of the Sinclair ZX81. It was never a great computer, even in 1981. It only had 1KB of on-board RAM, it was slow, it was small, it could only do black and white graphics, and it’s membrane keyboard was useless for fast typing. But it looked fantastic: black, sleek and totally futuristic. Almost all other 1980s microcomputers now look very dated. No surprise there, of course, but the ZX81 still looks amazing.

Hats off to Sinclair Research’s industrial designer, Rick Dickinson, for devising a design that is genuinely timeless.

The ZX81 membrane keyboard

The ZX81 keyboard hooked up to the Pi via USB and Arduino

Continue reading