Solar controller

Hello my name is Joseph Nohs. I am a plumbing contractor in ny. I have recently been installing solar thermal systems here and have use stecca solar controllers. I will soon be installing a system on my home and I recently purchased a bunch of arduino components and have decided to make my own controller.
This unit will be monitoring:
3 thermostats
and activating 3 relays that control
1 circulator
1 burner control circuit
1 solenoid 2 position valve
in addition i will need:
data logger
screen
4 buttons for menu navigation and variable changes
a clock

I have a mega 256 and a speed seed relay sheild

I would like to know the best temperature sensors for this application and any additional hardware I need such as witch screen, witch buttons,witch SD storage

I am a novice but i feel as if i can see the code allready it is so simple it cant be more then a hundred lines of code for this to work plus some shield libraries.

this is the basic concept

1 read all temperature sensors and log with time
2 if (temperature sensor 1) "T.S.1" is > T.S.3 by 10 degrees or more then turn on circulator
3 if T.S.1 >T.S.3 by less then ten degrees the shut off circulator
4 if T.S.1 is 220 degrees or more do not urn on circulator
5 if T.S.2 is < T.S.3 by 10 degrees then move (solenoid) "S1" 2 position valve to position 1
6 if T.S.2 is with in 5 degrees of T.S3 move S.1 toposition 2
7 if T.S.3 reaches maximum temp shut off circulator
8 log hours when circulator is running
9 log hours when S.1 is in position
10 If isolated end switch "I.E.S." is grounded and T.S.3 is < or with in 5 degrees activate relay for Burner control 120V "B.C.V."
11 if I.E.S. is ungrounded the deactivate B.C.V. relay
12 Log how many time and for how long the I.E.S. was grounded and we did not jump the selanoid for B.C.V.
13 use a screen and buttons to navigate a menu for variable changes
14 have 1 button for manuall over ride of the circulator to run for half and hour if the button is pressed once

in the last pic i was missing an important spec. build 1.1

I have only looked briefly at your posts and what you want to do should be well within the scope of an Arduino. It could almost certainly be done with an Uno if you want to hold the Mega for something else. (If you write your code so it just uses the pins that are on an Uno you can develop it on the Mega and transfer it to an Uno later).

You seem to have a good logical grasp of the steps that are needed which will go a long way to help with the design of your code.

As you say you are a beginner I would like to suggest a few things to help you achieve your goal smoothly

Work through several of the example sketches that come with the Arduino IDE until you are comfortable with how Arduino code is constructed. Make copies of some of the examples and experiment with modifying them.

When you move on to your own project start by writing a short sketch that manages one part of the project (for example controlling a relay) and when that works do the same for a different part (reading a temperature perhaps). When you can do all the parts separately then you can start writing a larger sketch that combines them. This is how experienced programmers do it. Many newbies try to do the whole thing at once and just get incomprehensible spaghetti code.

There will be lots of different parts of code in your project. Learn how to put them in self-contained functions which make the code much easier to follow.

There will be errors in your code. Expect that and design your code so you will be able to find them.

Learn how to avoid the use of the Arduino delay() function using the technique in the Blink Without Delay example sketch.

Have fun

...R

jnohs:
1 read all temperature sensors and log with time
2 if (temperature sensor 1) "T.S.1" is > T.S.3 by 10 degrees or more then turn on circulator
3 if T.S.1 >T.S.3 by less then ten degrees the shut off circulator
4 if T.S.1 is 220 degrees or more do not urn on circulator
5 if T.S.2 is < T.S.3 by 10 degrees then move (solenoid) "S1" 2 position valve to position 1
6 if T.S.2 is with in 5 degrees of T.S3 move S.1 toposition 2
7 if T.S.3 reaches maximum temp shut off circulator
8 log hours when circulator is running
9 log hours when S.1 is in position
10 If isolated end switch "I.E.S." is grounded and T.S.3 is < or with in 5 degrees activate relay for Burner control 120V "B.C.V."
11 if I.E.S. is ungrounded the deactivate B.C.V. relay
12 Log how many time and for how long the I.E.S. was grounded and we did not jump the selanoid for B.C.V.
13 use a screen and buttons to navigate a menu for variable changes
14 have0 1 button for manuall over ride of the circulator to run for half and hour if the button is pressed once

  1. data will fill quickly if done once a second. one way is to scan 5 times, average the readings, write once a minute.
    2 and 3 ) you might consider a deadband. if the delta T is greater than 11 then turn on the circulator, if it is less than 9, turn off.

