Jump to content
  • 0
Sign in to follow this  
Solar Dude

Multiple DS18B20 Sensors


Hello All,


I am fairly new to Arduino and I am trying to set up a program to control 3- Hydronic Circulators for a solar water heating project using 3-DS18B20 Temperature Sensors.

My Arduino Uno gets angry when I try to Verify my sketch.  I am trying to use multiple sensors to control multiple circulators and I'm not sure how to define each one.  I provided my sketch just to help understand what I'm doing.  I started this sketch based on the DS18B Tutorial..


Thanks in advance!!


#include <DallasTemperature.h>

#include <OneWire.h>

int Solar_Panel_Circulator = 8;
int Floor_Heat_Circulator = 9;
int DHW_Circulator = 10;

int temp_sensor_Solar = 2;
int temp_sensor_Floor = 3;
int temp_sensor_DHW = 4;
int Alarm = 5;

int lowerLimit_Solar = 150;
int higherLimit_Solar = 200;
int lowerLimit_Floor_Heat = 80;
int higherLimit_Floor_Heat = 85;
int lowerLimit_DHW = 50;
int higherLimit_DHW = 150;

OneWire oneWirePin(temp_sensor_Solar);
OneWire oneWirePin(temp_sensor_Floor);
OneWire oneWirePin(temp_sensor_DHW);
DallasTemperature sensors(&oneWirePin);

void setup(void){
  //The Circulators & Alarm as outputs

void loop(){
  Serial.print("Requesting Temperatures from sensors: ");
  temperature1 = sensors.getTempFByIndex(0);
  temperature2 = sensors.getTempFByIndex(1);
  temperature3 = sensors.getTempFByIndex(2);

  digitalWrite(Solar_Panel_Circulator, LOW);
  digitalWrite(Floor_Heat_Circulator, LOW);
  digitalWrite(temp_sensor_DHW, LOW);
  digitalWrite(Alarm, LOW);
  Serial.print("Temperature is ");

  if(temperature1 <= lowerLimit_Solar){
    Serial.println(", Solar Circulator is Activated");
    digitalWrite(Solar_Panel_Circulator, HIGH);

             if(temperature2 >= higherLimit_Solar)
      Serial.println(", Alarm is Activated");
      digitalWrite(Alarm, HIGH);

  if(temperature2 <= lowerLimit_Floor_Heat){
    Serial.println(", Floor Heat Circulator is Activated");
    digitalWrite(Floor_Heat_Circulator, HIGH);

         if(temperature2 >= higherLimit_Floor_Heat)
      Serial.println(", Floor Heat Circulator is De-activated");
      digitalWrite(Floor_Heat_Circulator, LOW);

 if(temperature3 <= lowerLimit_DHW){
    Serial.println(", DHW Circulator is Activated");
    digitalWrite(DHW_Circulator, HIGH);

          if(temperature3 >= higherLimit_DHW)
      Serial.println(", DHW Circulator is De-activated");
      digitalWrite(DHW_Circulator, LOW);





OneWire Error.JPG

Share this post

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I'm making progress, but now I'm having difficulties creating multiple Dallas Temperature sensor objects.

I tested all of my sensors by plugging them into pin 2 and they all work.  I just don't know how to  pass the OneWire reference into the class for multiple Dallas Temperature sensor objects.



redefinition of DTS.JPG

Share this post

Link to post
Share on other sites
  • 0

Hi Solar Dude,

If you go down the route of each temperature sensor has its own pin then I would reference it something like this. Each have their own unique DallasTemperature object. 

OneWire oneWirePin(temp_sensor_Solar);
DallasTemperature sensor_1(&oneWirePin);

OneWire oneWirePin2(temp_sensor_Floor);
DallasTemperature sensor_2(&oneWirePin2);

OneWire oneWirePin3(temp_sensor_DHW);
DallasTemperature sensor_3(&oneWirePin3);

If you want them all connected to the same pin then you need to reference each sensor by its physical address. (https://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

DeviceAddress temp_sensor_Solar = { 0x28, 0x8A, 0xB1, 0x40, 0x04, 0x00, 0x00, 0xC7 }; 

Let me know if that helps.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this