I suppose this could also be put under project guidance but i picked this becuase i am having a lot of confusion about the programming. This is only my second Arduino project. I wanted to use a fridge and a seedling heat mat to make a temperature control system that will maintain a given temperature regardless of the temperature outside the fridge. That's what i mean by year-round. This is my source.
The code from there is 5 years old and not mine. Currently, the problems with the code are to do with the warming and cooling functions. The stuff about Probe02, Temp02SetPoint, Temp02SetDiff, Temp02WarmMaxed is tied into the warming function because the original guy who wrote that wanted to have another probe just outside of the fermenter. Then there is something wrong with how the void loop() ends. It expected something before the curly bracket closing the loop.
I dont understand how to make it work for my case where i only plan on controlling one fermenter with a single DSB18B20 probe. This also means to use the lcd.setCursor() and lcd.print() commands to display only the results of one probe and fermenter show on the LCD. I made the probe and Adafruit LCD work independently with the examples from the library folders. The code i have so far is:
/* Multiple DS18B20 Temperature Sensors on 1 wire
for controlling heating or cooling of muliple fermenters.
*/
/*-----( Import needed libraries )-----*/
// Get 1-wire Library here: http://www.pjrc.com/teensy/td_libs_OneWire.html
#include <OneWire.h>
//Get DallasTemperature Library here: http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library
#include <DallasTemperature.h>
/*-----( Declare Constants and Pin Numbers )-----*/
// Digital pin 2 for all the DS18B20 data lines.
#define ONE_WIRE_BUS_PIN 2
#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>
/*-----( 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 )-----*/
// Pre-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
// Uncomment the following lines for preassigning the addresses to the probes variable
DeviceAddress Probe01 = { 0x28, 0xFF, 0xFB, 0x74, 0x44, 0xE0, 0x48, 0x66 };
//DeviceAddress Probe02 = { };
//DeviceAddress Probe03 = { };
//DeviceAddress Probe04 = { };
//DeviceAddress Probe05 = { };
//Relay digital write pins on Arduino
int Relay1 = 5;
int Relay2 = 6;
float Probe01Temp = 0;
///float Probe02Temp = 0;
///float Probe03Temp = 0;
//Limit and floor are Celcius
//Adjust these temperature limits as needed
int Temp01SetPoint = 15;
int Temp01SetDiff = 1;
int Temp02SetPoint = 15;
int Temp02SetDiff = 1;
static bool Temp01CoolMaxed;
static bool Temp01WarmMaxed;
static bool Temp02CoolMaxed;
static bool Temp02WarmMaxed;
static bool Relay01Status;
static bool Relay02Status;
//Adjust the address of the I2C as needed
//See https://github.com/todbot/arduino-i2c-scanner
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
void setup() /****** SETUP: RUNS ONCE ******/
{
// start lcd to show results
lcd.begin(20,4);
lcd.setCursor(0, 0);
lcd.print("Starting Up");
// Initialize the Temperature measurement library
sensors.begin();
// Comment out the following three lines if pre-assigned above
///sensors.getAddress(Probe01, 0);
///sensors.getAddress(Probe02, 1);
///sensors.getAddress(Probe03, 2);
// set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
sensors.setResolution(Probe01, 10);
///sensors.setResolution(Probe02, 9);
///sensors.setResolution(Probe03, 9);
///sensors.setResolution(Probe04, 10);
///sensors.setResolution(Probe05, 10);
//set the relays
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
//turn off the relays to start
digitalWrite(Relay1, HIGH);
digitalWrite(Relay2, HIGH);
Temp01CoolMaxed = false;
Temp01WarmMaxed = false;
Temp02CoolMaxed = false;
Temp02WarmMaxed = false;
Relay01Status = false;
Relay02Status = false;
lcd.setCursor(0, 1);
lcd.print("No sensors:");
lcd.setCursor(12, 1);
lcd.print(sensors.getDeviceCount());
lcd.setCursor(0, 2);
lcd.print("Getting temperatures");
delay(500);
lcd.clear();
//Set up labels on LCD
lcd.setCursor(0, 0);
lcd.print("C");
lcd.setCursor(1,0);
lcd.print("T1:");
lcd.setCursor(6,0);
lcd.print("-");
lcd.setCursor(8,0);
lcd.print("C");
lcd.setCursor(10,0);
lcd.print("H");
lcd.setCursor(11,0);
lcd.print("T2:");
lcd.setCursor(16,0);
lcd.print("+");
lcd.setCursor(18,0);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Carby1 Carby2 Outsde");
lcd.setCursor(5, 2);
lcd.print("C");
lcd.setCursor(12, 2);
lcd.print("C");
lcd.setCursor(19,2);
lcd.print("C");
lcd.setCursor(0, 3);
lcd.print("CL");
lcd.setCursor(2,3);
lcd.print("R1:");
lcd.setCursor(10,3);
lcd.print("HT");
lcd.setCursor(12,3);
lcd.print("R2:");
lcd.setCursor(4,0);
lcd.print(Temp01SetPoint);
lcd.setCursor(7,0);
lcd.print(Temp01SetDiff);
lcd.setCursor(14,0);
lcd.print(Temp02SetPoint);
lcd.setCursor(17,0);
lcd.print(Temp02SetDiff);
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
delay(5000);
// Command all devices on bus to read temperature
sensors.requestTemperatures();
//First carboy
Probe01Temp = sensors.getTempC(Probe01);
//Second carboy
///Probe02Temp = sensors.getTempC(Probe02);
//Outside temperature
///Probe03Temp = sensors.getTempC(Probe03);
//Change calls to triggerCoolingRelay and triggerWarmingRelay
//as needed such as both Relay01 and Relay02 both call triggerWarmingRelay()
Relay01Status=triggerCoolingRelay(Probe01Temp, Relay1, Temp01SetPoint, Temp01SetDiff, Temp01CoolMaxed);
Temp01CoolMaxed=Relay01Status;
Relay02Status=triggerWarmingRelay(Probe02Temp, Relay2, Temp02SetPoint, Temp02SetDiff, Temp02WarmMaxed);
Temp02WarmMaxed=Relay02Status;
//Print to LCD
lcd.setCursor(0,2);
lcd.print(Probe01Temp - 3.5);
///lcd.setCursor(7,2);
///lcd.print(Probe02Temp);
///lcd.setCursor(14,2);
///lcd.print(Probe03Temp);
lcd.setCursor(5,3);
if (Relay01Status)
{
lcd.print("On ");
}
else
{
lcd.print("Off");
}
lcd.setCursor(15,3);
///if (Relay02Status)
///{
///lcd.print("On ");
///}
///else
///{
/// lcd.print("Off");
}
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
bool triggerCoolingRelay(float tempC, int Relay, int TempSetLimit, int TempSetDiff, bool TempCoolMaxed)
{
bool result;
if (TempCoolMaxed)
{
if (tempC < (TempSetLimit-TempSetDiff))
{
//TempCoolMaxed=false;
result=false;
}
}
else
{
if (tempC > TempSetLimit)
{
//TempCoolMaxed=true;
digitalWrite(Relay, LOW);
result=true;
}
else
{
digitalWrite(Relay, HIGH);
result=false;
}
}
return result;
}// End triggerCoolingRelay
bool triggerWarmingRelay(float tempC, int Relay, int TempSetLimit, int TempSetDiff, bool TempWarmMaxed)
{
bool result;
if (TempWarmMaxed)
{
if (tempC > (TempSetLimit+TempSetDiff))
{
//TempWarmMaxed=false;
result=false;
}
}
else
{
if (tempC < TempSetLimit)
{
//TempWarmMaxed=true;
digitalWrite(Relay, LOW);
result=true;
}
else
{
digitalWrite(Relay, HIGH);
result=false;
}
}
return result;
}// End triggerWarmingRelay
The error code in red is:
C:\Users\hirde\Desktop\Circuitry projects\projects\all-seasons-temp-controller\all-seasons-temp-controller.ino: In function 'void loop()':
all-seasons-temp-controller:174:17: error: 'triggerCoolingRelay' was not declared in this scope
Relay01Status=triggerCoolingRelay(Probe01Temp, Relay1, Temp01SetPoint, Temp01SetDiff, Temp01CoolMaxed);
^~~~~~~~~~~~~~~~~~~
all-seasons-temp-controller:176:37: error: 'Probe02Temp' was not declared in this scope
Relay02Status=triggerWarmingRelay(Probe02Temp, Relay2, Temp02SetPoint, Temp02SetDiff, Temp02WarmMaxed);
^~~~~~~~~~~
C:\Users\hirde\Desktop\Circuitry projects\projects\all-seasons-temp-controller\all-seasons-temp-controller.ino:176:37: note: suggested alternative: 'Probe01Temp'
Relay02Status=triggerWarmingRelay(Probe02Temp, Relay2, Temp02SetPoint, Temp02SetDiff, Temp02WarmMaxed);
^~~~~~~~~~~
Probe01Temp
all-seasons-temp-controller:176:17: error: 'triggerWarmingRelay' was not declared in this scope
Relay02Status=triggerWarmingRelay(Probe02Temp, Relay2, Temp02SetPoint, Temp02SetDiff, Temp02WarmMaxed);
^~~~~~~~~~~~~~~~~~~
C:\Users\hirde\Desktop\Circuitry projects\projects\all-seasons-temp-controller\all-seasons-temp-controller.ino: At global scope:
all-seasons-temp-controller:207:1: error: expected declaration before '}' token
}//--(end main loop )---
^
exit status 1
'triggerCoolingRelay' was not declared in this scope
Any help is appreciated. Cheers!