you will need a real time clock, and a data logger. they make SD cards with RTC rather inexpensive.

for temperature sensors, you have a few options.

the digital ones are easier because they do not use analog. but, they are not nearly as sensitive. often accuracy is about 1/2 degree C or about 1 degree F. resolution is not bad, to a tenth of a degree or better.

there are a few temp sensors with humidity sensors. I would suggest you start there, but also get and RTD and a thermistor. put them all in one space and data log them.

as mentioned. average readings

a note about running times. when a device changes state, say a button is pushed. the events that occur are (1)the circuit changed state, (2)the circuit is in a new state, (2)the circuit change state and (4)the circuit is in a new state, or back to where it started. for a momentary button, this can happen quickly. for a burner, it could take minutes.

for data logging, you want to see the change of state. when you get that that point, you can log the event of the change.

couple of suggestions. as was mentioned, the code will probably not require a Mega. if you are planning for more than just this project, I would suggest you get a duplicate set of devices, UNO,. data logger, sensors, etc, and put them on an existing installation. sensors only, not controls. this would allow you to get data as an observer.

you did not mention how you will know a device is running. if you monitor the voltage at the pump or burner, you can get a feedback if the unit is actually getting power.

you have sensor at the collector, but not O.A. temp. if the weather is nice and the OA is sufficient, you may be able to extend time between runs of the burner.

you have taken steps to monitor temperatures, if you can log the moment the pump starts, the water temp to the collector and the temp from the collector, you can assume BTU gain. without a flow meter it would be a guess, but over time, your guess can become quite accurate. I use degree days to determine oil fill on a property for a client. without an internet connection, I could not get him to pay for a dial out alarm for oil level. before I got involved, they ran out 3 times. (the tanks is way too small.) last fill, I was off by 5 gallons.

wow thanks for the replies. I will be perusing this for sure :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:

My first question to help figure this out will be trivial but significant to my understanding and development of this project. The question is, Why is there a 3rd leg on a thermister. I am having a hard time understanding why we need a resistor to measure the resistance that the thermister is creating. A change in the temperature creates more or less resistance and we measure it and determine the temp, for some reason it does not work like this and we need 3 legs and a resistor... Why?

I see when they use a photo cell there is the same thing, a resistor is need to make measurements... WHY?

Witch sensors are recommended for this project, should i use analog or digital temp sensors, i would think analog so i free up any digital pins i might need in the future, if analog or digital witch thermosistors should i get and what accompanying resistors also, I need a temp range of -30 to +280 degrees Fahrenheit. there are so many options, i guess i dont need the perfect one now but i would like to know that the ones i order will at least work for learning, there are literally a million different sensors to choose from.

Take a look at the ds18b20 digital sensor - it's popular in arduino projects because you can put multiple sensors on a single pin. It covers the temperature range you need too.

jnohs:
I am having a hard time understanding why we need a resistor to measure the resistance that the thermister is creating.

The Arduino can only measure voltages so you need to use the resistance to create a varying voltage by using a voltage divider circuit. It's probably more helpful for you is you look that up. I'm sure Wikipedia will have a better explanation and diagrams than I can make. Your thermistor forms one part of the voltage divider. The Arduino reads the voltage at the junction between the thermistor and the other resistor. The thermistors I have have only 2 connections.

I am using an LM335 IC to measure the temperature in my fridge. It is easier to use than a thermistor because its output is linear.

...R

