please help me with attribute for sensor missing temperature= tset -1 degree, and look at part where is control each aquator for each rooms
Any help is welcome. It is possible to control this with an interface? witch one is easy to program?
sketch_jul_18.ino (28.9 KB)
A #define can replace one text with another text.
#define AMBIENT_SET tset=24 // Settings AMBIENT TEMP
Everywhere that you use AMBIENT_SET, it is replaced by tset=24. That means you can no longer use AMBIEN_SET in a calculation.
This is a typing error:
Serial.println();)
You are using a lot of SRAM memory. Do you use a Arduino Uno ? Then you better use the F() macro. Also read the PROGMEM page, I think you need that as well.
https://www.arduino.cc/reference/en/language/variables/utilities/progmem/
We prefer that you show the sketch in the post. Put it between three backslash single quotes
```
your sketch
```
In the Arduino IDE, in the preferences, the verbose compiler output can be turned on. Turn it on, and show us the complete output.
Type Ctrl+T in the Arduino IDE, then make it look even better. Put every comma, every indent, every space, every new line at the right place.
I see that you use this example: https://github.com/milesburton/Arduino-Temperature-Control-Library/blob/master/examples/Multiple/Multiple.ino
But that is with only two sensors.
Do you think that your sketch will work ?
If you make better use of arrays, and tables with text, then the sketch will be easier.
All the t1, t2, t3, and so on, should be in a table.
Do not use the name of a variable twice, because you have also integers called t1, t2, t3, and so on.
Does your display support the UTF-8 degree sign ° ? I don't think so. The Serial Monitor support UTF-8 and can display the °
type or paste // 18.07.2022 floor heating unit by Razvan Bogaci
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize the LCD and tell it which pins is to be used for communicating
#define ONE_WIRE_BUS 8 // Data wire is plugged into port 8 on the Arduino
#define precision 9 // OneWire precision Dallas Sensor
#define contrast 9 // Define the pin that controls the contrast of the screen
#define bright 10 // Define the pin the controls the brightness of the screen
#define rows 2 // Define the rows in display LCD
#define columns 16 // Define the columns in display LCD
//Define PUMPS
#define HEATER_REC_PUMP 41 // output to a Relay that switches recirculation heating Unit Pump
#define HEATER_PUMP 42 // output to a Relay that switches puffer heating Pump
#define FLOOR_PUMP 51 // output to a Relay that switches the Floor Unit Pump
// DEFINE ZONE 1
#define LIVING_GROUND_1_VALVE 11 // Zone 1: output to a Relay that controls the Valve(s)
#define LIVING_GROUND_2_VALVE 12 // Zone 1: output to a Relay that controls the Valve(s)
#define GROUND_OFFICE_VALVE 13 // Zone 1: output to a Relay that controls the Valve(s)
#define ENTRANCE_VALVE 14 // Zone 1: output to a Relay that controls the Valve(s)
// DEFINE ZONE 2
#define LIVING_FIRST_FLOOR_VALVE 21 // Zone 2: output to a Relay that controls the Valve(s)
#define MASTER_BEDROOM_VALVE 22 // Zone 2: output to a Relay that controls the Valve(s)
#define SMALL_BEDROOM_VALVE 23 // Zone 2: output to a Relay that controls the Valve(s)
// DEFINE ZONE 3
#define BEDROOM_EX_VALVE 31 // Zone 3: output to a Relay that controls the Valve(s)
#define APARTMENTS_EX_VALVE 32 // Zone 3: output to a Relay that controls the Valve(s)
#define DRESING_VALVE 33 // Zone 3: output to a Relay that controls the Valve(s)
//define TEMPERATURE SENSORS Zona 1 GROUND
#define LIVING t1 // Zone 1; input wired to the thermostat in the living ground floor
#define GROUND_OFFICE t2 // Zone 1; input wired to the thermostat in the ground office
#define ENTRANCE t3 // Zone 1; input wired to the thermostat in the main hall
//define TEMPERATURE SENSORS Zona 2 FIRST FLOOR
#define LIVING_1_FLOOR t4 ` // Zone 2; input wired to the thermostat in the living 1 floor
#define MASTER BEDROOM t5 // Zone 2; input wired to the thermostat in the master bedroom
#define SMALL_BEDROOM t6 // Zone 2; input wired to the thermostat in the small bedroom
//define TEMPERATURE SENSORS Zona 3 EXTENSION
#define BEDROOM_EXT t7 // Zone 3; input wired to the thermostat in the bedroom extension
#define DRESING_EXT t8 // Zone 3; input wired to the thermostat in the dressing extension
#define APT_EXT t9 // Zone 3; input wired to the thermostat in the apartment extension
//REF_TEMP
#define AMBIENT_SET tset=24 // Settings AMBIENT TEMP
//FLOOR_PUMP
#define PUFFER_IN t10 // Zone 3; input wired to the thermostat in the dining
#define PUFFER_OUT t11 // Zone 3; input wired to the thermostat in the dining
//
#define RELAY_ON 0
#define RELAY_OFF 1
#define HEATING_LED 12 // On when heating, Alternates during cooldown, is Off in idle mode
#define INDICATION_LED 13 // Alternates the on board LED to indicate board runs; can be easily removed to free an extra IO pin!
// Configure the Floor Unit Zones/rooms. Each zone/room owns a name, valve and thermostat:
//#define NR_ZONES 3 //Zone Zones[NR_ZONES]
//Zone ZONES [NR_ZONES] {
// {"Living 1 Room", Valve(LIVING_GROUND_1_VALVE, "Living 1 Valve"), "Living 2 Room", Valve(LIVING_GROUND_2_VALVE, "Living 2 Valve"), Thermostat(LIVING_THERMO, "Living Thermostat")},
// {"Kitchen Area", Valve(KITCHEN_VALVE, "Kitchen Valve"), Thermostat(KITCHEN_THERMO, "Kitchen Thermostat")},
// {"Ground Office", Valve(GROUND_OFFICE_VALVE, "Ground Office Valve"), Thermostat(GROUND_OFFICE_THERMO, "Gound Office Thermostat")},
// {"Entrance", Valve(ENTRANCE_VALVE, "Entrance Valve"), Thermostat(ENTRANCE_THERMO, "Entrance Thermostat")},
// {"Living_First_Floor Room", Valve(LIVING_FIRST_FLOOR_VALVE, "Living_First_Floor"), Thermostat(LIVING_FIRST_FLOOR_THERMO, "Living first floor Thermostat")},
//{ "Master bedroom", Valve(MASTER_BEDROOM_VALVE, "Master bedroom"), Thermostat(MASTER BEDROOM_THERMO, "Master bedroom Thermostat")},
// {"Small bedroom", Valve(SMALL_BEDROOM_VALVE, "Small bedroom"), Thermostat(SMALL_BEDROOM_THERMO, "Small bedroom Thermostat")},
// {"Bedroom extension Area", Valve(BEDROOM_EX_VALVE, "Bedroom extension Valve"), Thermostat(BEDROOM_EX_THERMO, "Bedroom extension Thermostat")},
// {"Apartments extension Area", Valve(APARTMENTS_EX_VALVE, "Apartments extension Valve"), Thermostat(APARTMENTS_EX_THERMO, "Apartments extension Thermostat")},
// {"Dressing Room", Valve(DRESING_VALVE, "Dresing Valve"), Thermostat(DRESING_THERMO, "Dresing Thermostat")}
//}
int licznik = 0; // Counter readings
int tset=24; // temperature setings for interior °C
// END CONFIGURATION BLOCK
//////////////////////////////////////////////////
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature.
DeviceAddress t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 , t12 , t13, t14, t15, t16, t17 , t18, t19; // arrays to hold device addresses
void setup(void)
{
// Initialize LCD to 20 characters by 4 lines
//lcd.begin(20, 4);
//lcd.clear();
lcd.begin(columns, rows); //Tell the LCD that it is a Columns x Rows LCD
pinMode(contrast, OUTPUT); //set pin contrast to OUTPUT
pinMode(bright, OUTPUT); //Set pin brightness to OUTPUT
digitalWrite(bright, HIGH); //LOW and HIGH <- digitalWrite OR analogWrite value 0-255 240
analogWrite(contrast, 50); //LOW and HIGH <- digitalWrite OR analogWrite value 0-255 54
lcd.noCursor(); //Disable cursor on LCD
lcd.clear(); //Clear Screen on LCD
Serial.begin(9600); //Start serial port
Serial.println("Dallas Temperature IC Control Library");
// Start up the library
sensors.begin();
// locate devices on the bus
Serial.print("Locating devices........");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" Devices.");
// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
// Search for devices on the bus and assign based on an index. Ideally,
// you would do this to initially discover addresses on the bus and then
// use those addresses and manually assign them (see above) once you know
// the devices on your bus (and assuming they don't change).
//
if (!sensors.getAddress(t1, 0)) {int t1=(tset-1);Serial.println("No Found Sensor 1");}
if (!sensors.getAddress(t2, 1)) {int t2=(tset-1);Serial.println("No Found Sensor 2");}
if (!sensors.getAddress(t3, 2)) {int t3=(tset-1);Serial.println("No Found Sensor 3");}
if (!sensors.getAddress(t4, 3)) {int t4=(tset-1);Serial.println("No Found Sensor 4");}
if (!sensors.getAddress(t5, 4)) {int t5=(tset-1);Serial.println("No Found Sensor 5");}
if (!sensors.getAddress(t6, 5)) {int t6=(tset-1);Serial.println("No Found Sensor 6");}
if (!sensors.getAddress(t7, 6)) {int t7=(tset-1);Serial.println("No Found Sensor 7");}
if (!sensors.getAddress(t8, 7)) {int t8=(tset-1);Serial.println("No Found Sensor 8");}
if (!sensors.getAddress(t9, 8)) {int t9=(tset-1);Serial.println("No Found Sensor 9");}
if (!sensors.getAddress(t10, 9)) {int t10=(tset-1);Serial.println("No Found Sensor 10");}
if (!sensors.getAddress(t11, 10)) {int t11=(tset-1);Serial.println("No Found Sensor 11");}
if (!sensors.getAddress(t12, 11)) {int t12=(tset-1);Serial.println("No Found Sensor 12");}
if (!sensors.getAddress(t13, 12)) {int t13=(tset-1);Serial.println("No Found Sensor 13");}
if (!sensors.getAddress(t14, 13)) {int t14=(tset-1);Serial.println("No Found Sensor 14");}
if (!sensors.getAddress(t15, 14)) {int t15=(tset-1);Serial.println("No Found Sensor 15");}
if (!sensors.getAddress(t16, 15)) {int t16=(tset-1);Serial.println("No Found Sensor 16");}
if (!sensors.getAddress(t17, 16)) {int t19=(tset-1);Serial.println("No Found Sensor 17");}
if (!sensors.getAddress(t18, 17)) {int t18=(tset-1); Serial.println("No Found Sensor 18");}
if (!sensors.getAddress(t19, 18)) {int t19=(tset-1); Serial.println("No Found Sensor 19");}
if (sensors.getDeviceCount() == 0 ) {
lcd.setCursor(0, 0);
lcd.print("NO Sensors !!!");
lcd.setCursor(0, 1);
lcd.print("CHECK SENSORS!!!");
delay (1200);
lcd.clear();
}
// show the addresses we found on the bus
for (int ilosc =0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor "); Serial.print(ilosc+1);
Serial.print(" Address: ");
if (ilosc == 0) { printAddress(t1); Serial.println();
} else if (ilosc == 1) { printAddress(t2); Serial.println();
} else if (ilosc == 2) { printAddress(t3); Serial.println();
} else if (ilosc == 3) { printAddress(t4); Serial.println();
} else if (ilosc == 4) { printAddress(t5); Serial.println();
} else if (ilosc == 5) { printAddress(t6); Serial.println();
} else if (ilosc == 6) { printAddress(t7); Serial.println();
} else if (ilosc == 7) { printAddress(t8); Serial.println();
} else if (ilosc == 8) { printAddress(t9); Serial.println();
} else if (ilosc == 9) { printAddress(t10); Serial.println();
} else if (ilosc == 10) { printAddress(t11); Serial.println();
} else if (ilosc == 11) { printAddress(t12); Serial.println();
} else if (ilosc == 12) { printAddress(t13); Serial.println();
} else if (ilosc == 13) { printAddress(t14); Serial.println();
} else if (ilosc == 14) { printAddress(t15); Serial.println();
} else if (ilosc == 15) { printAddress(t16); Serial.println();
} else if (ilosc == 16) { printAddress(t17); Serial.println();
} else if (ilosc == 17) { printAddress(t18); Serial.println();
} else if (ilosc == 18) { printAddress(t19); Serial.println();
}
}
// set the resolution to 9 bit per device
sensors.setResolution(t1, precision);
sensors.setResolution(t2, precision);
sensors.setResolution(t3, precision);
sensors.setResolution(t4, precision);
sensors.setResolution(t5, precision);
sensors.setResolution(t6, precision);
sensors.setResolution(t7, precision);
sensors.setResolution(t8, precision);
sensors.setResolution(t9, precision);
sensors.setResolution(t10, precision);
sensors.setResolution(t11, precision);
sensors.setResolution(t12, precision);
sensors.setResolution(t13, precision);
sensors.setResolution(t14, precision);
sensors.setResolution(t15, precision);
sensors.setResolution(t16, precision);
sensors.setResolution(t17, precision);
sensors.setResolution(t18, precision);
sensors.setResolution(t19, precision);
for (int ilosc = 0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor "); Serial.print(ilosc + 1);
Serial.print(" Resolution: ");
if (ilosc == 0) { Serial.print(sensors.getResolution(t1), DEC); Serial.println();
} else if (ilosc == 1) { Serial.print(sensors.getResolution(t2), DEC); Serial.println();
} else if (ilosc == 2) { Serial.print(sensors.getResolution(t3), DEC); Serial.println();
} else if (ilosc == 3) { Serial.print(sensors.getResolution(t4), DEC); Serial.println();
} else if (ilosc == 4) { Serial.print(sensors.getResolution(t5), DEC); Serial.println();
} else if (ilosc == 5) { Serial.print(sensors.getResolution(t6), DEC); Serial.println();
} else if (ilosc == 6) { Serial.print(sensors.getResolution(t7), DEC); Serial.println();
} else if (ilosc == 7) { Serial.print(sensors.getResolution(t8), DEC); Serial.println();
} else if (ilosc == 8) { Serial.print(sensors.getResolution(t9), DEC); Serial.println();
} else if (ilosc == 9) { Serial.print(sensors.getResolution(t10), DEC); Serial.println();
} else if (ilosc == 10) { Serial.print(sensors.getResolution(t11), DEC); Serial.println();
} else if (ilosc == 11) { Serial.print(sensors.getResolution(t12), DEC); Serial.println();
} else if (ilosc == 12) { Serial.print(sensors.getResolution(t13), DEC); Serial.println();
} else if (ilosc == 13) { Serial.print(sensors.getResolution(t14), DEC); Serial.println();
} else if (ilosc == 14) { Serial.print(sensors.getResolution(t15), DEC); Serial.println();
} else if (ilosc == 15) { Serial.print(sensors.getResolution(t16), DEC); Serial.println();
} else if (ilosc == 16) { Serial.print(sensors.getResolution(t17), DEC); Serial.println();
} else if (ilosc == 17) { Serial.print(sensors.getResolution(t18), DEC); Serial.println();
} else if (ilosc == 18) { Serial.print(sensors.getResolution(t19), DEC); Serial.println();
}
}
}
// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 20; i++)
{
// zero pad the address if necessary
if (deviceAddress[i] < 20) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
Serial.print("Temp: ");
Serial.print(tempC);
Serial.print("°C");
// Serial.print(" Temp F: ");
// Serial.print(DallasTemperature::toFahrenheit(tempC));
}
// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
//Serial.print("Resolution: ");
// Serial.print(sensors.getResolution(deviceAddress));
//Serial.println();
}
// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
Serial.print("Device Address: ");
printAddress(deviceAddress);
Serial.print(" ");
printTemperature(deviceAddress);
Serial.println();
}
/*
Main function, calls the temperatures in a loop.
*/
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature request to all devices on the bus
Serial.print("Reading DATA...request temperatures...."); sensors.requestTemperatures(); Serial.println("DONE");
// print the device information
for (int ilosc = 0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor no: "); Serial.print(ilosc + 1); Serial.print(" ");
if (ilosc == 0) { printData(t1);
} else if (ilosc == 1) { printData(t2);
} else if (ilosc == 2) { printData(t3);
} else if (ilosc == 3) { printData(t4);
} else if (ilosc == 4) { printData(t5);
} else if (ilosc == 5) { printData(t6);
} else if (ilosc == 6) { printData(t7);
} else if (ilosc == 7) { printData(t8);
} else if (ilosc == 8) { printData(t9);
} else if (ilosc == 9) { printData(t10);
} else if (ilosc == 10) { printData(t11);
} else if (ilosc == 11) { printData(t12);
} else if (ilosc == 12) { printData(t13);
} else if (ilosc == 13) { printData(t14);
} else if (ilosc == 15) { printData(t16);
} else if (ilosc == 16) { printData(t17);
} else if (ilosc == 17) { printData(t18);
} else if (ilosc == 18) { printData(t19);
}
}
if (sensors.getDeviceCount() <= 19) {
lcd.setCursor(0, 0);
lcd.print("Sensor Number "); lcd.print(licznik + 1);
lcd.setCursor(0, 1);
lcd.print(" Temp: ");
lcd.clear();
}
else if (sensors.getDeviceCount() > 19 ) {
lcd.setCursor(0, 0);
lcd.print("please add ");
lcd.setCursor(0, 1);
lcd.print(" SENSORS!!!");
delay (800);
lcd.clear();
}
if (licznik == 1) {
lcd.print(sensors.getTempC(t1)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 2) {
lcd.print(sensors.getTempC(t2)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 3) {
lcd.print(sensors.getTempC(t3)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 4) {
lcd.print(sensors.getTempC(t4)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 5) {
lcd.print(sensors.getTempC(t5)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 6) {
lcd.print(sensors.getTempC(t6)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 7) {
lcd.print(sensors.getTempC(t7)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 8) {
lcd.print(sensors.getTempC(t8)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 9) {
lcd.print(sensors.getTempC(t9)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 10) {
lcd.print(sensors.getTempC(t10)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 11) {
lcd.print(sensors.getTempC(t11)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 12) {
lcd.print(sensors.getTempC(t12)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 13) {
lcd.print(sensors.getTempC(t13)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 14) {
lcd.print(sensors.getTempC(t14)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 15) {
lcd.print(sensors.getTempC(t15)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 16) {
lcd.print(sensors.getTempC(t16)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 17) {
lcd.print(sensors.getTempC(t17)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 18) {
lcd.print(sensors.getTempC(t18)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 19) {
lcd.print(sensors.getTempC(t19)); lcd.write((char)223); lcd.print("°C");
}
//compare temperature sensor with temperature set
//void loop
if (sensors.getTempC(t1) > tset){
Serial.print("Temp LIVING_GROUD ");
Serial.print(sensors.getTempC(t1));
Serial.print("°C");
Serial.println();
lcd.print("Temp LIVING_GROUD ");lcd.print(sensors.getTempC(t1));lcd.print("°C");
digitalWrite(LIVING_GROUND_1_VALVE,HIGH); digitalWrite(LIVING_GROUND_2_VALVE,HIGH);
}else {digitalWrite(LIVING_GROUND_1_VALVE,LOW); digitalWrite(LIVING_GROUND_2_VALVE,LOW);
}
lcd.print("LIVING_GROUND_1&2_VALVE is ");
Serial.print("LIVING_GROUND_1&2_VALVE is ");
if (digitalRead (LIVING_GROUND_1_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t2) > tset){
Serial.print("Temp GROUND_OFFICE ");
Serial.print(sensors.getTempC(t2));
Serial.print("°C");
Serial.println();
lcd.print("Temp GROUND_OFFICE ");lcd.print(sensors.getTempC(t2));lcd.print("°C");
digitalWrite(GROUND_OFFICE_VALVE,HIGH);
}else {digitalWrite(GROUND_OFFICE_VALVE,LOW);
}
lcd.print("GROUND_OFFICE_VALVE is ");
Serial.print("GROUND_OFFICE_VALVE is ");
if (digitalRead (GROUND_OFFICE_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t3) > tset){
Serial.print("Temp LIVING_FIRST_FLOOR ");
Serial.print(sensors.getTempC(t3));
Serial.print("°C");
Serial.println();
lcd.print("Temp LIVING_FIRST_FLOOR ");lcd.print(sensors.getTempC(t3));lcd.print("°C");
digitalWrite(LIVING_FIRST_FLOOR_VALVE,HIGH);
}else {digitalWrite(LIVING_FIRST_FLOOR_VALVE,LOW);
}
lcd.print("LIVING_FIRST_FLOOR_VALVE is ");
Serial.print("LIVING_FIRST_FLOOR_VALVE is ");
if (digitalRead(LIVING_FIRST_FLOOR_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t4) > tset){
Serial.print("Temp MASTER_BEDROOM ");
Serial.print(sensors.getTempC(t4));
Serial.print("°C");
Serial.println();
lcd.print("Temp MASTER_BEDROOM ");lcd.print(sensors.getTempC(t4));lcd.print("°C");
digitalWrite(MASTER_BEDROOM_VALVE,HIGH);
}else {digitalWrite(MASTER_BEDROOM_VALVE,LOW);
}
lcd.print("MASTER_BEDROOM_VALVE is ");
Serial.print("MASTER_BEDROOM_VALVE is ");
if (digitalRead (MASTER_BEDROOM_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t5) > tset){
Serial.print("Temp SMALL_BEDROOM ");
Serial.print(sensors.getTempC(t5));
Serial.print("°C");
Serial.println();
lcd.print("Temp SMALL_BEDROOM ");lcd.print(sensors.getTempC(t5));lcd.print("°C");
digitalWrite(SMALL_BEDROOM_VALVE,HIGH);
}else {digitalWrite(SMALL_BEDROOM_VALVE,LOW);
}
lcd.print("SMALL_BEDROOM_VALVE is ");
Serial.print("SMALL_BEDROOM_VALVE is ");
if (digitalRead (SMALL_BEDROOM_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t6) > tset){
Serial.print("Temp BEDROOM_EX ");
Serial.print(sensors.getTempC(t6));
Serial.print("°C");
Serial.println();
lcd.print("Temp BEDROOM_EX ");lcd.print(sensors.getTempC(t6));lcd.print("°C");
digitalWrite(BEDROOM_EX_VALVE,HIGH);
}else {digitalWrite(BEDROOM_EX_VALVE,LOW);
}
lcd.print("BEDROOM_EX_VALVE is ");
Serial.print("BEDROOM_EX_VALVE is ");
if (digitalRead (BEDROOM_EX_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t7) > tset){
Serial.print("Temp APARTMENTS_EX ");
Serial.print(sensors.getTempC(t7));
Serial.print("°C");
Serial.println();
lcd.print("Temp APARTMENTS_EX ");lcd.print(sensors.getTempC(t7));lcd.print("°C");
digitalWrite(APARTMENTS_EX_VALVE,HIGH);
}else {digitalWrite(APARTMENTS_EX_VALVE,LOW);
}
lcd.print("APARTMENTS_EX_VALVE is ");
Serial.print("APARTMENTS_EX_VALVE is ");
if (digitalRead (APARTMENTS_EX_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t8) > tset){
Serial.print("Temp DRESING ");
Serial.print(sensors.getTempC(t8));
Serial.print("°C");
Serial.println();
lcd.print("Temp DRESING ");lcd.print(sensors.getTempC(t8));lcd.print("°C");
digitalWrite(DRESING_VALVE,HIGH);
} else {digitalWrite(DRESING_VALVE,LOW);
}
lcd.print("DRESING_VALVE is ");
Serial.print("DRESING_VALVE is ");
if (digitalRead (DRESING_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();)
Serial.print("sensor reading data loop number "); Serial.println(licznik);
delay(1200);
licznik++ ;
}
I am at beginning, so I need a lot of tricks to improve this sketch.
Thank you.
I make some changes in sketch, but I need more help with PROGMEN. I don't know how to use it.
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize the LCD and tell it which pins is to be used for communicating
#define ONE_WIRE_BUS 8 // Data wire is plugged into port 8 on the Arduino
#define precision 12 // OneWire precision Dallas Sensor
#define contrast 9 // Define the pin that controls the contrast of the screen
#define bright 10 // Define the pin the controls the brightness of the screen
#define rows 2 // Define the rows in display LCD
#define columns 16 // Define the columns in display LCD
//Define PUMPS
#define HEATER_REC_PUMP 22 // output to a Relay that switches recirculation heating Unit Pump
#define HEATER_PUMP 23 // output to a Relay that switches puffer heating Pump
#define FLOOR_PUMP 24 // output to a Relay that switches the Floor Unit Pump
// DEFINE ZONE 1
#define LIVING_GROUND_VALVE 25 // Zone 1: output to a Relay that controls the Valve(s)
#define GROUND_OFFICE_VALVE 13 // Zone 1: output to a Relay that controls the Valve(s)
#define ENTRANCE_VALVE 14 // Zone 1: output to a Relay that controls the Valve(s)
// DEFINE ZONE 2
#define LIVING_FIRST_FLOOR_VALVE 16 // Zone 2: output to a Relay that controls the Valve(s)
#define MASTER_BEDROOM_VALVE 17 // Zone 2: output to a Relay that controls the Valve(s)
#define SMALL_BEDROOM_VALVE 18 // Zone 2: output to a Relay that controls the Valve(s)
// DEFINE ZONE 3
#define BEDROOM_EX_VALVE 19 // Zone 3: output to a Relay that controls the Valve(s)
#define APARTMENTS_EX_VALVE 20 // Zone 3: output to a Relay that controls the Valve(s)
#define DRESING_VALVE 21 // Zone 3: output to a Relay that controls the Valve(s)
//define TEMPERATURE SENSORS Zona 1 GROUND
#define LIVING t1 // Zone 1; input wired to the thermostat in the living ground floor
#define GROUND_OFFICE t2 // Zone 1; input wired to the thermostat in the ground office
#define ENTRANCE t3 // Zone 1; input wired to the thermostat in the main hall
//define TEMPERATURE SENSORS Zona 2 FIRST FLOOR
#define LIVING_1_FLOOR t4 ` // Zone 2; input wired to the thermostat in the living 1 floor
#define MASTER BEDROOM t5 // Zone 2; input wired to the thermostat in the master bedroom
#define SMALL_BEDROOM t6 // Zone 2; input wired to the thermostat in the small bedroom
//define TEMPERATURE SENSORS Zona 3 EXTENSION
#define BEDROOM_EXT t7 // Zone 3; input wired to the thermostat in the bedroom extension
#define DRESING_EXT t8 // Zone 3; input wired to the thermostat in the dressing extension
#define APT_EXT t9 // Zone 3; input wired to the thermostat in the apartment extension
//FLOOR_PUMP
#define PUFFER_IN t10 // Zone 3; input wired to the thermostat in the dining
#define PUFFER_OUT t11 // Zone 3; input wired to the thermostat in the dining
#define HEATING_LED 26 // On when heating, Alternates during cooldown, is Off in idle mode
#define INDICATION_LED 27 // Alternates the on board LED to indicate board runs; can be easily removed to free an extra IO pin!
#define RELAY_ON 0
#define RELAY_OFF 1
int licznik = 0; // Counter readings
int tset=24; // temperature setings for interior °C -REF_TEMP
// END CONFIGURATION BLOCK
//////////////////////////////////////////////////
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature.
DeviceAddress t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 , t12 , t13, t14, t15, t16, t17; // arrays to hold device addresses
void setup(void)
{
// Initialize LCD to 20 characters by 4 lines
//lcd.begin(20, 4);
//lcd.clear();
lcd.begin(columns, rows); //Tell the LCD that it is a Columns x Rows LCD
pinMode(contrast, OUTPUT); //set pin contrast to OUTPUT
pinMode(bright, OUTPUT); //Set pin brightness to OUTPUT
digitalWrite(bright, HIGH); //LOW and HIGH <- digitalWrite OR analogWrite value 0-255 240
analogWrite(contrast, 50); //LOW and HIGH <- digitalWrite OR analogWrite value 0-255 54
lcd.noCursor(); //Disable cursor on LCD
lcd.clear(); //Clear Screen on LCD
Serial.begin(9600); //Start serial port
Serial.println("Dallas Temperature IC Control Library");
// Start up the library
sensors.begin();
// locate devices on the bus
Serial.print("Locating devices........");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" Devices.");
// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
// Search for devices on the bus and assign based on an index. Ideally,
// you would do this to initially discover addresses on the bus and then
// use those addresses and manually assign them (see above) once you know
// the devices on your bus (and assuming they don't change).
//
if (!sensors.getAddress(t1, 0)) {int t1=(tset-1);Serial.println("No Found Sensor 1");}
if (!sensors.getAddress(t2, 1)) {int t2=(tset-1);Serial.println("No Found Sensor 2");}
if (!sensors.getAddress(t3, 2)) {int t3=(tset-1);Serial.println("No Found Sensor 3");}
if (!sensors.getAddress(t4, 3)) {int t4=(tset-1);Serial.println("No Found Sensor 4");}
if (!sensors.getAddress(t5, 4)) {int t5=(tset-1);Serial.println("No Found Sensor 5");}
if (!sensors.getAddress(t6, 5)) {int t6=(tset-1);Serial.println("No Found Sensor 6");}
if (!sensors.getAddress(t7, 6)) {int t7=(tset-1);Serial.println("No Found Sensor 7");}
if (!sensors.getAddress(t8, 7)) {int t8=(tset-1);Serial.println("No Found Sensor 8");}
if (!sensors.getAddress(t9, 8)) {int t9=(tset-1);Serial.println("No Found Sensor 9");}
if (!sensors.getAddress(t10, 9)) {int t10=(tset-1);Serial.println("No Found Sensor 10");}
if (!sensors.getAddress(t11, 10)) {int t11=(tset-1);Serial.println("No Found Sensor 11");}
if (!sensors.getAddress(t12, 11)) {int t12=(tset-1);Serial.println("No Found Sensor 12");}
if (!sensors.getAddress(t13, 12)) {int t13=(tset-1);Serial.println("No Found Sensor 13");}
if (!sensors.getAddress(t14, 13)) {int t14=(tset-1);Serial.println("No Found Sensor 14");}
if (!sensors.getAddress(t15, 14)) {int t15=(tset-1);Serial.println("No Found Sensor 15");}
if (sensors.getDeviceCount() == 0 ) {
lcd.setCursor(0, 0);
lcd.print("NO Sensors !!!");
lcd.setCursor(0, 1);
lcd.print("CHECK SENSORS!!!");
delay (1200);
lcd.clear();
}
// show the addresses we found on the bus
for (int ilosc =0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor "); Serial.print(ilosc+1);
Serial.print(" Address: ");
if (ilosc == 0) { printAddress(t1); Serial.println();
} else if (ilosc == 1) { printAddress(t2); Serial.println();
} else if (ilosc == 2) { printAddress(t3); Serial.println();
} else if (ilosc == 3) { printAddress(t4); Serial.println();
} else if (ilosc == 4) { printAddress(t5); Serial.println();
} else if (ilosc == 5) { printAddress(t6); Serial.println();
} else if (ilosc == 6) { printAddress(t7); Serial.println();
} else if (ilosc == 7) { printAddress(t8); Serial.println();
} else if (ilosc == 8) { printAddress(t9); Serial.println();
} else if (ilosc == 9) { printAddress(t10); Serial.println();
} else if (ilosc == 10) { printAddress(t11); Serial.println();
} else if (ilosc == 11) { printAddress(t12); Serial.println();
} else if (ilosc == 12) { printAddress(t13); Serial.println();
} else if (ilosc == 13) { printAddress(t14); Serial.println();
} else if (ilosc == 14) { printAddress(t15); Serial.println();
} else if (ilosc == 15) { printAddress(t16); Serial.println();
} else if (ilosc == 16) { printAddress(t17); Serial.println();
}
}
// set the resolution to 9 bit per device
sensors.setResolution(t1, precision);
sensors.setResolution(t2, precision);
sensors.setResolution(t3, precision);
sensors.setResolution(t4, precision);
sensors.setResolution(t5, precision);
sensors.setResolution(t6, precision);
sensors.setResolution(t7, precision);
sensors.setResolution(t8, precision);
sensors.setResolution(t9, precision);
sensors.setResolution(t10, precision);
sensors.setResolution(t11, precision);
sensors.setResolution(t12, precision);
sensors.setResolution(t13, precision);
sensors.setResolution(t14, precision);
sensors.setResolution(t15, precision);
sensors.setResolution(t16, precision);
sensors.setResolution(t17, precision);
for (int ilosc = 0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor "); Serial.print(ilosc + 1);
Serial.print(" Resolution: ");
if (ilosc == 0) { Serial.print(sensors.getResolution(t1), DEC); Serial.println();
} else if (ilosc == 1) { Serial.print(sensors.getResolution(t2), DEC); Serial.println();
} else if (ilosc == 2) { Serial.print(sensors.getResolution(t3), DEC); Serial.println();
} else if (ilosc == 3) { Serial.print(sensors.getResolution(t4), DEC); Serial.println();
} else if (ilosc == 4) { Serial.print(sensors.getResolution(t5), DEC); Serial.println();
} else if (ilosc == 5) { Serial.print(sensors.getResolution(t6), DEC); Serial.println();
} else if (ilosc == 6) { Serial.print(sensors.getResolution(t7), DEC); Serial.println();
} else if (ilosc == 7) { Serial.print(sensors.getResolution(t8), DEC); Serial.println();
} else if (ilosc == 8) { Serial.print(sensors.getResolution(t9), DEC); Serial.println();
} else if (ilosc == 9) { Serial.print(sensors.getResolution(t10), DEC); Serial.println();
} else if (ilosc == 10) { Serial.print(sensors.getResolution(t11), DEC); Serial.println();
} else if (ilosc == 11) { Serial.print(sensors.getResolution(t12), DEC); Serial.println();
} else if (ilosc == 12) { Serial.print(sensors.getResolution(t13), DEC); Serial.println();
} else if (ilosc == 13) { Serial.print(sensors.getResolution(t14), DEC); Serial.println();
} else if (ilosc == 14) { Serial.print(sensors.getResolution(t15), DEC); Serial.println();
} else if (ilosc == 15) { Serial.print(sensors.getResolution(t16), DEC); Serial.println();
} else if (ilosc == 16) { Serial.print(sensors.getResolution(t17), DEC); Serial.println();
}
}
}
// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 20; i++)
{
// zero pad the address if necessary
if (deviceAddress[i] < 20) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
Serial.print("Temp: ");
Serial.print(tempC);
Serial.print("°C");
// Serial.print(" Temp F: ");
// Serial.print(DallasTemperature::toFahrenheit(tempC));
}
// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
//Serial.print("Resolution: ");
// Serial.print(sensors.getResolution(deviceAddress));
//Serial.println();
}
// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
Serial.print("Device Address: ");
printAddress(deviceAddress);
Serial.print(" ");
printTemperature(deviceAddress);
Serial.println();
}
/*
Main function, calls the temperatures in a loop.
*/
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature request to all devices on the bus
Serial.print("Reading DATA...request temperatures...."); sensors.requestTemperatures(); Serial.println("DONE");
// print the device information
for (int ilosc = 0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor no: "); Serial.print(ilosc + 1); Serial.print(" ");
if (ilosc == 0) { printData(t1);
} else if (ilosc == 1) { printData(t2);
} else if (ilosc == 2) { printData(t3);
} else if (ilosc == 3) { printData(t4);
} else if (ilosc == 4) { printData(t5);
} else if (ilosc == 5) { printData(t6);
} else if (ilosc == 6) { printData(t7);
} else if (ilosc == 7) { printData(t8);
} else if (ilosc == 8) { printData(t9);
} else if (ilosc == 9) { printData(t10);
} else if (ilosc == 10) { printData(t11);
} else if (ilosc == 11) { printData(t12);
} else if (ilosc == 12) { printData(t13);
} else if (ilosc == 13) { printData(t14);
} else if (ilosc == 15) { printData(t16);
} else if (ilosc == 16) { printData(t17);
}
}
if (sensors.getDeviceCount() <= 19) {
lcd.setCursor(0, 0);
lcd.print("Sensor Number "); lcd.print(licznik + 1);
lcd.setCursor(0, 1);
lcd.print(" Temp: ");
lcd.clear();
}
else if (sensors.getDeviceCount() > 19 ) {
lcd.setCursor(0, 0);
lcd.print("please add ");
lcd.setCursor(0, 1);
lcd.print(" SENSORS!!!");
delay (800);
lcd.clear();
}
if (licznik == 1) {
lcd.print(sensors.getTempC(t1)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 2) {
lcd.print(sensors.getTempC(t2)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 3) {
lcd.print(sensors.getTempC(t3)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 4) {
lcd.print(sensors.getTempC(t4)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 5) {
lcd.print(sensors.getTempC(t5)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 6) {
lcd.print(sensors.getTempC(t6)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 7) {
lcd.print(sensors.getTempC(t7)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 8) {
lcd.print(sensors.getTempC(t8)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 9) {
lcd.print(sensors.getTempC(t9)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 10) {
lcd.print(sensors.getTempC(t10)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 11) {
lcd.print(sensors.getTempC(t11)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 12) {
lcd.print(sensors.getTempC(t12)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 13) {
lcd.print(sensors.getTempC(t13)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 14) {
lcd.print(sensors.getTempC(t14)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 15) {
lcd.print(sensors.getTempC(t15)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 16) {
lcd.print(sensors.getTempC(t16)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 17) {
lcd.print(sensors.getTempC(t17)); lcd.write((char)223); lcd.print("°C");
}
//compare temperature sensor with temperature set
if (sensors.getTempC(t1) > tset){
Serial.print("Temp LIVING_GROUD ");
Serial.print(sensors.getTempC(t1));
Serial.print("°C");
Serial.println();
lcd.print("Temp LIVING_GROUD ");lcd.print(sensors.getTempC(t1));lcd.print("°C");
digitalWrite(LIVING_GROUND_VALVE,HIGH);
}else {digitalWrite(LIVING_GROUND_VALVE,LOW);
}
lcd.print("LIVING_GROUND_1&2_VALVE is ");
Serial.print("LIVING_GROUND_1&2_VALVE is ");
if (digitalRead (LIVING_GROUND_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t2) > tset){
Serial.print("Temp GROUND_OFFICE ");
Serial.print(sensors.getTempC(t2));
Serial.print("°C");
Serial.println();
lcd.print("Temp GROUND_OFFICE ");lcd.print(sensors.getTempC(t2));lcd.print("°C");
digitalWrite(GROUND_OFFICE_VALVE,HIGH);
}else {digitalWrite(GROUND_OFFICE_VALVE,LOW);
}
lcd.print("GROUND_OFFICE_VALVE is ");
Serial.print("GROUND_OFFICE_VALVE is ");
if (digitalRead (GROUND_OFFICE_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t3) > tset){
Serial.print("Temp LIVING_FIRST_FLOOR ");
Serial.print(sensors.getTempC(t3));
Serial.print("°C");
Serial.println();
lcd.print("Temp LIVING_FIRST_FLOOR ");lcd.print(sensors.getTempC(t3));lcd.print("°C");
digitalWrite(LIVING_FIRST_FLOOR_VALVE,HIGH);
}else {digitalWrite(LIVING_FIRST_FLOOR_VALVE,LOW);
}
lcd.print("LIVING_FIRST_FLOOR_VALVE is ");
Serial.print("LIVING_FIRST_FLOOR_VALVE is ");
if (digitalRead(LIVING_FIRST_FLOOR_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t4) > tset){
Serial.print("Temp MASTER_BEDROOM ");
Serial.print(sensors.getTempC(t4));
Serial.print("°C");
Serial.println();
lcd.print("Temp MASTER_BEDROOM ");lcd.print(sensors.getTempC(t4));lcd.print("°C");
digitalWrite(MASTER_BEDROOM_VALVE,HIGH);
}else {digitalWrite(MASTER_BEDROOM_VALVE,LOW);
}
lcd.print("MASTER_BEDROOM_VALVE is ");
Serial.print("MASTER_BEDROOM_VALVE is ");
if (digitalRead (MASTER_BEDROOM_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t5) > tset){
Serial.print("Temp SMALL_BEDROOM ");
Serial.print(sensors.getTempC(t5));
Serial.print("°C");
Serial.println();
lcd.print("Temp SMALL_BEDROOM ");lcd.print(sensors.getTempC(t5));lcd.print("°C");
digitalWrite(SMALL_BEDROOM_VALVE,HIGH);
}else {digitalWrite(SMALL_BEDROOM_VALVE,LOW);
}
lcd.print("SMALL_BEDROOM_VALVE is ");
Serial.print("SMALL_BEDROOM_VALVE is ");
if (digitalRead (SMALL_BEDROOM_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t6) > tset){
Serial.print("Temp BEDROOM_EX ");
Serial.print(sensors.getTempC(t6));
Serial.print("°C");
Serial.println();
lcd.print("Temp BEDROOM_EX ");lcd.print(sensors.getTempC(t6));lcd.print("°C");
digitalWrite(BEDROOM_EX_VALVE,HIGH);
}else {digitalWrite(BEDROOM_EX_VALVE,LOW);
}
lcd.print("BEDROOM_EX_VALVE is ");
Serial.print("BEDROOM_EX_VALVE is ");
if (digitalRead (BEDROOM_EX_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t7) > tset){
Serial.print("Temp APARTMENTS_EX ");
Serial.print(sensors.getTempC(t7));
Serial.print("°C");
Serial.println();
lcd.print("Temp APARTMENTS_EX ");lcd.print(sensors.getTempC(t7));lcd.print("°C");
digitalWrite(APARTMENTS_EX_VALVE,HIGH);
}else {digitalWrite(APARTMENTS_EX_VALVE,LOW);
}
lcd.print("APARTMENTS_EX_VALVE is ");
Serial.print("APARTMENTS_EX_VALVE is ");
if (digitalRead (APARTMENTS_EX_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(t8) > tset){
Serial.print("Temp DRESING ");
Serial.print(sensors.getTempC(t8));
Serial.print("°C");
Serial.println();
lcd.print("Temp DRESING ");lcd.print(sensors.getTempC(t8));lcd.print("°C");
digitalWrite(DRESING_VALVE,HIGH);
} else {digitalWrite(DRESING_VALVE,LOW);
}
lcd.print("DRESING_VALVE is ");
Serial.print("DRESING_VALVE is ");
if (digitalRead (DRESING_VALVE)==1) {
Serial.print(" on ");lcd.print(" on ");
}
else { Serial.print(" off ");lcd.print(" off ");
}
Serial.println();
Serial.print("sensor reading data loop number "); Serial.println(licznik);
delay(1200);
licznik++ ;
}
Have you tried the Ctrl+T ?
It is also in the menu: Tools / Auto Format
// 18.07.2022 floor heating unit by Razvan Bogaci
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize the LCD and tell it which pins is to be used for communicating
#define ONE_WIRE_BUS 8 // Data wire is plugged into port 8 on the Arduino
#define precision 12 // OneWire precision Dallas Sensor
#define contrast 9 // Define the pin that controls the contrast of the screen
#define bright 10 // Define the pin the controls the brightness of the screen
#define rows 2 // Define the rows in display LCD
#define columns 16 // Define the columns in display LCD
//Define PUMPS
#define HEATER_REC_PUMP 22 // output to a Relay that switches recirculation heating Unit Pump
#define HEATER_PUMP 23 // output to a Relay that switches puffer heating Pump
#define FLOOR_PUMP 24 // output to a Relay that switches the Floor Unit Pump
// DEFINE ZONE 1
#define LIVING_GROUND_VALVE 25 // Zone 1: output to a Relay that controls the Valve(s)
#define GROUND_OFFICE_VALVE 13 // Zone 1: output to a Relay that controls the Valve(s)
#define ENTRANCE_VALVE 14 // Zone 1: output to a Relay that controls the Valve(s)
// DEFINE ZONE 2
#define LIVING_FIRST_FLOOR_VALVE 16 // Zone 2: output to a Relay that controls the Valve(s)
#define MASTER_BEDROOM_VALVE 17 // Zone 2: output to a Relay that controls the Valve(s)
#define SMALL_BEDROOM_VALVE 18 // Zone 2: output to a Relay that controls the Valve(s)
// DEFINE ZONE 3
#define BEDROOM_EX_VALVE 19 // Zone 3: output to a Relay that controls the Valve(s)
#define APARTMENTS_EX_VALVE 20 // Zone 3: output to a Relay that controls the Valve(s)
#define DRESING_VALVE 21 // Zone 3: output to a Relay that controls the Valve(s)
//define TEMPERATURE SENSORS Zona 1 GROUND
#define LIVING T1 // Zone 1; input wired to the thermostat in the living ground floor
#define GROUND_OFFICE T2 // Zone 1; input wired to the thermostat in the ground office
#define ENTRANCE T3 // Zone 1; input wired to the thermostat in the main hall
//define TEMPERATURE SENSORS Zona 2 FIRST FLOOR
#define LIVING_1_FLOOR T4 ` // Zone 2; input wired to the thermostat in the living 1 floor
#define MASTER BEDROOM T5 // Zone 2; input wired to the thermostat in the master bedroom
#define SMALL_BEDROOM T6 // Zone 2; input wired to the thermostat in the small bedroom
//define TEMPERATURE SENSORS Zona 3 EXTENSION
#define BEDROOM_EXT T7 // Zone 3; input wired to the thermostat in the bedroom extension
#define DRESING_EXT T8 // Zone 3; input wired to the thermostat in the dressing extension
#define APT_EXT T9 // Zone 3; input wired to the thermostat in the apartment extension
//FLOOR_PUMP
#define PUFFER_IN T10 // Zone 3; input wired to the thermostat in the dining
#define PUFFER_OUT T11 // Zone 3; input wired to the thermostat in the dining
#define HEATING_LED 26 // On when heating, Alternates during cooldown, is Off in idle mode
#define INDICATION_LED 27 // Alternates the on board LED to indicate board runs; can be easily removed to free an extra IO pin!
#define RELAY_ON 0
#define RELAY_OFF 1
int licznik = 0; // Counter readings
int tset = 24; // temperature setings for interior °C -REF_TEMP
// END CONFIGURATION BLOCK
//////////////////////////////////////////////////
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature.
DeviceAddress T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17; // arrays to hold device addresses
void setup(void)
{
// Initialize LCD to 20 characters by 4 lines
//lcd.begin(20, 4);
//lcd.clear();
lcd.begin(columns, rows); //Tell the LCD that it is a Columns x Rows LCD
pinMode(contrast, OUTPUT); //set pin contrast to OUTPUT
pinMode(bright, OUTPUT); //Set pin brightness to OUTPUT
digitalWrite(bright, HIGH); //LOW and HIGH <- digitalWrite OR analogWrite value 0-255 240
analogWrite(contrast, 50); //LOW and HIGH <- digitalWrite OR analogWrite value 0-255 54
lcd.noCursor(); //Disable cursor on LCD
lcd.clear(); //Clear Screen on LCD
Serial.begin(9600); //Start serial port
Serial.println("Dallas Temperature IC Control Library");
// Start up the library
sensors.begin();
// locate devices on the bus
Serial.print("Locating devices........");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" Devices.");
// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
// Search for devices on the bus and assign based on an index. Ideally,
// you would do this to initially discover addresses on the bus and then
// use those addresses and manually assign them (see above) once you know
// the devices on your bus (and assuming they don't change).
//
if (!sensors.getAddress(T1, 0)) {
int T1 = (tset - 2);
Serial.println("No Found Sensor 1");
}
if (!sensors.getAddress(T2, 1)) {
int T2 = (tset - 2);
Serial.println("No Found Sensor 2");
}
if (!sensors.getAddress(T3, 2)) {
int T3 = (tset - 1);
Serial.println("No Found Sensor 3");
}
if (!sensors.getAddress(T4, 3)) {
int T4 = (tset - 1);
Serial.println("No Found Sensor 4");
}
if (!sensors.getAddress(T5, 4)) {
int T5 = (tset - 1);
Serial.println("No Found Sensor 5");
}
if (!sensors.getAddress(T6, 5)) {
int T6 = (tset - 1);
Serial.println("No Found Sensor 6");
}
if (!sensors.getAddress(T7, 6)) {
int T7 = (tset - 1);
Serial.println("No Found Sensor 7");
}
if (!sensors.getAddress(T8, 7)) {
int T8 = (tset - 1);
Serial.println("No Found Sensor 8");
}
if (!sensors.getAddress(T9, 8)) {
int T9 = (tset - 1);
Serial.println("No Found Sensor 9");
}
if (!sensors.getAddress(T10, 9)) {
int T10 = (tset - 1);
Serial.println("No Found Sensor 10");
}
if (!sensors.getAddress(T11, 10)) {
int T11 = (tset - 1);
Serial.println("No Found Sensor 11");
}
if (!sensors.getAddress(T12, 11)) {
int T12 = (tset - 1);
Serial.println("No Found Sensor 12");
}
if (!sensors.getAddress(T13, 12)) {
int T13 = (tset - 1);
Serial.println("No Found Sensor 13");
}
if (!sensors.getAddress(T14, 13)) {
int T14 = (tset - 1);
Serial.println("No Found Sensor 14");
}
if (!sensors.getAddress(T15, 14)) {
int T15 = (tset - 1);
Serial.println("No Found Sensor 15");
}
if (sensors.getDeviceCount() == 0 ) {
lcd.setCursor(0, 0);
lcd.print("NO Sensors !!!");
lcd.setCursor(0, 1);
lcd.print("CHECK SENSORS!!!");
delay (1200);
lcd.clear();
}
// show the addresses we found on the bus
for (int ilosc = 0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor "); Serial.print(ilosc + 1);
Serial.print(" Address: ");
if (ilosc == 0) {
printAddress(T1); Serial.println();
} else if (ilosc == 1) {
printAddress(T2); Serial.println();
} else if (ilosc == 2) {
printAddress(T3); Serial.println();
} else if (ilosc == 3) {
printAddress(T4); Serial.println();
} else if (ilosc == 4) {
printAddress(T5); Serial.println();
} else if (ilosc == 5) {
printAddress(T6); Serial.println();
} else if (ilosc == 6) {
printAddress(T7); Serial.println();
} else if (ilosc == 7) {
printAddress(T8); Serial.println();
} else if (ilosc == 8) {
printAddress(T9); Serial.println();
} else if (ilosc == 9) {
printAddress(T10); Serial.println();
} else if (ilosc == 10) {
printAddress(T11); Serial.println();
} else if (ilosc == 11) {
printAddress(T12); Serial.println();
} else if (ilosc == 12) {
printAddress(T13); Serial.println();
} else if (ilosc == 13) {
printAddress(T14); Serial.println();
} else if (ilosc == 14) {
printAddress(T15); Serial.println();
} else if (ilosc == 15) {
printAddress(T16); Serial.println();
} else if (ilosc == 16) {
printAddress(T17); Serial.println();
}
}
// set the resolution to 9 bit per device
sensors.setResolution(T1, precision);
sensors.setResolution(T2, precision);
sensors.setResolution(T3, precision);
sensors.setResolution(T4, precision);
sensors.setResolution(T5, precision);
sensors.setResolution(T6, precision);
sensors.setResolution(T7, precision);
sensors.setResolution(T8, precision);
sensors.setResolution(T9, precision);
sensors.setResolution(T10, precision);
sensors.setResolution(T11, precision);
sensors.setResolution(T12, precision);
sensors.setResolution(T13, precision);
sensors.setResolution(T14, precision);
sensors.setResolution(T15, precision);
sensors.setResolution(T16, precision);
sensors.setResolution(T17, precision);
for (int ilosc = 0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor "); Serial.print(ilosc + 1);
Serial.print(" Resolution: ");
if (ilosc == 0) {
Serial.print(sensors.getResolution(T1), DEC); Serial.println();
} else if (ilosc == 1) {
Serial.print(sensors.getResolution(T2), DEC); Serial.println();
} else if (ilosc == 2) {
Serial.print(sensors.getResolution(T3), DEC); Serial.println();
} else if (ilosc == 3) {
Serial.print(sensors.getResolution(T4), DEC); Serial.println();
} else if (ilosc == 4) {
Serial.print(sensors.getResolution(T5), DEC); Serial.println();
} else if (ilosc == 5) {
Serial.print(sensors.getResolution(T6), DEC); Serial.println();
} else if (ilosc == 6) {
Serial.print(sensors.getResolution(T7), DEC); Serial.println();
} else if (ilosc == 7) {
Serial.print(sensors.getResolution(T8), DEC); Serial.println();
} else if (ilosc == 8) {
Serial.print(sensors.getResolution(T9), DEC); Serial.println();
} else if (ilosc == 9) {
Serial.print(sensors.getResolution(T10), DEC); Serial.println();
} else if (ilosc == 10) {
Serial.print(sensors.getResolution(T11), DEC); Serial.println();
} else if (ilosc == 11) {
Serial.print(sensors.getResolution(T12), DEC); Serial.println();
} else if (ilosc == 12) {
Serial.print(sensors.getResolution(T13), DEC); Serial.println();
} else if (ilosc == 13) {
Serial.print(sensors.getResolution(T14), DEC); Serial.println();
} else if (ilosc == 14) {
Serial.print(sensors.getResolution(T15), DEC); Serial.println();
} else if (ilosc == 15) {
Serial.print(sensors.getResolution(T16), DEC); Serial.println();
} else if (ilosc == 16) {
Serial.print(sensors.getResolution(T17), DEC); Serial.println();
}
}
}
// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 18; i++)
{
// zero pad the address if necessary
if (deviceAddress[i] < 18) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
Serial.print("Temp: ");
Serial.print(tempC);
Serial.print("°C");
// Serial.print(" Temp F: ");
// Serial.print(DallasTemperature::toFahrenheit(tempC));
}
// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
//Serial.print("Resolution: ");
// Serial.print(sensors.getResolution(deviceAddress));
//Serial.println();
}
// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
Serial.print("Device Address: ");
printAddress(deviceAddress);
Serial.print(" ");
printTemperature(deviceAddress);
Serial.println();
}
/*
Main function, calls the temperatures in a loop.
*/
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature request to all devices on the bus
Serial.print("Reading DATA...request temperatures...."); sensors.requestTemperatures(); Serial.println("DONE");
// print the device information
for (int ilosc = 0; ilosc < sensors.getDeviceCount(); ilosc++) {
Serial.print("Sensor no: "); Serial.print(ilosc + 1); Serial.print(" ");
if (ilosc == 0) {
printData(T1);
} else if (ilosc == 1) {
printData(T2);
} else if (ilosc == 2) {
printData(T3);
} else if (ilosc == 3) {
printData(T4);
} else if (ilosc == 4) {
printData(T5);
} else if (ilosc == 5) {
printData(T6);
} else if (ilosc == 6) {
printData(T7);
} else if (ilosc == 7) {
printData(T8);
} else if (ilosc == 8) {
printData(T9);
} else if (ilosc == 9) {
printData(T10);
} else if (ilosc == 10) {
printData(T11);
} else if (ilosc == 11) {
printData(T12);
} else if (ilosc == 12) {
printData(T13);
} else if (ilosc == 13) {
printData(T14);
} else if (ilosc == 14) {
printData(T15);
} else if (ilosc == 15) {
printData(T16);
} else if (ilosc == 16) {
printData(T17);
}
}
if (sensors.getDeviceCount() <= 17) {
lcd.setCursor(0, 0);
lcd.print("Sensor Number "); lcd.print(licznik + 1);
lcd.setCursor(0, 1);
lcd.print(" Temp: ");
lcd.clear();
}
else if (sensors.getDeviceCount() > 17 ) {
lcd.setCursor(0, 0);
lcd.print("please add ");
lcd.setCursor(0, 1);
lcd.print(" SENSORS!!!");
delay (800);
lcd.clear();
}
if (licznik == 1) {
lcd.print(sensors.getTempC(T1)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 2) {
lcd.print(sensors.getTempC(T2)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 3) {
lcd.print(sensors.getTempC(T3)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 4) {
lcd.print(sensors.getTempC(T4)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 5) {
lcd.print(sensors.getTempC(T5)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 6) {
lcd.print(sensors.getTempC(T6)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 7) {
lcd.print(sensors.getTempC(T7)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 8) {
lcd.print(sensors.getTempC(T8)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 9) {
lcd.print(sensors.getTempC(T9)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 10) {
lcd.print(sensors.getTempC(T10)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 11) {
lcd.print(sensors.getTempC(T11)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 12) {
lcd.print(sensors.getTempC(T12)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 13) {
lcd.print(sensors.getTempC(T13)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 14) {
lcd.print(sensors.getTempC(T14)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 15) {
lcd.print(sensors.getTempC(T15)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 16) {
lcd.print(sensors.getTempC(T16)); lcd.write((char)223); lcd.print("°C");
} else if (licznik == 17) {
lcd.print(sensors.getTempC(T17)); lcd.write((char)223); lcd.print("°C");
}
//compare temperature sensor with temperature set
if (sensors.getTempC(T1) > tset) {
Serial.print("Temp LIVING_GROUD ");
Serial.print(sensors.getTempC(T1));
Serial.print("°C");
Serial.println();
lcd.print("Temp LIVING_GROUD "); lcd.print(sensors.getTempC(T1)); lcd.print("°C");
free(T1);
digitalWrite(LIVING_GROUND_VALVE, HIGH);
}
else {
digitalWrite(LIVING_GROUND_VALVE, LOW);
}
lcd.print("LIVING_GROUND_1&2_VALVE is ");
Serial.print("LIVING_GROUND_1&2_VALVE is ");
if (digitalRead (LIVING_GROUND_VALVE) == 1) {
Serial.print(" on "); lcd.print(" on ");
}
else {
Serial.print(" off "); lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(T2) > tset) {
Serial.print("Temp GROUND_OFFICE ");
Serial.print(sensors.getTempC(T2));
Serial.print("°C");
Serial.println();
lcd.print("Temp GROUND_OFFICE "); lcd.print(sensors.getTempC(T2)); lcd.print("°C");
free(T2);
digitalWrite(GROUND_OFFICE_VALVE, HIGH);
}
else {
digitalWrite(GROUND_OFFICE_VALVE, LOW);
}
lcd.print("GROUND_OFFICE_VALVE is ");
Serial.print("GROUND_OFFICE_VALVE is ");
if (digitalRead (GROUND_OFFICE_VALVE) == 1) {
Serial.print(" on "); lcd.print(" on ");
}
else {
Serial.print(" off "); lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(T3) > tset) {
Serial.print("Temp LIVING_FIRST_FLOOR ");
Serial.print(sensors.getTempC(T3));
Serial.print("°C");
Serial.println();
lcd.print("Temp LIVING_FIRST_FLOOR "); lcd.print(sensors.getTempC(T3)); lcd.print("°C");
free(T3);
digitalWrite(LIVING_FIRST_FLOOR_VALVE, HIGH);
}
else {
digitalWrite(LIVING_FIRST_FLOOR_VALVE, LOW);
}
lcd.print("LIVING_FIRST_FLOOR_VALVE is ");
Serial.print("LIVING_FIRST_FLOOR_VALVE is ");
if (digitalRead(LIVING_FIRST_FLOOR_VALVE) == 1) {
Serial.print(" on "); lcd.print(" on ");
}
else {
Serial.print(" off "); lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(T4) > tset) {
Serial.print("Temp MASTER_BEDROOM ");
Serial.print(sensors.getTempC(T4));
Serial.print("°C");
Serial.println();
lcd.print("Temp MASTER_BEDROOM "); lcd.print(sensors.getTempC(T4)); lcd.print("°C");
free(T4);
digitalWrite(MASTER_BEDROOM_VALVE, HIGH);
}
else {
digitalWrite(MASTER_BEDROOM_VALVE, LOW);
}
lcd.print("MASTER_BEDROOM_VALVE is ");
Serial.print("MASTER_BEDROOM_VALVE is ");
if (digitalRead (MASTER_BEDROOM_VALVE) == 1) {
Serial.print(" on "); lcd.print(" on ");
}
else {
Serial.print(" off "); lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(T5) > tset) {
Serial.print("Temp SMALL_BEDROOM ");
Serial.print(sensors.getTempC(T5));
Serial.print("°C");
Serial.println();
lcd.print("Temp SMALL_BEDROOM "); lcd.print(sensors.getTempC(T5)); lcd.print("°C");
free(T5);
digitalWrite(SMALL_BEDROOM_VALVE, HIGH);
}
else {
digitalWrite(SMALL_BEDROOM_VALVE, LOW);
}
lcd.print("SMALL_BEDROOM_VALVE is ");
Serial.print("SMALL_BEDROOM_VALVE is ");
if (digitalRead (SMALL_BEDROOM_VALVE) == 1) {
Serial.print(" on "); lcd.print(" on ");
}
else {
Serial.print(" off "); lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(T6) > tset) {
Serial.print("Temp BEDROOM_EX ");
Serial.print(sensors.getTempC(T6));
Serial.print("°C");
Serial.println();
lcd.print("Temp BEDROOM_EX "); lcd.print(sensors.getTempC(T6)); lcd.print("°C");
free(T6);
digitalWrite(BEDROOM_EX_VALVE, HIGH);
}
else {
digitalWrite(BEDROOM_EX_VALVE, LOW);
}
lcd.print("BEDROOM_EX_VALVE is ");
Serial.print("BEDROOM_EX_VALVE is ");
if (digitalRead (BEDROOM_EX_VALVE) == 1) {
Serial.print(" on "); lcd.print(" on ");
}
else {
Serial.print(" off "); lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(T7) > tset) {
Serial.print("Temp APARTMENTS_EX ");
Serial.print(sensors.getTempC(T7));
Serial.print("°C");
Serial.println();
lcd.print("Temp APARTMENTS_EX "); lcd.print(sensors.getTempC(T7)); lcd.print("°C");
free(T7);
digitalWrite(APARTMENTS_EX_VALVE, HIGH);
}
else {
digitalWrite(APARTMENTS_EX_VALVE, LOW);
}
lcd.print("APARTMENTS_EX_VALVE is ");
Serial.print("APARTMENTS_EX_VALVE is ");
if (digitalRead (APARTMENTS_EX_VALVE) == 1) {
Serial.print(" on "); lcd.print(" on ");
}
else {
Serial.print(" off "); lcd.print(" off ");
}
Serial.println();
if (sensors.getTempC(T8) > tset) {
Serial.print("Temp DRESING ");
Serial.print(sensors.getTempC(T8));
Serial.print("°C");
Serial.println();
lcd.print("Temp DRESING "); lcd.print(sensors.getTempC(T8)); lcd.print("°C"); \
free(T8);
digitalWrite(DRESING_VALVE, HIGH);
}
else {
digitalWrite(DRESING_VALVE, LOW);
}
lcd.print("DRESING_VALVE is ");
Serial.print("DRESING_VALVE is ");
if (digitalRead (DRESING_VALVE) == 1) {
Serial.print(" on "); lcd.print(" on ");
}
else {
Serial.print(" off "); lcd.print(" off ");
}
Serial.println();
Serial.print("sensor reading data loop number "); Serial.println(licznik);
delay(6000);
licznik++ ;
}
Thanks a lot! Right now I thik is looks more clean.
Use the F macro as suggested to save RAM. Anywhere you're just printing text it'll leave it in PROGMEM.
Where you have this:
lcd.print("LIVING_GROUND_1&2_VALVE is ");
Serial.print("LIVING_GROUND_1&2_VALVE is ");
Use this instead:
lcd.print(F("LIVING_GROUND_1&2_VALVE is "));
Serial.print(F("LIVING_GROUND_1&2_VALVE is "));
Compiled and linked for an Arduino MEGA:
Sketch uses 13470 bytes (5%) of program storage space. Maximum is 253952 bytes.
Global variables use 1490 bytes (18%) of dynamic memory, leaving 6702 bytes for local variables. Maximum is 8192 bytes.
Good point. No need for F at all.
I think it is more of a structured system design problem.
In its current form it is a spaghetti program where the functionality has been copied together with COPY/PASTE.
However, I recommend studying the IPO principle and creating functions, objects and methods.
This way rooms, sensors, valves, pumps and whatever can be easily added.
Have a nice day and enjoy programming in C++ and learning.
A programming language is meant to prevent repetitive source code.
My suggestion is to select one of the two:
- Make a sketch for just one temperature sensor.
- Use an array.
An array can be like this:
// global variable:
DeviceAddress Taddress[17];
// in setup():
for (int i=0; i<17; i++)
{
if (!sensors.getAddress(Taddress[i], 0))
{
Serial.print( "Sensor ");
Serial.print( i);
Serial.println( " not found");
}
// in the loop():
for (int i=0; i<17; i++)
{
lcd.print(sensors.getTempC(Taddress[i]));
lcd.write((char)223);
lcd.print("C");
}
Thanks a lot for your example and it is a good point of view.
In reality I have 2 hydraulic circuits for this area. This is like a remainder for this particularity.
Paul, yes you are right. Is not all copy /paste. I try to build this device for optimization floor heating in all this area. I want to link this with a computer and have possibility to collect all this information and make some graphics. This is a way I can learn fast with your advice...Yes I have prepare an arduino Mega, but it is a easy way. For this choice I have no obstacle regarding free memory, but I want to learn in hard way.
I am grateful all of you for your support and I am open to your solution.
I don't have a solution, but some ideas on how to design this heating system.
What is this new variable T1 for? It is never used.
What do you imagine this line will do?
Here's my tip: never copy a single line of code into your sketch unless you know exactly what is does and why it is needed.
That would be an amazing programming language, if it is ever created! But I don't think it's possible. I think the closest possibility would be a compiler/interpreter/IDE that could spot what might be repetitive code and offer advice to the programmer about ways to remove it.
I think what you meant is that (good) programming languages allow a (good) programmer to avoid writing repetitive source code. But there is no way they can prevent a bad programmer from repeating code.
But good programmer is will become in time, so I want to guide my way nothing else. I am at beginning is my second project for me. Please not shot me right now, I will louse my interest in this project. I know if you want be good in this , is needed at least 10000 hours of programming.
So I need guidance from your side nothing else. I have an idea and I want to put in practice with your support.
That's the number of hours typically quoted for mastery. You can get by with far far less for some simple Arduino coding.
Look at arrays of struct. You will need to associate a DS18B20's address with a location name and a valve pin number and they will let you do it. The code can then be shrunk to a tiny fraction of its current size.
Hello Guys, I study for a couple of days how to read with low memory temp from sensors. I modify my last sketch. so I want to read in a string address for all sensors and convert in a character. I do this to be able to change any broken sensor without any modification on arduino programs.
For control each hydraulic circuit I want to declare an struct Heat { byte Zone[i};byte Dev_Temp_Valve;} to be more easy to Work wit this. Zone[i] it have 9 parameter's characters. and another array for device like temperature and valve. Do you think is a good way ?