I have used the 2 channel non invasive sketch, to build a device which monitors how much power is being used in the home, and how much power is being generated by the solar panels. If I am generating more than I am currently using, then the excess power is diverted to an immersion heater - to heat domestic hot water. This is a better option than it flowing back to the grid for which I don't get paid (solar renta roof).
This was a steep learning curve as I have never worked with a microprocessor before, but great fun and a great sense of acheivement when it actually works!
The first version was built on a Arduino Uno board, with the input components mounted on veroboard, but then I decided to build it as a standalone, with everything on one board.
The LCD is reclaimed from an old alarm keypad, and I had a USB panel socket laying about so I used that for the 4 CT input connections. (did I mention that I am a Yorkshireman...)
As the peak solar power generation is 3.5kw, I used a shunt resistor to range up to 5kw, but fitted clamping diodes (Glyn's idea - see forum) to ensure that the mains usage did not exceed 5kw and damage the Atmega chip.
With a bit of sawing and hacking, managed to fit the PCB into a Maplins project box.
Here you can see the power results, which if less than 1kw displays in watts, otherwise kw's.
The tiny LED is multi function and indicates;
1) flashing every 4 seconds - indicates that the unit is functioning, but not enough solar power to activate either relay.
2) steady but lit 25% - indicates that 500w is being unused, and activates relay 1, with a diode in series to limit the load to 500w (yes it does work, I've done the sums on the leccy meter!)
3) steady but lit brightly - indicates that in excess of 1kw is being unused, switches off relay 1 and activates relay 2 which delivers a full kw (which is the rating of the immersion heater).
The button is a menu navigator, and switches between displays (copied from another project).
This display shows how much power is generated within a 24hr period, before resetting back to zero at midnight. There is no external timing here, just a simple millis() counter which resets every 24hrs. On startup, the counter resets after 12hrs for one occassion ( so if it's powered up at midday, it will reset at midnight and every midnight thereafter.
This display shows voltage and power factor, which of course is needed for calibration purposes.
To calibrate it, I took the readings from the LCD, removed the chip and wrote the new sketch via a Arduino Uno board, before replacing it in the standalone.
The sketch is posted here , please feel free to make any suggestions or create a new version of the paste in pastebin., and although a new guy to Arduino's/programming, if I can help, please email me at (the last word in bold in this post) @gmail.com
Sketch has also been uploaded to OpenEnergyMonitor. Download it here
...UPDATE 7th Sept
Following Glyn's advice (in comments below) I have built a Nanode, and have connected both units via their Rx/Tx serial bus, and use a simple Serial.print statement in the above device, to be decoded in the Nanode by the CmdMessenger library.
Data is then uploaded to Pachube every 20seconds by the Nanode, provided that the data values have changed.
Many thanks to Trystan & Glyn
yorkshirepudn
Please post any comments and questions about the Solar PV Manager system to the forums
Re: Solar Power Manager
Thanks - I'd better make some progress then!
There should be no specific compensation needed for the immersion heater: the control loop will just try to keep the grid current to a small value in the export direction. Damping it correctly will probably be a challenge.
It would be a pity if another chip were needed to produce the pulses. I'm very new to this so haven't really got a handle on it yet, but you've got the micros() function which could be used to get fairly accurate timings, assuming your loop iterates quickly enough. Am I right in thinking that it is limited by the speed at which ADC samples appear? I see that the microcontroller has three timers and interrupt capability, so perhaps something could be done with that? I haven't worked out how you are managing to call delay() without losing samples.
I presume a power MOSFET would have to sit inside a bridge rectifier, so would probably be less efficient than a triac after you take into account two diode drops. The triac would be bolted to a nice earthed metal case, and the worst that could happen would be that it would fail short circuit, just putting the immersion heater on "manual".
Re: Solar Power Manager
Fantastic work Paul! It looks great in that box. I'v uploaded the code to OpenEnergyMonitor and attached it to your post as a more permanent solution than paste bin. I'v kept your link to past bin.
Would you mind adding you email to the end of the post so any questions could be directed to you?
Re: Solar Power Manager
Cheers Glyn, I am well pleased with the project, and today has been the first full day since installation.
It has diverted 2.4kWh to the immersion heater today and has met our total hot water needs, so the gas boiler didn't even need to fire up, reducing our gas power usage.
I wish I had used a ethernet/pachube output though, because I could check the status via my iPhone instead of having to go into the garage and look at the LCD.
Can you suggest a low cost solution to get this data to pachube - with or without the LCD. My router is about 3mtrs away from the unit.
Re: Solar Power Manager
Hi Paul,
Probably the cheapest and most flexible option is to use a Nanode. There is a code example of uploading data to Pachube using the nanode here. You have the luxury of having your router so close, so wireless transmission will not be required. The Nanode could exchange serial data with your other arduino on the Rx and Tx pins. On the Nanode the Rx and Tx pins are broken out to the green terminal block. One power supply could be used to power both boards.
Thanks for adding your emai btw!
Re: Solar Power Manager
Thanks Glyn, could you clarify a few points please;;
1) As I am not using a Arduino Uno board, do I use pins 2 & 3 (D0 & D1) from the Atmega 328 to gain access to Rx & Tx, and is it a simple wired connection from Tx on the Atmega to Rx on the Nanode, and from Rx on the Atmega to Tx on the Nanode?
2) The Nanode sketch is pretty scary, how much additional programming would be needed in both the Atmega & Nanode sketches to make this happen?
You will probably have realised by now that I am running uphill!!
Re: Solar Power Manager
Yes that's it.Maybe do some testing using a normal Arduino talking to the Nanode if you have a spare one laying around.
Not much extra should be needed on your Atmega, just a few lines to serial print out the data you want to send to the Nanode. On the Nanode the data needs to be received, stored in the correct variables then posted to Pachube. If you want to send multiple variables you could send them in CVS format then use this sketch that some friends of mine wrote to decode/convert the serial data stream back into variables.
It would be a good idea to test out posting some test data to Pachube using the Nanode with it stand-alone to begin with. I've not actually used that sketch or am experiance in using pachube. I've head other people having success with that sketch.
Good luck,
Re: Solar Power Manager
Thanks Glyn, I have ordered one from Ken, so no turning back now!
Re: Solar Power Manager
Paul, Good work, This is just what i have been trying to do, but without as much success as you have had!.
I have had the system working, but with a 3 kW immersion heater, and using a Triac to limit the power to that available, but your stand alone method is a very elegant solution, is there a chance you could publish the vero board layout ?
Regards Steve
Re: Solar Power Manager
Steve, I too have considered triacs, and especially the linear power controllers (Crydom), but they are not totally linear in operation and difficult to match supply/demand.
I also considered fitting a full wave bridge rectifier to the load, and using a Mosfet to control the power via PWM...
Eventually, I went for the relay option, which is a safe and logically dependable option (but maybe not the most efficient!), but I accept the trade-off.
I sketched the veroboard layout on paper but made a number of mistakes, which were corrected post build, so give me a couple of days, and if I can, I'll post it.
Paul
Re: Solar Power Manager
Thanks Paul, I was using PWM to control the Triac, from an Arduino dimmer project published elsewhere. It works fine, although you need a big heatsink or the Triac overheats and will avalanche, also it is safer to use an isolated tab Triac in case you accidentally touch it while it powered up!!
To get round the supply/demand problem I had to wire the immersion heater circuit outside the c/t otherwise its seen as load and the system see-saws. I do this by putting the c/t on the neutral to the consumer unit and passing the immersion heater neutral back through the c/t, thus cancelling the I/heater load. Luckily I have 16mm tails, I'm not sure if you could fit both in the c/t if you have 25mm tails. It's at this point I should say I'm a qualified electrician, and that anyone thinking of trying this at home should take care not to electrocute themselves... or use the services of your friendly neighbourhood electrician
Steve