just trying to wrap my head around this...
Why do i need a voltage divider to measure the resistance produced by a thermister. if i supply 3 volts to a thermosiste and it resist 1/2 of that load dont i get a voltage drop and then now depending on the amount of voltage drop i would know the tempature. why do i need to add a noter resisteor of a known value...?

If you connect your thermister to 5V and ground there will be a voltage drop of 5V across it. If you measure the voltage at one side it's 5V, at the other it's zero, irrespective of the temperature. There's nowhere else in the circuit to measure a voltage.

Putting another resistor in series with the thermister means that you can measure the voltage at the point between them and that will vary according to the resistance of the thermister (which relies on temperature) and hence you can use the varying voltage to calculate temperature.

Quite feasible, yes, but these commercial controllers are a lot smarter than I think you realise. You need to be more rigorous in thinking about the safety of your system, e.g. what is it going to do when the tank is at its high-temp limit and the sun is out? You need to run the circulator to stop the panel overheating, and you need to have over-temp dumping, etc. Are you going to pump in order to prevent frost pipe-bursts? Under which conditions and how much energy can you expend on it?

Have a look at PID controllers, which you can use to control pump running times/power/whatever to optimise the thermal energy flow obtained from the solar panel against the power wasted on the circulation pump. And in planning the flow rates, take into account the solar panel's effectiveness, etc.

How are you going to safely isolate the electrical inputs and outputs?

Have a look into the concept of a state machine. Figure out all the possible states your system can be in (startup, idle, circulating, overtemp, gas-heating, etc) and the logical conditions (comparisons between inputs and internal variables) that cause it to move from one state to another. Draw out the state machine - this is the part that people should probably review carefully - to make sure there are no transitions missed and that critical conditions are always evaluated, etc.

Think what happens if the software crashes. Is it still safe? Can you build some safety into the interface electronics that makes it respond better/more-safely if the software stops for some reason? Some means of using hardware to prevent outputs being set in a dangerously inconsistent way? For example I have a thermal controller for an audio amplifier, it's an arduino with a pair of DS1620 sensors, each of which works like an DS1820 but with additional high/low outputs; if my software crashes and it overheats then the DS1620's high outputs will kill the power. If my software is dead, the fan is wired so that it will come on at full power, etc. Your gas tap for sure MUST turn itself off if the software crashes, and that needs to be guaranteed by the hardware.

What are the common failure modes of your sensors? If they fail, what will your software do, and is that a hazard? For example if you melt a thermistor and it goes short-circuit and you've got it wired up so that a shorted thermistor indicates "minimum temperature", will it just turn the gas on and leave it on? And boil your tank, all the while thinking it's cold? You need to make sure that your input and output directions are configured so that a failure doesn't do something inherently risky (e.g. failed thermistor must make your software think the tank is hot not cold), and you need to make your software smart enough that it can detect physical faults, e.g. if we turn the gas on, do we see the temperature rising with the expected time/temp profile? If not, then there is a possibly-hazardous fault such as extinguished flame (gas leak! you must have flame-presence sensors in the hardware that operate with NO software intervention) or a failed temperature sensor.

As to the thermistor, an arduino does not measure resistance. There is no such thing as a "resistance input", only voltage inputs. There is no such thing as "resisting (half of) a load"; those words just don't go together like that in electronic engineering. However If you put your thermistor (Rt) in series with another resistor (R1), then the voltage at their junction will be Vcc*Rt/(R1+Rt) which, being a voltage, is something the arduino can measure. Anyway, the digital temperature sensors are far easier to interface and more accurate, as long as you can find one that covers the temperature range (INCLUDING fault conditions like accidental overheat) that you need.

Yes the digital sensors are nicer to work with but there are caveats. For any reasonable degree of accuracy they are slow to respond 750ms.

The dallas library is quite large and you already have a lot of things to fit in with all you requirements

I never managed to get two seperate busses working with the dallas library so I had to put all the sensors on one bus which made identifying which sensor I was reading tricky. Certaintly too tricky to commercialise

In the end I plumbed for an lm335

John. Just so you know I private messaged you