Adventures in I2C: clock stretching on the Raspberry Pi

This is a bit complicated, technically, but I’ve been asked to document the issue just in case someone comes across it.

I was getting I2C read errors when using the new TE AmbiMate MS4 sensor board (review coming soon!) with the Raspberry Pi 4. I contacted TE about it and they asked me to try a Pi 3. So I did, and it worked absolutely fine.

It was an intermittent issue on the Pi 4 (everyone’s favourite sort of error!), and so I did some research and found some information on something called ‘clock stretching‘.

This apparently affects the Raspberry Pi and was documented in a lot of detail, back in 2013 by someone at Advamation. Here is that post.

Although I found evidence on the Raspberry Pi forums that it had been fixed on the Pi 4, this is apparently not the case as it was a Pi 4 I was getting the problem on.

I tried a good old-fashioned apt-get update and upgrade and tried it again. No joy.

I was pointed at this GitHub issue which implied that the problem still exists. It suggested adding a line to /boot/config.txt


which forces the Pi to use the old I2C driver. This failed to work, in fact it made the problem worse because suddenly it wouldn’t read anything from the sensor. I reversed this.

I tried an rpi-update to get the latest firmware, just in case a fix had been implemented on a newer version. This again failed to work.

Eventually, after some searching around (good ol’ Google!) I came across this issue on GitHub which suggested that the problem was the speed at which I was trying to read the I2C bus. So, I added a config option to /boot/config.txt as follows to reduce the read speed from 100000 baud to 10000 baud:


Miraculously, this worked and I received stable readings from all the sensors on the AmbiMate without the errors occurring.

I came across an alternative solution (which I haven’t tried). Apparently, the bug only affects hardware clock stretching. However, it is possible to use an alternate set of pins for I2C and use software clock stretching. This is documented on GitHub here. Here is the relevant bit:

Raspbian has a software I2C driver that can be enabled by adding the following line to /boot/config.txt:


This will create an I2C bus called /dev/i2c-3. SDA will be on GPIO23 and SCL will be on GPIO24 which are pins 16 and 18 on the GPIO header respectively.

I hope this is of some use to someone!

Book review: Raspberry Pi Projects for Kids (by Dan Aldred)

I was sent a review copy of this book by No Starch, but I can say what I like 🙂

The author

According to the blurb in the first couple of pages, Dan Aldred is a Computer Science teacher, freelance writer and hacker. He’s also a Raspberry Pi Certified Educator, so he should certainly know how to write a book with this title. I’m happy to say that he delivers, and then some.

About the book as a publication

First of all, this is a No Starch publication. If you’ve seen past reviews from me of No Starch books, you’ll know I hold them in high regard in terms of the quality they produce. This one is no exception. It’s full colour, has over 260+ pages and is nicely bound.

The whimsical cover gives you an idea who the book is aimed at, and Dan has a great turn of phrase and uses clear, basic English to get across concepts and instructions. It’s ideal for young teens, for instance, but will also be attractive to Pi beginners who need projects to get themselves going on.


There is a good introduction detailing how to use the book, and the equipment you’ll need. This is followed by a, by now obligatory, introduction to the Raspberry Pi, its capabilities and the way you’ll be working with it. An introduction to Python competes the introductory chapters and it includes some information on how Python works in terms of functions, loops etc. It’s a great chapter for those used to other computer languages, although perhaps it could have had a bit on how to go from visual block-based programming to text-based programming, considering the target audience.


The rest of the book is a series of projects to build based on the Pi with other, added components such as a Pi camera, LEDs etc. These components are all listed in a previous chapter, but if you want to do them one at a time, the individual chapters also list what you need. The projects are as follows:

  • Hot glue night light – using a silicon ice-cube mould and an LED to create a small light.
  • Selfie snapper – the first Pi camera project.
  • Pi Spy part 1 – using a normal webcam for surveillance.
  • Manipulating Minecraft – how to use Python to “hack” into Minecraft. (This is similar to a lot of other starter projects involving Minecraft, but it’s good to see what I would term an “old reliable” make a comeback).
  • Radio invasion – using the Pi as an FM transmitter.
  • Automatic texting machine – using the Pi to send SMS messages using an external service.
  • Pi Spy part 2 – tracking devices using Bluetooth and wifi..
  • Magic music box – using the Pi as a music source for a speaker.
  • Nature box – using a camera to detect motion.
  • Smart plugs – using the Energenie smart plug system with the Pi.
  • Mirror Mirror – using the Pi and a monitor behind a mirror to display social media updates.
  • Computer games with the SenseHAT – uses the Pi and the SenseHAT as a game display and controller.

