My Pi PV Monitor and immersion heater Journey, finished with a bash (script)

Hello everybody, this site is amazing; I've been lurking around for a month or two now and am now ready to start. I'm looking for things here that I may have missed.

There is so much info here, and I've found a lot of it, but, you can't possibly know what you haven't found, so if you can point to any good stuff that I should be aware of, that'd be great.

I've got a 12 panel ( 2 .5 KW max) PV installation talking to a SMA Sunny Boy 2500HF inverter who in turns blu-tooths to a Sunny Beam monitor. Like pretty much everybody, I tried to use as much of the surplus as I could. Started by getting an Immersion Heater Power Reducer ( for my immersion heater - which luckily had never been used or wired up before so was in good condition. Now according to my British Gas Energy Monitor this takes about 1.2 ish Kw and heats the tank up in a couple of hours. This unit was probably over priced at 50 gbp, but there you go, live and learn.

So, after a few months, of running up and down the stairs (good exercise mind) to turn it on and off as the sun goes in and out, I started thinking about some sort of automatic control and came across this site. And, I had a RasberryPi - as an old coder from just before BBC B Micro days, I couldn't resist buying one last year, but it didn't have a problem to solve - now it does!

I am a type 2 installation. I can't put a CT clip-on on my solar output as this comes to my solar meter (a JWI PRO75D) from the inverter in twin cable. So I intend to monitor it's output with a pulse sensor - is that a straight forward option?  The grid import/export to be monitored with a CT clip-on and an AC-AC sensor for it's direction.

My ultimate aim, well firstly is to have fun and enjoy the journey, and then at some time to be able to switch the immersion heater on and off according to some strategy that I might devise. In fact better than that to have a selection of plug-in strategies that can be activated according to circumstances of power available, time of day, time of year, probably other things as well.

Are there pins left unused on the Pi's gpio  after the RFM12Pi has been plugged in ?

Is there a design for a gpio output from the Pi to switch a mains relay?

