DS18B20 Temp Controller

I have a temp controller I built using an Arduino and a series of DS18B20 sensors. The arduino is plugged into a laptop and provides output on the sensors over the serial port. I want to build a web based GUI front end for this to display the temps and other info. As part of the process I am updating the code to try and make it a little bit cleaner and work more efficiently.

I have tried to build a class that handles checking the temp, setting the relay to HIGH or LOW and outputting the data to the serial monitor.

The class needs the address of the sensor passed to it, so it can check the temp. The problem I have at the moment is with passing the sensor address to the class. I am getting the following error

error: cannot initialize a parameter of type ‘const uint8_t *’ (aka ‘const unsigned char *’) with an lvalue of type ‘byte’ (aka ‘unsigned char’)

Which leads me to think I am using the wrong variable type for the sensor address. I have tried several options and still get errors of this nature.

Is there something I am missing here? Is it even possible to do it this way?

Any help or advise would be appreciated.

Here is my code.

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS_PIN 2

// 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);

// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress Probe01 = {0x28, 0x6B, 0xE3, 0x2A, 0x06, 0x00, 0x00, 0x0B};     //Temp Probe Tank3 - FV2 Miguel
DeviceAddress Probe02 = {0x28, 0x73, 0xA0, 0x2C, 0x06, 0x00, 0x00, 0x5F};     //Temp Probe Glycol Line Mid Point
DeviceAddress Probe03 = {0x28, 0xDE, 0x86, 0x2C, 0x06, 0x00, 0x00, 0x2D};     //Temp Probe Tank1 - BBT1 Wayki
DeviceAddress Probe04 = {0x28, 0x86, 0x67, 0x2C, 0x06, 0x00, 0x00, 0xB5};     //Temp Probe Tank4 - FV3 Chato
DeviceAddress Probe05 = {0x28, 0xEA, 0xEF, 0x2A, 0x06, 0x00, 0x00, 0xF7};     //Temp Probe Glycol Line Start Point
DeviceAddress Probe06 = {0x28, 0xAD, 0x76, 0x2A, 0x06, 0x00, 0x00, 0x43};     //Temp Probe Glycol Line End Point
DeviceAddress Probe07 = {0x28, 0xDD, 0x03, 0x2C, 0x06, 0x00, 0x00, 0x6D};     //Temp Probe Tank2 - FV1 Lex
DeviceAddress Probe08 = {0x28, 0x82, 0xB1, 0x2B, 0x06, 0x00, 0x00, 0x2D};     //Temp Probe Walk In Cooler - Fridge
DeviceAddress Probe09 = {0x28, 0x73, 0x3B, 0x2B, 0x06, 0x00, 0x00, 0x1E};     //Temp Probe Glycol Tank


/*Define Temp Set Points - If tank not in use set high 100C
CHECK YOUR TANK CAREFULLY!*/
long BBTSetPoint = 150;  //Wayki BBT  1.5
long FV1SetPoint = 4;  //Lex
long FV2SetPoint = 100;   //Miguel
long FV3SetPoint= 18.5;  //Chato
long FridgeSetPoint = 3.5;  //Walk in Cooler

/*Differential*/
long FVDiff = 0.5;
long BBTDiff = 0.3;
long FridgeDiff = 3.0;

class MasterRelay
{
  //Class Member Variables Initialize at startup
  int RelayPin;
  long Interval;
  
  // State Variables
  int RelayState;
  unsigned long previousMillis;
  
  // Constuctor creates a Relay
  public:
  MasterRelay(int pin, long time)
  {
    RelayPin = pin;
    pinMode(RelayPin, OUTPUT);
        
    Interval = time;
    
    RelayState = LOW;
    previousMillis = 0;
  }
 
  void Update()
  {
    //Check to see if Valves are OPEN
    unsigned long currentMillis = millis();

    
    if(currentMillis - previousMillis > Interval)
      {
       previousMillis = currentMillis;
  
        /*Check if any valves are open. If yes, turn pump on, in No, pump off*/
        if ( digitalRead(7) == LOW && digitalRead(8) == LOW && digitalRead(9) == LOW && digitalRead(10) == LOW && digitalRead(12) == LOW )
        {
        RelayState = LOW;
        digitalWrite(RelayPin, RelayState);
        }

        else if ( digitalRead(7) == HIGH || digitalRead(8) == HIGH || digitalRead(9) == HIGH || digitalRead(10) == HIGH || digitalRead(12) == HIGH )
        {
        RelayState = HIGH;
        digitalWrite(RelayPin, RelayState);
        }            
      
      Serial.println();
      Serial.print("Relay ");
      Serial.print(RelayPin);
      Serial.print(": ");
      Serial.print(RelayState);
 
     }
  } 
};


