Hi Forum,
I'm working on a Raspberry Pi based heating control system but I'm hoping my approach could be used for a variety of sense / control scenarios (e.g. light, water moisture, heating etc).
I've attached my design so far and put notes below to share the idea in case anyone else would like to do the sam.
I'd welcome comments! I have not built anything like this before so it's new territory for me and I'd love to get some advice. Will it work, any draw backs of flaws?
Credit to Mike for his very well explained explanation on "http://www.raspberrypi.org/forums/viewtopic.php?t=36225 How to wire a Raspberry Pi to a Sainsmart 5v Relay Board" in this http://www.raspberrypi.org/forums/viewtopic.php?t=36225 thread.
Kind regards
Adam
Drawings
(right click and open theses images in new tab to see them enlarged)
Parts List
- 1x Raspberry Pi - Micro Controller, offers range of choice for programming control logic and building a user interface to the system
- 2x Sainsmart 8x Relay (operates at 5V throughout, could also consider the 16x relay but this requires 12V for the relay circuit)
- 1x MCP23017-E/SP - I2C 16 bit port expander (1.8V-5.5V Supply. DIP Package.)
- 3x ULN2003AN - 7x Darlington Transistor Array (PDIP Package)
- 2x AD7997 - I2C 8 channel, 10 bit ADC (2.7V-5.5V Supply. TSSOP Package)
- 2x 5v 1A power supplies - 1x for the RPi, 1x for the sainsmart boards.
- Various capacitors and resistors - as required for noise filtering and pull up / pull downs.
- Pi Cobler, Project board, jumper wires, solder etc.
Notes
>>> THE GOAL
Control an environment (in this example temperature in many "zones") using a programming language (e.g. python) and Web User Interface (e.g. a web framework like python's django). Keep the electronics easy to construct (solder etc) with relatively cheap to buy the components.
>>> THE RELAYS
Sainsmart 8x relays as a cost effective way for switching mains voltage. The advantage of two 8x relays rather than one 16x is the 8x version can use a 5v supply, the same as the Raspberry Pi. The 16x requires a 12v supply.
>>> THE TRANSISTORS
The ULN2003AN Darlington Transistor Array was selected because it is amiable in an easy to solder, relatively cheap, DIP package. Further advantages of using these transistors include inverting the logic so a high bit turns the relays on, and interfacing between the 3.3V port expanders and the 5V really boards. Darlington pairs are not strictly required for this circuit (see “How to wire a Raspberry Pi to a Sainsmart 5v Relay Board” in the references) however the ULN2003AN is a nice alternative to purchasing individual transistors and resistors. Unfortunately it only providers 7 transistor pairs per chip so three ULN2003AN’s are required to cover 16 channels.
>>> THE I/O
For input and output the MPC23017 port expander and the AD7997 ADC were selected for their 3.3V I2C compatibility. More of these chips can be added to the I2C bus to expand the number of relays and sensors beyond 16x.
>>> POWER SUPPLY & ISOLATION
The circuit works using 5v power supplies and 3.3v from the RPi GPIO. It is assumed all have a common ground. The Raspberry Pi requires one supply, capable of 700mA to 1A, which will power the Pi itself and the 3.3V MPC23017 and AD7997 chips. The Sainsmart 8X relay requires two 5v supplies, VCC and JD-VCC, which can be made common using a jumper across pins 2 and 3 on the board. There is an advantage to supplying these separately because, since the board uses opto-isolators, the really circuits will then be physically isolated from the control circuits. VCC will draw around 24mA total (1.5mA x 16) so could be supplied from the GIO 5V out pin. JD-VCC will draw significantly more, around 960mA (60ma x16) with all relays activated so could be powered from a dedicated 1A 5V supply.
>>> START UP STATE
At start up the Raspberry Pi may move the GPIO pins though various states (low, floating, high?). If/where this is the case the I2C port expander and transistors offer a simple way to avoid any unintended switching that may occur if the relay board was attached directly to the GPIO. All bits of on the port expander should remain low or floating during start up and the transistor array includes a pull down resistor which will keep the logic low (relays off) until the port expander is intently set to output a logic high.
-
- Posts: 3
- Joined: Fri May 09, 2014 8:49 am
Re: Pi Based Heating* Control system
As for the hardware, I recommend considering also an "I2C to 1-Wire" gateway based on e.g. DS2482-800, especially for the DS18B20 teperature sensors.
For the software part:
- If your goal is to learn Python, dive into your project and you will learn a lot.
- If your goal is to create a control system, rely on software packages which are already available (Resologis IPC, REX Control System, etc.) otherwise you'll be too exhausted by the time you reach the point where you'll be seriously controlling something. This will result in implementing a simple on-off thermostat control (with hysteresis) and that'll be it. I've been there before and I left the path, otherwise I would never finish my projects of controlling heating in my house, my summer house and my parent's house. The few bucks you pay for the license are well worth the time it saves you.
I sincerely appologize if you find my comment insulting, but I just described my personal experience and opinion.
For the software part:
- If your goal is to learn Python, dive into your project and you will learn a lot.
- If your goal is to create a control system, rely on software packages which are already available (Resologis IPC, REX Control System, etc.) otherwise you'll be too exhausted by the time you reach the point where you'll be seriously controlling something. This will result in implementing a simple on-off thermostat control (with hysteresis) and that'll be it. I've been there before and I left the path, otherwise I would never finish my projects of controlling heating in my house, my summer house and my parent's house. The few bucks you pay for the license are well worth the time it saves you.
I sincerely appologize if you find my comment insulting, but I just described my personal experience and opinion.
-
- Posts: 3
- Joined: Fri May 09, 2014 8:49 am
Re: Pi Based Heating* Control system
Hi josar
Not insulting at all, very helpful.
On the software from I'm relatively open about what languages to used, just keen to be able to make a good looking Web UI for users to be able to control the control system. The two packages you suggested look very interesting so I'll take closer look. If I don't use them - for hysteresis I was just thinking about having a low tiger level (e.g. when temperature is below a certain level turn the heating on) and a high trigger level (e.g. when temperature is above a certain level turn the heating off).
1-wire is a good suggestion but for temperature why would you prefer it to a simple thermistor/resistor voltage divider and an ADC to measure the voltage. This could then be calibrated using some real world measurements and a suitable mapping in software to transform the output of the ADC to a real world temperature.
Cheers
Adam
Not insulting at all, very helpful.
On the software from I'm relatively open about what languages to used, just keen to be able to make a good looking Web UI for users to be able to control the control system. The two packages you suggested look very interesting so I'll take closer look. If I don't use them - for hysteresis I was just thinking about having a low tiger level (e.g. when temperature is below a certain level turn the heating on) and a high trigger level (e.g. when temperature is above a certain level turn the heating off).
1-wire is a good suggestion but for temperature why would you prefer it to a simple thermistor/resistor voltage divider and an ADC to measure the voltage. This could then be calibrated using some real world measurements and a suitable mapping in software to transform the output of the ADC to a real world temperature.
Cheers
Adam
-
- Posts: 12
- Joined: Mon Jan 28, 2013 7:30 am
Re: Pi Based Heating* Control system
Have a look at https://code.google.com/p/raspi-boiler-control/
I am doing a similar thing to teach myself python. I'm no expert and the code is evolving over time as I go back and redo things. it uses bootstrap from twitter to make the front end pretty and work with mobile devices
It uses a 1 wire temperature sensor and a solid state relay. The database is postgres.
Adam
I am doing a similar thing to teach myself python. I'm no expert and the code is evolving over time as I go back and redo things. it uses bootstrap from twitter to make the front end pretty and work with mobile devices
It uses a 1 wire temperature sensor and a solid state relay. The database is postgres.
Adam
Re: Pi Based Heating* Control system
Yes, that's practically the same as hysteresis. It's easy to implement and easy to set up but you will typically achieve very poor precision (and room comfort if we're talking about heating controller).aogriffiths wrote:... having a low trigger level (e.g. when temperature is below a certain level turn the heating on) and a high trigger level (e.g. when temperature is above a certain level turn the heating off).
With thermistor you need 1 ADC for each sensor. And that means wires. And that can be a problem. Calibration takes time, which can be a problem too. That's why I prefer a single bus line (3 or 2 wires) with many 1-Wire sensors attached to it. No calibration needed, no analog noise, etc.aogriffiths wrote: 1-wire is a good suggestion but for temperature why would you prefer it to a simple thermistor/resistor voltage divider and an ADC to measure the voltage. This could then be calibrated using some real world measurements and a suitable mapping in software to transform the output of the ADC to a real world temperature.
Re: Pi Based Heating* Control system
You should also take a look at https://code.google.com/p/webiopi/ perfect for your project
Toshi Bass
Toshi Bass
-
- Posts: 2
- Joined: Sun Sep 23, 2018 8:57 am
Re: Pi Based Heating* Control system
Hi I would like to use a Pi to build a heating controller that uses a weather station to monitor how my house reacts to the weather!
I have 8 zones that I would like to control ( 5 Radiators + 3 wet under floor ).
I plan to use a weather monitoring station with USB connectivity.
I plan to hard wire everything for reliability .
I would really appreciate any feedback.
I have 8 zones that I would like to control ( 5 Radiators + 3 wet under floor ).
I plan to use a weather monitoring station with USB connectivity.
I plan to hard wire everything for reliability .
I would really appreciate any feedback.
Re: Pi Based Heating* Control system
It would probably be best to start a new topic, rather than adding to an old one. Also, add some more details about how the zones would be controlled.
-
- Posts: 2
- Joined: Sun Sep 23, 2018 8:57 am
Re: Pi Based Heating* Control system
Hi I was thinking of using the Honeywell MT4 actuators, they are normally used with the HCC80r controller
- DougieLawson
- Posts: 42748
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Pi Based Heating* Control system
Are you joking? That pile of junk hasn't been updated since 2015. There are much better ways to control GPIOs now (usually using RPi.GPIO, GPIOZero and/or PIGPIO/pigpiod).Toshibass wrote: ↑Thu May 22, 2014 9:19 pmYou should also take a look at https://code.google.com/p/webiopi/ perfect for your project
Toshi Bass
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: Pi Based Heating* Control system
Check the date of that response. 2014!DougieLawson wrote: ↑Sun Sep 23, 2018 8:34 pm[Are you joking? That pile of junk hasn't been updated since 2015. There are much better ways to control GPIOs now (usually using RPi.GPIO, GPIOZero and/or PIGPIO/pigpiod).
Also, Toshibass hasn't visited the forums since 27 Feb 2017.
- DougieLawson
- Posts: 42748
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Pi Based Heating* Control system
Arrgh! The perils of new forum members bumping ancient old crap posts. They really should get locked after 6 months of inactivity.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.