Controlling the Maplin Robot Arm with Scratch V2 Offline on Microsoft Windows 10

In a complete departure from my previous posts, and as a result of buying one of these Arms for my kids for Christmas I thought I would write-up what I have done with it.

This is the Maplin Robot Arm  (~£29 discounted), I think originally it is made by a company called OWI from the US.

Maplin USB Robot Arm

Maplin USB Robot Arm

This is a basic arm with 5 motors and can be controlled from Windows with the supplied software or from Linux (i.e. Raspberry Pi, using some basic Python)

I was looking to see if the arm could be controlled/programmed from MIT’s Scratch programming language so that my youngest kid to join in too, and the answer is yes!

Most of the information, work (and credit) I needed to do was already done at a great blog post by Franco Raimondi.

I have updated the instructions for Microsoft Windows 10 and also modified the Python code needed so that it runs on Python 3.51.

Click to read more and the full instructions.

Posted in Maplin, Python, Robot Arm, Scratch, tinkering, Uncategorized, Windows 10 | 2 Comments

Monitoring Room Temperatures with Moteino’s and Raspberry Pi

Read about my latest use of Pi and Arduino Here.  and you can also produce data like this:



Posted in Energy, hacking, Raspberry PI | Tagged , , , , , , , , , , , | 1 Comment

Home Energy Centre using Raspberry Pi and Nook Simple Touch


Following on from using a Raspberry Pi to capture the electricity consumption of my home, I have over the last 2 years installed Solar Thermal Hot Water panels and very recently Solar PV.  This meant that I had an opportunity to create something I had been looking to do for a while – an in house portable “Home Energy Centre”. This post documents the thought process behind what I did, the choices I made and also the problems and hurdles I had to overcome to get it all up and running. First let’s talk about the Home Energy Centre.

Hec-Display on Tablet

Hec-Display on Tablet

Hec-display in kitchen

Hec-display in kitchen

This is built on a “Nook Simple Touch”, which I bought about a year ago during National Book Week for only £21!

Why did I choose this device? Several reasons really,

  1. it was cheap!
  2. It has built in Wi-Fi
  3. It is easily hackable (with Nook Manager)
  4. the battery life is good (about 1 week with wireless running all the time and the display refreshing)
  5. it has a touch screen
  6. it is small and can easily be mounted (either in a frame or on a fridge using magnetic adhesive tape)
  7. I can always re-use it as an e-book reader!

The “Home Energy Centre” (HEC) runs in the browser of the Nook.  Because it runs in a browser it can also be displayed on any device with a browser, for example PC, Laptop, Mobile Phone.

The screen is split into 3 main sections.

The left hand section displays information on how the Solar PV panels are performing; telling me what Electricity is being generated now, if any is being exported, along with the totals for the day so far.  This updates automatically reasonably frequently.

The middle column displays information on how the Solar Thermal Panels are performing, these provide hot water. So the display shows me, the current temperature of the panels, the current temperature of the water in the hot water tank; along with, the speed of the pump as a percentage and the number of hours the pump has run in total.  The lower section tells you for how many hours the pump has run so far today, and importantly what the temperature gain in the Hot Water has been so far this day.

The right hand column displays the current weather for where I live.

Along the bottom are 3 “buttons”, for now only the left hand button works and this takes me to the graphs of electricity consumption I did a while ago (See this blog post). This information all in one place and readily visible has help us decide when to use electrical appliances in the house and when to or not heat the hot water using the central heating (Gas based) system we have in the house.

 High Level Architecture

The diagram below shows the physical architecture of the setup.  The complete code is here at github.


The Raspberry Pi performs all of these functions:

  1. Receives Solar Thermal output from the Resol pump controller via its VBUS data bus and the electronic circuit, into the tty0 serial port.
  2. Decodes the data calculates values and files it ready for processing
  3. Receives over the local network, via multicast, Solar and Electricity xml packets from the Owl Intuition Solar PV monitoring and files it ready for processing
  4. Runs the program to draw the Home Energy Display (python/pygame) as a picture, this program also fetches the latest weather information from Weather Underground via the internet.
  5. Runs tightvncserver (required by pygame)
  6. Runs lighttpd server to serve the image map / web page that is displayed on the Nook, or any web browser/mobile phone.

Solar Thermal Real Time Data Solution