class ValveRelay
{
  //Class Member Variables Initialize at startup
  int RelayPin;
  long Interval;
  long Diff;
  long SetPoint;
  byte ProbeNum;
  
  // State Variables
  int RelayState;
  unsigned long previousMillis;
  long currentTemp;
  
  // Constuctor creates a Relay
  public:
  ValveRelay(int pin, long time, long difference, long tempSP, byte Probe)
  {
    RelayPin = pin;
    pinMode(RelayPin, OUTPUT);
        
    Interval = time;
    Diff = difference;
    SetPoint = tempSP;
    ProbeNum = Probe;
    
    RelayState = LOW;
    previousMillis = 0;
  }
 
  void Update()
  {
    //Check to see if it´s time to check temps
    unsigned long currentMillis = millis();
    sensors.requestTemperatures(); // Send the command to get temperatures
    
    if(currentMillis - previousMillis > Interval)
      {
       previousMillis = currentMillis;
       currentTemp = sensors.getTempC(ProbeNum);
            
      /* Check Temp */
      if ( currentTemp == -127 || currentTemp == 85 )
      {
        Serial.println();
        Serial.print("Sensor ERROR on: ");
        Serial.print(ProbeNum);
      }
      else
      {
        if ( currentTemp <= SetPoint )
        {
          RelayState = LOW;
          digitalWrite(RelayPin, RelayState);
        }

        else if ( currentTemp > ( SetPoint + Diff) )
        {
          RelayState = HIGH;
          digitalWrite(RelayPin, RelayState);
        }
        
        //Serial Output
        Serial.println();
        Serial.println("Set Point : ");    
        Serial.print(SetPoint);
        Serial.println("Probe ");
        Serial.print(ProbeNum);
        Serial.print(" Temperature is : ");
        Serial.print(currentTemp);
      }
      
      Serial.println();
      Serial.print("Relay ");
      Serial.print(RelayPin);
      Serial.print(": ");
      Serial.print(RelayState);
 
     }
  } 
};

//ValveRelay(int pin, long time, long difference, long tempSP, int Probe) 
  ValveRelay relay1(7, 120000, BBTDiff, BBTSetPoint, Probe03);                //  Relay 1 BBT1 using Probe 3 and PIN 7
  ValveRelay relay2(8, 120000, FVDiff, FV1SetPoint, Probe07);                 //  Relay 2 FV1 using Probe 7 and PIN 8
  ValveRelay relay3(9, 120000, FVDiff, FV2SetPoint, Probe01);                 //  Relay 3 FV2 using Probe 1 and PIN 9
  ValveRelay relay4(10, 120000, FVDiff, FV3SetPoint, Probe04);                //  Relay 4 FV3 using Probe 4 and PIN 10
  ValveRelay relay5(12, 120000, FridgeDiff, FridgeSetPoint, Probe08);         //  Relay 5 Walk In Cooler using Probe 8 and PIN 12
  
//MasterRelay(int pin, long time)
  MasterRelay relay6(6, 120000);                                              //  Relay 6 Loop Pump using PIN 6

  
void setup(void)
{
 
  // Start up the library
  sensors.begin();

  // start serial port
  Serial.begin(9600);

}

void loop(void)
{
  relay1.Update();
  relay2.Update();
  relay3.Update();
  relay4.Update();
  relay5.Update();
  relay6.Update();
}
  ValveRelay(int pin, long time, long difference, long tempSP, byte Probe)

But, then you call the constructor with:

  ValveRelay relay1(7, 120000, BBTDiff, BBTSetPoint, Probe03);                //  Relay 1 BBT1 using Probe 3 and PIN 7

The type of each argument in the constructor and in the call must match. Probe03's type is not byte:

DeviceAddress Probe03 = {0x28, 0xDE, 0x86, 0x2C, 0x06, 0x00, 0x00, 0x2D};     //Temp Probe Tank1 - BBT1 Wayki

It's type is DeviceAddress.

OK, changed the type to DeviceAddress and now get an error

error: array type 'DeviceAddress' (aka 'uint8_t [8]') is not assignable ProbeNum = Probe;

You can NOT assign one array to another. You need to COPY the elements of one array to the other, using a for loop.

Thanks Paul, that makes sense. I have added the following and it now compiles

   for (int i = 0; i < 8; i++) {
   ProbeNum[i] = Probe[i];
   }

Next step is trying to work up the Web based front end.

Post code in code tags - you've garbled your array indices into italics!!!

Fixed. Thank you Mark