It’s an eclectic mix, but I think the book is stronger for that as it gives kids (and adults, for that matter) a variety that they can pick-and-choose their way through.

The colour diagrams and pictures help to keep the book engaging throughout, and I must compliment the author and the publishers for the layout, especially.


This book is ideal for those who have either just got their Pi and are in their early teens, or perhaps slightly younger, and also those who have used the Pi for a bit and want something to get their teeth into. The range of projects is exciting and varied, although perhaps slightly equipment-heavy. Having said that, the Pi camera and other components are quite cost-effective and the SenseHAT, which is more expensive, is only used in the last chapter, so can easily be avoided if you don’t want to make the additional investment.

So, all in all, I can happily give this book a hearty recommendation. A great post-Christmas present for your child who has got their Raspberry Pi and is wondering what to do with it! 🙂

Buying the book

You can pick up Raspberry Pi Projects for Kids from No Starch (if you’re in the US or you want an electronic version) or from Amazon if you’re UK/Europe-based. Other retailers are available 🙂

Christmas 2019 gifts round-up for Raspberry Pi, micro:bit and more!

Hi everyone. I thought it might be nice to put out a blog post with some great gift ideas for the Raspberry Pi/electronics/robotics/micro:bit person in your life who might like to have a little something to open at Christmas 🙂 This post comes with a piece of advice: Watch out for Black Friday (week) deals!


Let’s start off with a gift for someone who might just be about to start their Raspberry Pi journey. The Official Raspberry Pi 4 Desktop Kit is lovely. It comes with everything you need to get started, including a great Beginner’s Guide book. Also included is the official keyboard and mouse, as well as the Pi, a case, an SD card and monitor cables. You could also look at The Pi Hut’s Starter Kit which is cheaper (but doesn’t have the keyboard/mouse) or Pimoroni’s equivalent kit which comes with slightly different items.

Festive Fun

If you’re looking for a couple of stocking fillers, take a look at The Pi Hut’s website for their Christmas tree range or alternatively, pre-order Pimoroni’s new offering: a Snowflake LED board.


If you think that special someone might appreciate some robotics fun, take a look over on 4tronix’s website for some Raspberry Pi and micro:bit goodies. Gareth has just launched the MARS Rover for micro:bit kit (pictured above). It’s just lovely and well worth the money if you want something a bit more expensive. If you want something at the lower end, you could also take a look at the Bit:Bot XL for micro:bit which comes in at £42. There are Raspberry Pi goodies too, so have a browse!

If they’re just starting out with robotics, take a look at the CamJam EduKit 3 which is a great little starter kit that myself and Tim Richardson designed and produced in partnership with The Pi Hut. It gets you going on your journey and includes a set of downloadable worksheets to teach you what you need to know.

And finally, if you want something a bit different, take a look at PiBorg’s RockyBorg which is a steerable robotics platform.


Pimoroni have just launched their Pirate Audio range which is a collection of audio boards to suit a variety of tastes for £19.50 plus shipping. These are fairly low-power audio devices, but they look gorgeous as usual and produce a nice sound on a small scale.

If you or your loved one is an ‘audiophile’ and you want to drive more powerful speakers, I thoroughly recommend IQaudIO’s boards. These are high-quality, beautifully designed and really pack a punch.

3D printing

If your enthusiast is into 3D printing, getting some filament for them (check the size they need!) is one way to win your way into their hearts… Well, you know what I mean.

Pimoroni have just started stocking some nice-looking filaments but if you want a 3D printing specialist, I recommend 3D Printz who are based up in Shropshire.

High class Add-ons

For add-on boards, you will want to check out the RasPiO website – there’s plenty on there that you might not have seen before. Alex Eames has been in the Pi community from the very beginning and he’s created some great boards including the Breadboard Pi Bridge (above), an Arduino-powered Night Light kit (which is great fun to put together as you can read in my beta review) and the Pro HAT which puts the GPIO pins in the right order!

