Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


#157253 25-Nov-2014 11:38
Send private message

Hey guys,

I am in the process of building my own solar H2O controller. I already have the evacuated tubes on the roof and have been running them via the standard solar controller installed when I built the house for 3 years. The system has been working like a charm but I want to extend it and monitor the HWC temps as well as track when the pump is running etc.

So I have built a DIY controller using an Arduino UNO with DS18B20 temp probes (for HWC temps) and a MAX31865 breakout board to read the RTD PT-1000 temp probe installed in my collector. I have written the Arduino sketch but wanted to see if any experts out there had any feedback or suggestions for things I might have missed or could improve!

Should be pretty obvious what is going on, here are the various config values I have defaulted to;

// adjustable configuration parameters
const double temp_diff_on = 10.0;
const double temp_diff_off = 8.0;
const double temp_hwc_max = 85.0;
const double temp_col_emerg_off = 130.0;
const double temp_col_emerg_on = 120.0;
const double temp_col_max = 110.0;
const double temp_col_min = 4.0;

The sketch code can be found at this link (can't seem to find a way to attach a file to this post);

 


http://openenergymonitor.org/emon/node/6165

 


Cheers,
Ben

View this topic in a long page with up to 500 replies per page Create new topic
 1 | 2
Aredwood
3885 posts

Uber Geek


  #1183040 25-Nov-2014 22:34

Sweet. You have basicly copied my system. Only thing you need to add in is some code to detect sensor failures. As Im also using the DS18B20 sensors. Only I have 9 of them monitoring various things. I have had wiring faults cause all the sensor temps return as -128 (Same as what happens if I disconnect a sensor). Yet have also had a wiring fault that caused all of the temps to return as 0. Have yet to figure out what exactly is happening when that occurs. Another issue I have - sometimes I have a burst error that causes just 1 sensor to return -128 It is random as to which one. (would be related to the number of sensors and amount of wiring in my system).

I need to add sensor failure detection code into my own program. As after I do this I will be able to do more advanced things that require statefull control. My code uses 6 outputs, but only 2 have things connected to them at the moment.

Also if your bottom temp sensor is higher than the flow connection to the cylinder (pipe from panel to cylinder). Use the bottom temp sensor instead of the top one for restricting cylinder temp. Otherwise if the cylinder gets hot enough to go into overheat mode. It won't come out of it again until the top sensor cools down enough for it to go back into normal mode. Even if the bottom temp sensor says the cylinder is cold. Which will happen if cylinder fully heats and you then draw off some hot water. I have had plenty of times where the top of my cylinder is about 85. But the bottom is only around 25.







  #1183042 25-Nov-2014 22:41
Send private message

Awesome - glad to hear someone else is doing this! Yeah, I need to have a look at my sensor failure code. The RTC sensor returns a nice error code (via the MAX31865 breakout board) so that is easy to trap, I need to do some more investigation for the onewire stuff. I am using some code I found to do the temperature reading in the *background* so the Arduino can continue monitoring my MQTT broker for other messages - this Arduino is also responsible for controlling my underfloor heat pump and alarm system via a set of relays. So there are a number of other things it is handling as well as the solar controller.

I see what you are saying about the difference between bottom/top sensors for temp restricting. So do you always use the bottom sensor? Or just use the lowest of the two?

Would you care to share your sketch? Would be interested to see how you have coded yours up. More than happy to share mine if you are interested.

Cheers,
Ben

Aredwood
3885 posts

Uber Geek


  #1183710 27-Nov-2014 00:25

Yes would love to see a full copy of your program. Here is mine.
https://www.dropbox.com/s/l1qs6o86q1akisd/Temp_controller_v3.ino?dl=0

This project is the very first thing that I have used an Arduino for. So it has been a steep but fun learning curve for me. So not surprising my code is not very elegant.

If my cylinder gets too hot it dumps heat into my radiator central heating system. So my cylinder can never overheat. (switches on pump that transfers heat between cylinder and central heating). Hardware is an Arduino Uno, With 8 channel relay shield and 16X2 LCD display shield.

Plumbing is 300L mains pressure stainless steel HWC. With top and bottom element ports and temp sensors. And boost element installed in top port. 50 tube solar collector (30 tube + 20 tube) direct connected to cylinder via pump. Homemade 3 way water/water/water heat exchanger to allow heat to transfer between mains pressure drinking water (from HWC), low pressure closed circuit central heating water, and spa pool water.

New features I need to add into my code.
-Modify heatdump code to dump waste heat into spa pool (requires wiring changes also)
-sensor failure detection, Needs to retry on fail. And then set a default safe reading after say 10 fails in a row. And / or run some different "safe mode" code.
-Stateful operation support, Will allow me to write test routines that do things like switch pumps on and off, and monitor flow sensors to check both pump and flow sensors are working and not stuck either on or off. Or to record if the heat dump routine ran or not during the day.
-Program delays without using the DELAY command, So I can have instant response when I add sensors other than temp sensors.
-Utilise the buttons on the LCD display board for a simple menu system to view / modify set points.
-Code to manage operation of my boiler, spa temp, and electric boost element. All currently done via manual control.

As for your setup - is this your cylinder? http://openenergymonitor.org/emon/applications/shw#software If so then be careful - as the max temp and pressure that polybute pipe can handle is 82deg @ 600KpA. For that reason the flow and return pipes to my panels are copper. Also that cylinder should have a TPR valve on it (temperature and pressure relief valve) As a backup for over temp and pressure conditions.







  #1183812 27-Nov-2014 09:03
Send private message

Awesome - thanks mate. Here is a link to my sketch (let me know if it doesn't work, never shared stuff on Dropbox before);

https://www.dropbox.com/sh/d73yvqlmri5y30m/AAB-dAuL63lCQAKBWXzXuJJQa?dl=0

I have only been doing stuff with Arduinos for the last 6 months as well, so excuse any stupid mistakes in my code! This code is not in 'production' yet although I have done a fair bit of testing. The node is also responsible for controlling/monitoring my underfloor heating system and monitors a flood sensor under my HWC. That is the monitor_pins stuff which just detects any state change on those pins and publishes an MQTT message - my home automation software (openHAB) listens for those messages and takes the appropriate action. Likewise, openHAB can send commands via MQTT which results in this sketch switching a digitial pin HIGH/LOW.

So if you ignore all that code you will see the temperature monitoring stuff, both the RTD PT-1000 and DS18B20 sensors. I have pretty good fault detection for the RTD sensor (which came from an example sketch that came with the digital breakout board I am using to monitor that probe) but I haven't quite worked out how to detect sensor failures for the DS18B20s. The basic examples for reading DS18B20s is not very efficient, since the sensors are quite slow to read and the Dallas libraries have very long built-in delays to ensure a reading is obtained. This renders the Arduino busy while the readings are being taken. So I found some code which sends off a request to each sensor (I have 3) to begin taking a reading. The Arduino then keeps looping and can process other tasks. Each loop we check to see if the sensors have completed their reading, and once they have we take the values and update our state variables.

This works very well and means you can have a very responsive device (i.e. for reading MQTT messages etc) whilst the DS18B20s are doing their slow temperature readings. The tricky bit is detecting failures which I haven't looked into in any detail yet. I think perhaps a simple check that resets the temperatures to an error value if they are not updated after a few seconds would probably work - I will look to add this to the code this weekend hopefully.

Then it is just the logic for controlling the pump. I don't have any display since all temperatures and pump state changes are published to MQTT so it is easy for me to monitor there (and is where openHAB will be monitoring from). The plan is to allow configuration via MQTT as well - this is the beauty of MQTT! 

I have a solar ready SS 350l HWC, with middle and bottom elements and 3 temp sensor ports. Sounds very similar to yours. I have a 40 tube collector (2x20) directly connected in open loop to the HWC via a circulating pump. I have copper flow/return pipes up to the collector - the ones with foam insulation. The HWC has a TPR valve on top as well. So I think we probably have very similar setups - aside from your custom heat exchanger bit.

Having another dump load would be very handy but I just don't have anything suitable. I do have hydronic underfloor heating but that is a closed loop circuit between the manifold and the air-to-water heatpump. I am concerned if I tried diverting hot water to that I would introduce air and cause issues potentially. Plus I only generally have excess hot water in summer, when I don't want the underfloor to be warming up. 

I will have a look at your sketch in detail this weekend, thanks again for sharing. 

  #1184532 27-Nov-2014 23:17
Send private message

I have had a look at your code - nice work - got quite a few outputs getting switched there!

About the only thing my DIY version won't do that the original controller does, is control the pump speed. According to the docs and my controller settings, the min speed is currently set to 90%. So I take that to mean that as the temp differential starts to drop between the collector and HWC, the pump speed is reduced, until it hits 90%. Therefore I am not sure that my DIY version, which will either run the pump at 100% on, or 0% off, will be noticeably different. 

I just made some changes to my sketch, but haven't tested it yet. Have a look if you are interested. I have added some more robust temp failure detection for the DS18B20s by checking the CRC in the sensor reading packets. I also have a timeout, since my readings are done in the background, so that if 2 secs go by without an update I restart the temp reading process.

I have also added a load of MQTT configurable parameters - so I can adjust the various controller threshold temps, and enable/disable holiday mode etc.


Aredwood
3885 posts

Uber Geek


  #1184558 28-Nov-2014 01:08

All I will do for sensor failure detection is check for values lower than -25 Which will mean a sensor has failed or is disconnected. And if a sensor returns a value of 0 Check if the other sensors are as well - if so then there is a wiring or cable fault. Also to get program delays without using the DELAY command. look up the example sketch "Blink without delay" One of my mates who knows way more about Arduino programming than me. Says he just uses that code for program delays. So you can just wait a second for the sensors to take their temp measurements. Yet the rest of your code will still execute as normal. I will look up the part code on the main IC on the relay board. As they interface via the I2C bus Meaning you can stack more than 1 on the same bus. And each IC has 16 I/O pins. And if you use them for inputs. They can be configured so the IC will cause an interrupt when a pin changes state. Meaning your code doesn't have to constantly check pin states just to wait for a button to be pressed.





  #1184601 28-Nov-2014 08:04
Send private message

Yep - that 'Blink without delay' is basically what my sketch is doing for the DS18B20 reads - only it doesn't wait a fixed time but just until the sensors have data ready to receive. Depending on the resolution you can get very quick readings using this method. Here is the forum post I found this code on if you are interested - https://lowpowerlab.com/forum/index.php/topic,666.0.html.

Yeah would be interested to know what the part number of your IC. Having multiple interruptable pins would be good - I am using interrupts on a couple of my other Arduino projects (battery poweree RF entry gate sensor and weather station) but the standard Arduino chip typically only handles a single interrupt (I think...). Having a chip which does its own interrupts would be great - as you say I could bin all that monitoring loop code and debounce stuff - although it has been working perfectly well for 6 months.

So are you running this solar controller currently in production/live? I am getting close to growing the nuts to deploy mine...

 
 
 

Cloud spending continues to surge globally, but most organisations haven’t made the changes necessary to maximise the value and cost-efficiency benefits of their cloud investments. Download the whitepaper From Overspend to Advantage now.
  #1184602 28-Nov-2014 08:05
Send private message

PS - were you able to view my sketch on that Dropbox link I shared?

Aredwood
3885 posts

Uber Geek


  #1189617 5-Dec-2014 21:30

Sorry only remembered this thread just now. That IC is the MCP23017 And this is the relay shield Im using on my solar controller. http://www.freetronics.com/collections/shields/products/relay8-8-channel-relay-driver-shield Unfortunatly that shield only uses 8 out of the 16 I/O pins that the MCP23017 has. (unless you can solder flyleads onto the pins of a surface mount IC). Although yes there is a through hole version of that IC to make things easier if you are going to build your own boards using it. Datasheet - http://ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf

And yes I was able to view your dropbox link, - Thanks. Haven't been able to have a good look at your code yet - have only skim read it.

My solar controller has been live for almost the whole time that I have had my panels installed. Before that I simply left the circulating pump running all day. (only about a month between installing panels and making solar controller).





  #1189756 6-Dec-2014 09:09
Send private message

Cheers for that - was already looking at that relay board from Freetronics but have decided to just stick with a couple of 4xrelay boards and address them individually. I have just enough spare pins and only need 6 relays currently so should be fine for this case. 

  #1222798 26-Jan-2015 21:45
Send private message

As a follow up, after trialing my DIY solar H2O controller and running into a few issues with the RTD thermistor in the collector, and getting bad readings from my DS18B20s, I decided to stick with the factor controller and updated my Arduino sketch to monitor the HWC thermistors (NTC 10Ks) parasitically. This has allowed me to leave the controller in place and just monitor the voltage drop across the thermistors using the analog pins on my Uno. I managed to calibrate nicely so I am within half a degree of what is reported on the controller LCD.

This is all I really wanted - to be able to monitor my HWC temps (I have three probes) - and foolishly decided I needed to replace the whole controller so I could use the DS18B20s which I thought would be easier to read!

Anyway, all working nicely now, and reporting temps over MQTT to my home automation system. I already have rules to send me alerts when the HWC gets above 80 degrees, and to only enable my PV diverter (to send excess generation to the HWC) if the temp is below 50 degrees (and shut off once it hits 60). 

Thanks for all your help with this.

mattosaur4
40 posts

Geek


  #1234040 10-Feb-2015 12:04
Send private message

Hi

Thought I'd try asking this here as you guys seem to know a fair amount about Solar Systems and making your own.

I've recently moved into a house with a Evacuated Tube Solar Hot Water System and LCD Panel based controller.  I guess they are all fairly similar?  The manual isn't the clearest (chinese english), so I was wondering what a good setup is for the options it has.

Pipe Timing
Heat Timing

From what I can tell from the manual Pipe Timing is the set periods of time I specify where it pumps hot water from the roof for 3 mins every 15mins when the temp difference is reached.

Heat Timing is where it checks if the temp difference is 8-10c and then turns on the Electric heating if needed.

So my initial thoughts were Heat Timing should be something like 6-7am as we get up at 7am and again at say 5-6pm before we come home from work.

Pipe Timing I'm less sure about, the factory defaults are something like 4-6am and 5-10pm.  Do I want it moving water at these times into the tank, wouldn't it be better to move it when it's at it's hottest? 4pm type thing?  Is it better for it to unload the whole lot twice a day? Does the pump use much power?

Any recommendations, for maximum power savings, whilst still having hot water based on NZ's daylight savings etc...?

Thanks,
Matt

Aredwood
3885 posts

Uber Geek


  #1236012 11-Feb-2015 20:25

The pipe timing as you have explained it makes no sense. There is no advantage in restricting when the pump can operate. My homemade controller just compares cylinder and tank temps to control the pump.

If the instructions are online please post a link to them.





mattosaur4
40 posts

Geek


  #1259585 15-Mar-2015 10:09
Send private message
Aredwood
3885 posts

Uber Geek


  #1259760 15-Mar-2015 17:27

Pipe timing is to control a secondary circulating pump that circulates water from the cylinder, around the pipes in your house, and back to the cylinder. (ring main system) Used when you have hot taps that are a long way from the cylinder. Therefore it is nothing to do with solar panel operation.





 1 | 2
View this topic in a long page with up to 500 replies per page Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.