I would love the option of a further halving the power as well (so that'd make it about 600watts), but I'm guessing cos my AC theory is a bit shakey, that having already halved the power with my Power Reducer which has presumably chopped one half of the sine wave off, any options to play further with it are limited?

I also toyed with the idea of interrogating the SMA inverter via blu-tooth to get it's estimation of it's output, there is a PC application around that can be used to control the inverter, but I abandoned that as the intricacies of the blu-tooth and SMA protocols seemed a bit overwhelming.

So sorry, it's a long post, but my TSL257 fell thro the letterbox today, my other stuff is on route from "The Shop", I have installed a double 13amp socket and a little shelf under the stairs where the EmonTx is going to live and I've sorted out all the hardware and power supply stuff that Pi needs to keep it happy - and, as I said earlier, I'm ready to go!

Thanks for all your help,


Robert Wall's picture

Re: My Pi PV Monitor and immersion heater Journey, finished with a bash (script)

I think you should look at Robin Emley's Mk2 controller or, if you want monitoring too, it's derivative MartinR's Solar PV power diversion with emonTx, emonGLCD and temperature measurement to solve your immersion heater problem. Both use the same underlying principle, only the software is radically different, as Robin's is completely autonomous and does not have monitoring. You can read all the details for yourself, briefly Robin's has one c.t. on the meter tail and it attempts to balance PV generation with a controlled load, so making the most of your free energy before it get donated back to the grid. It doesn't need a c.t. on the PV feed as it seeks to set up zero nett energy flow through your meter. Martin's has a second c.t. for monitoring and a display, and the ability to send logging data too.

I think you should keep on looking here. We know how to get information out of a few meters, and there's an article about Sunnyboy and Bluetooth in Building Blocks, so don't reinvent the wheel!

The best hint I think I can give you is don't use the site's search. Instead use Google like this:


(without the square brackets of course).

And of course, use the forums. There are a fair number of helpful people here with quite a bit of accumulated knowledge between them.

EricD's picture

Re: My Pi PV Monitor and immersion heater Journey, finished with a bash (script)

Thanks Robert for those pointers, I hadn't found those and they're right on the button.

Thanks also for the Google search hint, that's a real advance, I just didn't know that about Google.

Very grateful for your help.

stuart's picture

Re: My Pi PV Monitor and immersion heater Journey, finished with a bash (script)

Let me know if you need help interfacing with the SMA inverter - thats my specialty!


EricD's picture

Re: My Pi PV Monitor and immersion heater Journey, finished with a bash (script)

Thanks Stuart, that seemed to me to be an area that was almost rude not to pursue. I had downloaded the Sunny Explorer ( SunnyExplorerSetup10615.exe) but did get a bit frightened off with talk in the user manual of potentially mangling the plant.

So yes, I'll almost certainly be in touch a bit further down the road when I've got something up and going, I like the idea of getting information straight from the horses mouth a lot!

Petrik's picture

Re: My Pi PV Monitor and immersion heater Journey, finished with a bash (script)

Submitted by stuart on Fri, 19/07/2013 - 11:25.
Let me know if you need help interfacing with the SMA inverter - thats my specialty!


Does this mean that you have managed to make the smagateway working, i.e. from bluetooth to rdm12b like one of the jeelabs example scripts show ? I tried to make it today for a good two hours without success so would appreciate some help and pointers where to dig deeper...


manicmoddin's picture

Re: My Pi PV Monitor and immersion heater Journey, finished with a bash (script)

Just getting my renta roof system set up.

I am wanting to look at power diversion as we use very little in the day, but get a lot at night with washing machine etc.

For accurcy sake, has anyone ever looked into aurora inverters? This has been installed and has rs485 apparently.

Using the spare power to power a heater of types will be perfect and hopefully cut the gas bill. Also would push onto oil filled radiator so as to help dry clothes indoors.

Each day a different thing to learn.

EricD's picture

Re: My Pi PV Monitor and immersion heater Journey, finished with a bash (script)

As you can see, this project stalled for a couple of years, but I started looking at it again in June this year.

It is now up and running, and thanks very much for all the help I've received from the entries in this Forum.

My software solution was necessitated by my PV installation and immersion heater power location, and to some degree, my skills set.

Briefly I have a rev B pi running a bash script that gathers the emonTX raw data, provided by tailing the emonhub.log (set to INFO loglevel). It uses that data, plugged into a configurable strategy, to switch on/off a latching relay that controls my 1.5kW immersion heater. The script has a 10 second (configurable) delay between decisions. It writes to a log and has evolved over the weeks; it is configurable to send confirmation emails, write a CSV file for analysis and write a very verbose commentary in the log and other stuff as well. The main strategy variable are re-read on each of it's decision cycles so they can be altered on the fly. It shuts itself down in the evening (time is configurable) and emails a summary of the days's activities to me. A cron entry gets it up in the morning.

I had to lift up the rfm12pi module with a stand-off so I could get to some GPIO ports to drive the relay switch box.

The latching relay switch box, powered by two AA cells, has a 16 amp Ciseco relay in it, which is apparently good for 10 million operations. I have another script that gathers information from the ongoing log and gives a "story so far" picture, including the times of on and off and the number of relay "clicks".

On an overcast day, with washing machine and kettle activity, it clicked around 200 times. And on a bright and sunny day, or a totally overcast day it clicked maybe 20 times. Reckoning on an average 100 clicks per day gives the relay an expected life of 274 years, the batteries (Poundland's finest) may need replacing before then.

It obviously cannot react instantaneously to changing household demands or the varying solar generation, but it seems to be doing a pretty good job of heating the hot water tank without using any imported power.

Thanks again for all of your help, there's been times when I've had maybe 8 tabs open in my browser scouring through these Forum entries. Quite a journey.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.