LoRa LoRa Laughs

If your Pi/micro:bit enthusiast is into long-range communication, take a look at Pi Supply’s LoRa range.


That’s all, folks

There is plenty of other electronics wizardry out there, just take a look around.

Remember, though: the true joy of Christmas is spending time with your loved ones, cherishing that time and making the most of the Winter break, if you get one! There’s also the small matter of the birth of Christ, but I know my readership is mixed so I won’t go on about that – if you know me well, you know how I feel about Jesus and his love for the world. Hopefully you’ll hear from me again on or around Christmas. Until then: Keep warm!

Red Robotics’ RedBoard+ review – a fully-featured motor controller that isn’t afraid of high power and multiple functions

Neil Lambeth, of Red Robotics has recently released his first motor controller board for the Raspberry Pi. “Oh, not another one!” I hear you cry… Well, hold up there – this is one to pay attention to and it’s not ridiculously expensive, either.

TL;DR – Just buy one if you’re into robotics – it’s fantastic!


Coming in at £30/$38, the RedBoard+ is a HAT-sized controller board and it’s just packed with features:

  • It takes a battery input from 7V-24V and has reverse polarity protection.
  • It powers the Pi with a steady 5.2V, 3A power supply, meaning it will cope with a Pi 4, if necessary.
  • It has a 3.3 Volt 800mA Regulator.
  • It can control two sets of DC motors with two H-bridges on-board, capable of handling 6A per channel (12A overall!) This is one beefy controller.
  • It has a 4-Channel 5V level shifter for driving Neopixels, DotStars or other 5V electronics.
  • It breaks out three channels of an analogue-to-digital converter (one channel is used for battery monitoring)
  • It has one RGB LED on-board used for anything you like, but most useful as a battery warning light and/or an IP blinker (both scripts are included on the code repository).
  • It can directly drives up to twelve hobby servos (with a separate power input for large ‘robot’ servos).
  • It has one user-programmable button which is best used, as supplied, to shutdown or reboot your Pi with different hold-times.
  • An actual power switch to route battery power to the Pi and the motors.
  • Four I2C channels broken out onto headers.
  • Headers for serial communication (RX & TX).
  • Several Ground and Power pins.
  • A “really useful header” onto which you can plug an optional (but not yet available) OLED screen – this came in really handy, so thanks Neil for including one in my review pack!

Using the board

I have a robot I’ve been working on for ages with four powerful, 12V motors and a wooden chassis. It normally uses another motor controller board, but it makes an ideal test platform for the RedBoard+. Here it is in action (with thanks to the wife for doing the recording!):

I used a 10 x 1.2V rechargeable AA battery pack to power the Pi and the motors together, through the RedBoard+. To start with, the Pi kept rebooting and I wondered why… Panic set in! But it turns out that the batteries I was using were… not very good. Neil had pointed out that this could be the problem right at the beginning, but I spent a good few hours in denial before switching over to some Eneloops/Amazon Basics batteries (after which the problem miraculously went away!) Lesson learned: Always Use Good Batteries. It will also work with LiPo batteries, but I’m not that brave… yet! There’s even a test script in the GitHub repository that monitors battery power, tuned for LiPos.

For reference the offending AA batteries were these ones (EBL batteries which I got through Amazon):

Blummin’ things! Anyway!