Getting meaningful data from the Solar Thermal panels was definitely a challenge.  I didn’t want to spend over £100 on a special LAN adapter they sell. My system has a Resol© BS/4 pump controller which has a VBUS© data bus output.  The signal this bus produces is similar to RS485 in that it is a dual polarity signal, but not exactly the same.  I designed the following circuit to process the signal and turn it into 9600 baud 0V, 3.3V serial data suitable for interfacing to a Raspberry Pi. RESOL Circuit Diagram v3 Please note this circuit is not electrically isolated from the VBUS controller, which does switch a relay for the pump which runs from mains electricity.  If an electrical fault occurs in the VBUS controller it could fry the circuit or the Raspberry PI.  In a revised version I would incorporate an opto-isolator.  The circuit is also designed only to receive data and not transmit it.  If you want to use this circuit with a device that withstands 0,5V serial data, e.g. an Arduino©, then just remove the two resisters that form the voltage divider at the output. Remember to stop the Pi from starting the default tty0 terminal on the serial port. Now that we have some nice clean serial data coming into the Pi, we need to process it.  The Resol protocol is quite unique in that it swaps MSB and LSB’s around so that only the starting byte of a sequence of data has its MSB set, &AA signifies the start of a sequence of data.  Fortunately for me, someone far cleverer than me has written a C program to do this called “vbusdecode”.  The next problem I had was that you need to know the XML format of the data for the controller you have in order to tell vbusdecode what to do.  This information is not supplied in the documentation from Resol.  After a lot of research and hunting and many false trails, I found an XML specification file in the installation files for some free software until recently given away buy Resol.  This means that finally we can decode the data coming via the VBUS.  I discovered that the BS/4 sends out three different types of data, I am only interested in one type and I want the data in CSV format, so I modified the source code for “vbusdecode” to do this. So every day a new file is created to store the Solar Thermal Data and every few minutes a new line of data is added. This file is used by the HEC display program as the source of its Solar Thermal data.

Useful Links & Credits

  1.  vbusdecode (original information) Andy White
  2.  Desrablog (where I started)
  3.  Hobbytronixs (for clues on the electronic circuit) (in German)

Solar PV Solution

This solution was far simpler and one I got working in two evenings.  The OWL© PV Intuition product comes with a device that spits out data in a multicast group on the local network.  It also has a published API and can also be configured to push data to a certain IP address and port.  I took the simple route and just used the multicast data. I have adapted an already created Python library/set of classes for receiving multicast data.  Two types of XML datagrams are received approximately every 30 seconds, one for Electricity consumption and one for PV generation and Export.  This program receives the XML data, decodes it and stores them in two files on the Raspberry Pi to process.  The code is here.

HEC Display Program

This is main program that pulls all of the data sources together and creates the Home Energy Centre display. It is written in Python and Pygame.  My original idea was to serve the display in an X-window using tightvncserver on the Raspberry Pi, and view it using the VNC client for Android.  This proved problematic on the Nook, as in order to get the VNC client on the Nook I needed to install all of the google apps and the google play store app.   This made the nook unstable. So I reverted to a different plan:  just use the web browser on the nook, and change the main program to paint (save) a picture of the screen to an image file – which is web served to the browser.  This works well in pygame and is easy to code.  I have subsequently removed the majority of the Google apps from the Nook and it is much more responsive and stable. The main program is here.

Lighttpd Configuration and Webpage.

The Pi is running a standard install of lighttpd.  It serves a very basic index.html web page like so:

<img src=“./images/frontscreen.png” border=“1”>

This serves the “picture” of the HEC display as an image map, allowing mouse clicks or touch screen (on the nook) presses to be detected and appropriate actions taken.  The page auto refreshes.  There is another version of the page in a sub directory called nook, which is the same apart from having a slower refresh rate.  This helps conserve the battery life of the nook.

Physical Installation

Everything is installed in a cupboard near to the pump controller for the Solar Hot water in a £ 3 Sandwich box!


Nook Modifications

The Nook has been rooted with NookManager.  There are plenty of articles on how to do this. For example:

For information on installing NGAppsAttack look here.

I have also made the following modifications to remove the screen saver/timeout and slow down the screen refresh method to conserve battery life.  Instructions for this can be found in this thread:

Known Problems/Irritations

The Pi sometimes locks up and is not reachable across the network.  This was cured by removing the lid of the sandwich box!

Tightvncserver sometimes locks up.

Things to improve, things to do.

Start logging the Solar Thermal Data and the Solar PV data in RRD so daily graphs can be produced (similar to what I have done previously)

Tidy up the code for the Solar Thermal side.

