Home Energy Centre using Raspberry Pi and Nook Simple Touch

Introduction

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.

sw-architecture

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:

<html>
<head>
<META HTTP-EQUIV=“refresh” CONTENT=“15”></META>
</head>
<body>
<img src=“./images/frontscreen.png” border=“1”>
</body>
</html>

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!

HEC-installation

Nook Modifications

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

http://www.babblingengineer.com/how-to/how-i-turned-my-nook-into-an-e-reader-monster/

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: http://forum.xda-developers.com/showthread.php?p=29113425

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!

Advertisements
This entry was posted in Energy, hacking, Raspberry PI, tinkering and tagged , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

23 Responses to Home Energy Centre using Raspberry Pi and Nook Simple Touch

  1. Pingback: Home Energy Centre using a #RaspberryPi and Nook Simple Touch | Raspberry Pi Pod

  2. Sean says:

    Thank you for your sample code – I plan to use a lot of it for my house!. I have a vbus/net interface to a Resol BS/3, and a SMA inverter on my PV array, so your code isn’t 100% what I need, but I’ll be able to make it work. I also will be using a kindle for my WWW browser, and might even make an interface for my smart TV 🙂

    When I get the vbus/net and SMA protocol support added, if I send you patches, will you include them in your HEC package ? As I make patches/enhacements I’ll send them to you…if requested.

    • David Moule says:

      Hi Sean, I’m having problems leaving messages her so I am trying some direct replies. I’m going to build gazza’s circuit to try and download data from my Resol solar heating (hot water) controller. Would you be able to point me the direction of what files I need to load onto to raspberry pi. I assume its the ones in the Resol folder on Github.

  3. Great goods from you, man. I have understand your stuff previous to and you’re
    just too excellent. I really like what you’ve acquired
    here, really like what you’re saying and the way in which you
    say it. You make it entertaining and you still take care of to keep it smart.
    I can’t wait to read much more from you. This is really a
    tremendous website.

  4. bnew019 says:

    Wow thank you. I have been trying something like this with the Nook Touch Simple for ages, and just came across your blog with the xda link how to disable the screensaver!

  5. ps915 says:

    How did you rotated your screen/browser?

    • Gaz99 says:

      Hi ps915, sorry for the delay in replying. Initially I could not remember! However after some digging I found the answer.
      The Nook Manager software used to root the Nook, has in its home screen a settings icon (a cog). Note this is not the same as the built in settings screen for the Nook.

      One of the settings option is called “Screen Orientation” and I chose the option “Force to Landscape”.

      I hope this helps, regards Gaz99

  6. zero says:

    Hi
    I use your circuit to get data from my RESOL DeltaSol BS Plus v2. I read data from DeltaSol in every minute. Sometimes I get CRC error. (Sometimes one error per month or 2-3 error per day. So the period of good work very different). I use in my circuit LM393P instead of LM339N and 5k resistor instead of 5k1 resistor. What is your opinion the problem is in two component or other thing? (eg. noise in vbus cable, i use siple two pair cable without shadow)?
    When you plan to make the revision version (with the optoisolator)?
    Thanks
    Sorry my bad English

    • Gaz99 says:

      Hi Zero, I do not think that there is anything to worry about in the changes to the circuit you have made. One thought, I have twisted the two wires from the pump controller to the circuit, this helps to stop interference. Perhaps try this. Regards Gazz99

  7. Alfredo Sola says:

    Hi, I have uploaded it to 123D circuits. It is called vbus-to-ttl-converter. Sorry, can’t add the full URL; antispam protection I suppose.
    Corrections and ideas welcome. In particular, I’m not sure about the RJ-45 positions.
    Also, what license would you like it to have?
    Thanks.

  8. Farsonic says:

    Got any spare boards printed?

  9. I ended up purchasing three PCB’s from 123Dcircuits through OSHPARK.com. I will probably end up with a couple of PCB’s left over that I might part with. If anyone is interested let me know.

  10. David Moule says:

    Francois, I would be interested in purchasing one of your spare circuits if you decide to part with them.

  11. David Moule says:

    Dear Gaz, thank you for publishing such a really useful article. Earlier this year I installed solar panels to heat my hot water. I have a resol controller but as you correctly point out, the data logger is around 300 euro to buy. Fortunately I was gifted a Raspberry Pi as leaving present from work, so now I have the opportunity to start collecting data. I have ordered all the parts to make up the circuit on a breadboard but I’ve just noticed in your “sandwich box picture” that the circuit board has a power supply to it. This may seem a daft question but is this power supply a discrete feed or can it be taken from the Raspberry Pi? If it is discrete feed could you tell me what type of product I should be looking for in the electronic components store. Thanks.

    • Gaz99 says:

      hi David,
      I used a separate 5v supply, but the circuit current draw is minimal, you should be able to use the same 5v supply as for the Pi. Make sure it is a 2A supply.

  12. David Moule says:

    Hi Gary, one more question. In your article you mentioned a safety upgrade to the circuit using an opto isolator. I’m not any good with electronics but from googling it, would I be correct in saying that the opto isolator would be inserted into the VBUS input path so that;
    vbus a connects to pin1
    vbus b connects to pin 2
    pin6 would connect to 5v
    pin 5 would connect to where vbus a originally went
    pin 4 would connect to where vbus b originally went.

    I havent bought the opto isolator yet!
    Thanks

    • Gaz99 says:

      hi, not quite. The VBUS signal is differential, and has to go through the comparitor first. I would put the opto-isolator between the output of the circuit and the input to the Raspberry Pi.
      The purpose of the isolator would be to protect the Raspberry Pi, which is the most expensive part.

  13. gazzat5 says:

    Have a look at the android app electricsign which takes a screencap of a website refreshed at set intervals. Can be used in conjunction with the nook default screens aver to display info like this without having the browser running / browser bar visible

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s