All this time to test things out meant that I got to code a script to control the robot, with some help from Neil’s original test scripts and a program I’d written (for that other motor controller) that used Tom Oinn’s approxeng.input library (if you haven’t tried this out and you’re into robotics, give it a go – it’s lovely and is compatible with a lot of different games controllers.

Code and Scripts

The controller comes with a GitHub repository containing a simple-to-use library and various test scripts. These were instrumental in trying out the controller board and diagnosing the battery issue. If you get really stuck, and don’t want to install the software yourself, there’s even an SD card image linked to from the GitHub page. Neil’s really put a lot of thought into the user experience. The code he’s released works with both Python 3 (thank goodness) and Python 2 (shudder).

I’ve yet to put to the test the servo capabilities, but if you look at the bottom of this blog post, you’ll see an example of the board using servos as well as DC motors.


There are a lot of motor controllers out there, some more capable than others. If you want a controller board that does more than “just run a couple of motors”, I thoroughly recommend the RedBoard+. It’s good on price, fantastic on functionality and just oozes usefulness. Use the right batteries though – some just aren’t good enough to reliably run the Pi – stick with Eneloops or Amazon Basics or IKEA rechargeable batteries (which seem to all be the same base unit).

Put it another way: if I had to return this review unit (I don’t), I’d buy one in a heartbeat. When you consider the complexity of robotics competitions such as Pi Wars and the need to run more than just two DC motors at low speed, a controller that can handle a wide input range, can deliver high ampage to the motors and can also handle servos (including high-power servos) at the same time, RedBoard+ is what you need.

You can buy a RedBoard+ from Tindie.

Final bit

I’ll leave you with this demo video, shot by Neil himself. It shows all the functionality being used!

Potton Pi & Pints Raspberry Jam – Saturday, 23rd November, 2019 from 1pm-5pm

Fancy doing some Raspberry Pi, Arduino or micro:bit stuff in a relaxed, social atmosphere?
Fancy a chat with fellow geeky-type people?
Fancy finding out about the Raspberry Pi and other boards from first principles?
Then, the “Potton Pi & Pints” Raspberry Jam is for you!


This is an informal family-friendly event from the same team that brings you the Cambridge Raspberry Jam and Pi Wars.
We start at lunchtime and encourage people to bring along their projects to Show and Tell or to come along and find out more about the Raspberry Pi, micro:bit or Arduino and what they can do. We set up some pi-topCEED Raspberry Pi workstations for general hacking, but you’re welcome to bring your own equipment along.

This event is an ideal opportunity to get some one-on-one help with setting your Pi up or to get assistance with an ongoing project.

If you want to drop in and learn something new, we supply some Raspberry Pis, worksheets and electronics so you (and your kids, if you have them!) can get hands-on.


The event is being held in Potton, a small town on the Bedfordshire/Cambridgeshire border, at The Rising Sun, a family-friendly, dog-friendly pub. Food is available all day and is of the pub-grub variety: generously-portioned and reasonably-priced. You can read more about The Rising Sun on their website.

We’ve arranged to use the upstairs function room which has tables and chairs and plenty of space for your projects or just for talking if that’s all you want to do.

This event is a real social for Pi enthusiasts and we’re hoping it will be nice and relaxed with none of the stress and frantic nature of the usual CamJam and Pi Wars! Kick back, unwind and do stuff with your Pi.


We’ll be supplying a few Raspberry Pi workstations in the shape of pi-topCEEDs, keyboards and mice. All you have to do is come along. We’ll have some of our worksheets with us so there’ll be some activities for kids available.

Show and Tell

Feel free to bring your own Pi (or Arduino, micro:bit or other) project and whatever other electronic wizardry/gadgetry you happen to have. Please bring a 4-way adapter and extension cord just in case we run out! 🙂

Stay for a meal or a drink

At the end of the Jam (5pm-ish), feel free to join us for a meal/drink/chat. We generally go on into the evening! Everyone is welcome, so feel free to bring the whole family!



Any questions can, as usual, be addressed to Tim Richardson ( and/or Michael Horne

Raspberry Pi and micro:bit robot maker Dexter Industries acquired by Modular Robotics

American educational robotics company Dexter Industries has been acquired by fellow American robotics company Modular Robotics. Dexter Industries, the company behind the excellent Raspberry Pi-based GoPiGo and the micro:bit-based Gigglebot as well as several others was merged into Modular Robotics back in July. Since then, they’ve been integrating their operations. Modular Robotics, based in Boulder, Colorado, make Cubelets – a fantastic way to get your kids into physical computing and robotics. You start off without a screen, assembling the blocks together, before moving on to using Blockly to program more advanced behaviour.

For now, both product lines are expected to continue, which is very welcome news for this blogger – the GoPiGo in particular is a brilliant robotics kit and the visual programming environment/software that goes with it (Bloxter) is first-rate, providing a user-friendly interface to help get you started with programming your robot. I reviewed the kit and the software a couple of years ago and it’s a great starting point.

It will be interesting to see how things progress as the companies innovate and work together to create new, exciting ways of encouraging kids of all ages to get into robotics.