Implement a 5 day weather forecast using the UK Met office’s data point service and implement the Forecast Button

Implement the Automation button (that is a topic for another time!)

Thanks for Reading!

I hope you have found this interesting and it inspires you to do something with a Raspberry Pi. Also thanks to the world wide web, all of the credits listed above and Simon, Stuart, Ashleigh and Mark for putting up with me and giving me encouragement on this project!

Posted in Energy, hacking, Raspberry PI, tinkering | Tagged , , , , , , , , , , , , , , , , , , | 52 Comments

Home Energy Console on Nook Simple Touch

Home Energy Console on Nook Simple Touch

Teaser for my next blog update, this is what I have been working on, all powered by the wonderful Raspberry Pi (c) !

Image | Posted on by | Tagged , , , , , , , , , , , , , , , , , , | Leave a comment

What does Ironing look like?

As an example,  below is a graph of the electrical consumption of an iron.  You can clearly see the spikes and drops of consumption as the element of the iron switches on and off to heat itself.  The on-off switching is modulated (on top of) the base load of the house.  The base load switching is primarily caused by the compressors of the two fridge freezers I own switching on and off.Electric Profile of an Iron

Posted in Uncategorized | Leave a comment

Monitoring Home Electricity Consumption with a Raspberry Pi – part 2

1. What you need

  • A Raspberry Pi
  • A Current Cost Meter
  • A RJ45 to USB converter cable

2. Setting Up the Raspberry Pi

Install the latest version of the Rasbian image onto a suitable SD card, insert into the Pi, connect to a network and boot-up.

If you need help follow the instructions here at the Raspberry Pi website.

3. Get the necessary software packages

With the Pi connected to a network with Internet access run the following commands (some may take a while and you may have to confirm with a “yes”):

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install lighttpd rrdtool
sudo apt-get install python3-dev python3-numpy

This installs all of the necessary packages we need.

4. Download and Install PySerial

PySerial is used to communicate with Serial Ports (here a USB port) and handle receiving the data from the Current Cost Display.

To download PySerial do the following (as the user pi , with a home directory of /home/pi)

cd ~ ; mkdir pyserial
cd pyserial

On the Pi start a graphical display (startx) open the Midori Browser and navigate to 

Download the latest version of PySerial (was 2.6 in May 2013) and save it into the pyserial directory you created earlier.

Either at the command prompt, or in a Terminal Window:

cd ~
cd pyserial
tar -xvpf./pyserial-2.6.tar.gz  # check the file name is correct
cd pyserial2.6                  # dir name = version downloaded
sudo python install    # this installs pyserial

5. Add the user Pi to the dialout group

To be authorized to use the USB port the user Pi has to be a member of the Linux group called “dialout” to make this so, enter:

sudo usermod -a -G dialout pi

6. Download the web-site files, lighttpd config files, RRD and Python scripts.

Go to the following URL on GitHub and download the powermon.tar file and save in the home directory of the user Pi (i.e. in /home/pi).

tar -xvpf./powermon.tar

This will unpack several subdirectories.

7. Setting up the webserver/website
The next step is to install the web site files in /var/www and setup the lighttpd configuration.
At this point think of a user id (not Pi !) and password for accessing the website.
Edit the light.user file, and copy the config files.

cd /home/Pi/currentcost/lighthttpd
nano light.user         # edit the file (see below)** and save.
sudo cp light.user /etc/lighttpd/light.user
sudo cp lighttpd.conf /etc/lighttpd/lighttpd.conf

**Replace user:password with your-user-id:your-password and save it again.

Install the web site files by:

