Hello everyone!
I am a little bit nervous, this is my first post in here, I hope I will do everthing acurate now! Just give me a hint how to do better if I make some mistakes :
I played around with Arduino for about 1 week now, an I am really enthusiastic, not just about the hole new world to control everything, but also this great community and how people help each other!
After I did the projects in the project book (starter kit) I wanted to make a “real” project, and it was about my heating system, controling the circulation pumps for the boiler and to the radiators:
500L storage tank for storing hot water, connected to a boiler (fire wood)
The pumps shall be controlled depending on the temperature in the storage boiler
A controll LED shall indicate if the sensors have a failure
Using two DS18B20 Temperature sensors DS18B20 (Store, Sweden) to measure
–>01 temperature going into storage tank (at the top, from the boiler)
–>02 temperature going out from storage tank (at the bottom, to the boiler)
Controlling 2 pumps (230VAC, 50Hz) with a 4-relay 4 relay module (store, Sweden) module for
→ Circulation pump, from bottom of storage → boiler → top of the storage tank
→ Circulation pump, pumping the hot water out to the radiators
I tried the sketch with Arduino Uno, did some data logging (copy and paste, guess SD card data logging is my next project ) then I put it in a nice little box and used an Adafruit Trinket (due to availability, space and price…hope it is not a hinder to ask questions here when using it?). So the sketch works so far, the pump for the boiler starts when a certain temperature is reached, pump to the radiators starts when storage tank has a certain temp, and if temp becomes low pumps switch off. But I have som questions concerning the code. I will post the questions in a new post here to have a better overview, but here comes the hole sketch so you get a picture of what Ive done so far:
#include <DallasTemperature.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define ONE_WIRE_BUS_PIN 2
/*-----( Declare objects )-----*/
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS_PIN);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/*-----( Declare Variables )-----*/
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress Probe01 = { 0x28, 0xFF, 0x21, 0xB7, 0x61, 0x15, 0x03, 0x95 };
DeviceAddress Probe02 = { 0x28, 0xFF, 0x22, 0xB5, 0x61, 0x15, 0x03, 0xDC };
/*-----( Global variables for the outputs; Pumps and control LED )-----*/
const int pumpBoiler = 4;
const int pumpRadiator = 3;
const int controlLED = 1;
void setup() { /****** SETUP: RUNS ONCE ******/
// set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
sensors.setResolution(Probe01, 10);
sensors.setResolution(Probe02, 10);
//set output pins
pinMode(controlLED, OUTPUT);
digitalWrite(controlLED, LOW);
for (int p = 3; p <= 4; p++) {
pinMode(p, OUTPUT);
digitalWrite(p, LOW);
}
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
// Command all devices on bus to read temperature
sensors.requestTemperatures();
float tempC01 = sensors.getTempC(Probe01);
float tempC02 = sensors.getTempC(Probe02);
//Trigger values, values for activating the pumps (relay HIGH)
const int g01 = 0.5;
float triggerValue0101 = tempC02 + g01;
float triggerValue0102 = 63.5;
float triggerValue0201 = 57 ;
/*
Pump to the boiler shall be on if it is running (fire in the boiler is on -> water to the
boilder is colder than the water from the boiler OR if the water from the boiler reaches
a certain temperature
*/
if ((tempC01 >= triggerValue0101) || (tempC01 >= triggerValue0102)) {
digitalWrite(pumpBoiler, HIGH);
}
else {
digitalWrite(pumpBoiler, LOW);
}
/*
The pump for the hot water to the radiators shall be activated if the storage tank
has reached a certain temperature (the bottom temp)
*/
if (tempC02 >= triggerValue0201) {
digitalWrite(pumpRadiator, HIGH);
}
else {
digitalWrite(pumpRadiator, LOW);
}
/*
If temperature sensor 01 has a failure it reports -127 deg and a control LED
shall indicate the failure
*/
if (tempC01 == -127) {
digitalWrite(pumpRadiator, LOW);
digitalWrite(pumpBoiler, HIGH);
controlBlink01();
delay(1000);
}
/*
If temperature sensor 02 has a failure it reports -127 deg and a control LED
shall indicate the failure
*/
if (tempC02 == -127) {
digitalWrite(pumpRadiator, LOW);
digitalWrite(pumpBoiler, HIGH);
controlBlink02();
delay(1000);
controlBlink02();
delay(1000);
}
/*
If both temperature sensors have a failure it reports -127 deg and a control LED
shall indicate the failure
*/
if ((tempC02 == -127) && (tempC01 == -127)) {
digitalWrite(pumpRadiator, LOW);
digitalWrite(pumpBoiler, HIGH);
controlBlink03();
}
}
//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
void controlBlink01() {
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
delay(100);
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
delay(100);
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
delay(100);
}
void controlBlink02() {
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
delay(100);
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
delay(100);
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
delay(500);
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
delay(100);
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
delay(100);
digitalWrite(controlLED, HIGH);
delay(100);
digitalWrite(controlLED, LOW);
}
void controlBlink03() {
digitalWrite(controlLED, HIGH);
delay(200);
digitalWrite(controlLED, LOW);
delay(200);
digitalWrite(controlLED, HIGH);
delay(200);
digitalWrite(controlLED, LOW);
delay(200);
digitalWrite(controlLED, HIGH);
delay(200);
digitalWrite(controlLED, LOW);
delay(200);
digitalWrite(controlLED, HIGH);
delay(200);
digitalWrite(controlLED, LOW);
delay(200);
}
//*********( THE END )***********