sudo chown -R pi /var/www
sudo chgrp -R www-data /var/www
sudo usermod -G www-data pi
cp -rp /home/pi/currentcost/www/* /var/www
cd /var
sudo chgrp -R www-data ./www
sudo chmod -R 760 ./www
cd ~
sudo /etc/init.d/lighttpd restart

The last command will restart the webserver.
If you open a web browswer and point it at the IP address of your Raspberry Pi (e.g. http://192.168.x.y) then the front page of the web-site should appear. If you click on a link, you should get challanged to enter the user id and password you specified above.

8. Creating the RRD store

This is the file that stores all of the data recieved from the Current Cost Meter.  To create this do:

cd /home/pi/currentcost/setup

9. Installing the Powermon service and crontab entries

To install the powermon service (which automatically starts the data collection python script at bootup) do the following:

cd /home/pi/currentcost/init
sudo cp powermon /etc/init.d/powermon
sudo update-rc.d powermon defaults

To install the automatic (cron) jobs to update the graphs do the following:

cd /home/pi/currentcost/setup
crontab -e       # go to the bottom of the
# comments and read in (CTRL+R in nano)
# the pi_crontab file
# save the file (accept the offered file name)
# check this has worked by running
crontab -l

10. Start the data collection service
To start the data collection service issue the following command:

sudo /etc/init.d/powermon start

You should now be collecting data .. wait 10 minutes and check your website.

Posted in Energy, hacking, Raspberry PI, tinkering | 17 Comments

Monitoring Home Electricity Consumption with a Raspberry Pi – part 1


A couple of years ago I was lucky enough to be given a Current Cost Energy Meter like the one in the photos below.  This type of device comes with a Hall Effect Sensor which goes around the Live Cable to your Electricity Meter and a display unit.  The two communicate with each other using Bluetooth.

After a while using the Meter and looking at the display, I did quite a bit at home to reduce my electricity consumption, including changing  light bulbs for cost efficient LED ones, I purchased one of these remote controlled plug sets to be able to switch devices (TV, Computer, Xbox etc.) off of standby when they were not being used.

Current Cost ClassicHallEffectSensorI discovered that the Current Cost Classic transmits data out of the socket on the bottom of it.  It looks like an Ethernet connection, but the signal coming out of it is TTL logic serial data.

I decided to see if I could capture this data and do something useful with it.

I purchased a RJ45 to USB cable from the CurrentCost Online Shop and after some “googling” managed to get it to work..

The rest of this blog is about how I used a Raspberry Pi to capture and display the electricity consumption of my house.

Solution Overview

The Raspberry Pi automatically reads data from the Current Cost Meter, processes it, stores it, graphs the data and serves it out on the web to be viewed by a client with a web browser.

I use the following configuration/packages to achieve this:

  • Current Cost Meter via the RJ45 to USB Cable sends data to the Raspberry Pi (Rev 1 Model B) running Rasbian via one of the USB Connectors.
  • The data is captured, processed and stored in RRDTool using PySerial and some hand cranked Python code.
  • Using automatic cron jobs RRDTool is used to create graphs which are dropped into the structure of the simple website being served by the Raspberry Pi.
  • Lighttpd is used to serve the Website to my home LAN
  • I have used port forwarding on my Broadband Router to enable me to view the website from the Internet i.e. work etc.  The website is password protected. For reasons which will become clear!

Website Design

I deliberately kept the web site design very plain and very simple to ensure that the Pi is not overloaded and also so that the site can be viewed from PC”s, iPad and also Android phone.  And actually I am not very good at html!

Home Page

Home Page

This is what the site looks like, a front page, links for Electricity Consumption for the last 10 mins, 2 hours, 4 hours, last day, last week and Temperature in the last day (the Current Cost device has a temperature sensor in it).

And alongside are examples of the other pages of the website.






Last 10 minutes

Last 10 minutes

Last 4 Hours
Last 4 Hours

Last day
Last day

Last Week (incomplete)

Last Week (incomplete)



RRDTool allows to do calculations on the data, and therefore for the graphs I compute the Average and the Maximum.  This is not too noticeable on the shorter timescale graphs, but you begin to notice the effect on the graphs for the last day and the last week.

Also I calculate the load factor, which is expressed as a percentage on the graph where 100 = a load factor of 1.

The Load Factor is normally at 100 until something with a motor switches on or off.  This is most obvious when the Washing Machine motor switches on, but I have also seen the load factor change when the central heating pump comes on and the compressor for my two fridge/freezers.

The Current Cost display spits out a reading every 6 seconds, which means it is quite good at capturing peaks or spikes in energy usage.  This means that for example it is possible to start to identify what appliances are being used in the home, by their signatures.  This includes items like Kettles, Irons, Fridge Freezers etc.

The corollary of this is that, with a little bit of knowledge, it becomes possible to know if a house is occupied or not.  This can be used for positive or less positive reasons.  If you are on holiday you might not want to see your kettle being switched on! Equally if  you are monitoring the electricity consumption of an Elderly relative or friend you might want to check that they have made their cup of early morning tea by 10am.

It is for these reasons that the website I created is password protected.

In the next blog post I will go into detail on how to setup your Raspberry Pi to monitor your electricity.

Posted in Energy, hacking, Raspberry PI, tinkering | 10 Comments