Go Down

Topic: Multiple DS18B20 Temperature Sensors on one bus (Read 83476 times) previous topic - next topic

Trickyrick

I have 3 of this working thanks to your tutorial.  Is there a humidity sensor that will work on the same pin as these temp sensors or does it have to go on its own pin.

robtillaart

you should check the DHT22 if you want to have humidity and temperature.
The temp is not as precise as the DS18B20,

if you want very good temp sensor + humidity you should check for the DHT33
only seen in a shop in Switzerland.

- http://shop.boxtec.ch/temperature-c-39_71.html -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Trickyrick

Thanks I have ordered a dht11.  I dont really want it for temp only humidity.  Can I assume that both the 11 and the 22 will go on the same buss as the ds18b20

robtillaart

no the DHT11 needs a separate pin as it uses a really different protocol.

check - http://arduino.cc/playground/Main/DHTLib -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

celamb89

Worked like a charm!

Code: [Select]

// ************************************************
// Variables for 3 DS18B20 sensors
// ************************************************
OneWire ds_1(11);     //sensor 1 on pin 11
OneWire ds_2(12);  //sensor 2 on pin 12
OneWire ds_3(13);  //sensor 3 on pin 13

//Then search every pin for its address and request temps
DallasTemperature sensor_1(&ds_1);
DallasTemperature sensor_2(&ds_2);
DallasTemperature sensor_3(&ds_3);

float temp_1; //HLT
float temp_2; //Mash
float temp_3; //Boil

// ************************************************
// Temperature check for 3 sensors
// ************************************************
void temp_check() {
 
  sensor_1.requestTemperatures();
  sensor_2.requestTemperatures();
  sensor_3.requestTemperatures();
 
  temp_1 = sensor_1.getTempCByIndex(0); //HLT
  temp_2 = sensor_2.getTempCByIndex(0); //Mash
  temp_3 = sensor_3.getTempCByIndex(0); //Boil
 
  lcd_1.setCursor(0,0);
  lcd_1.print("Temperatures [C]");
  lcd_1.setCursor(0,1);
  lcd_1.print("HLT  Temp: ");
  lcd_1.print(temp_1);
  lcd_1.setCursor(0,2);
  lcd_1.print("Mash Temp: ");
  lcd_1.print(temp_2);
  lcd_1.setCursor(0,3);
  lcd_1.print("Boil Temp: ");
  lcd_1.print(temp_3);

}

void setup() {

  Serial.begin(9600);
 
  sensor_1.begin(); //initialize sensors
  sensor_2.begin();
  sensor_3.begin();
}

Rudraksha

Hi Everyone,

There is a lot around the web on this subject, but I have recently pulled a lot together and written clear example code. You can see the updated page on the http://ArduinoInfo.Info WIKI here:
http://arduino-info.wikispaces.com/Brick-Temperature-DS18B20

I have a utility sketch that you can use to get the internal serial number (Device Address) on DS18B20's that you have.  Then you can use those addresses in the code for multiple temperature sensors on one wire. This is important so you can know "which sensor is which" in a bus environment. You can see that info here:
http://arduino-info.wikispaces.com/Brick-Temperature-DS18B20#mult

I will have an example running in a day or two which displays and graphs inside and outside temperatures on KSduino.org
Hey,
Could you kindly help me to combine and develop a hybrid sketch that will contain both the utility sketch for internal serial number(Device Address) as well as sketch for reading the temperature from the above device addresses. I tried the above project but have been unsuccessful every time since there seems to b a problem in converting byte array into unsigned long integer (unint8_t). Recently, i tried converting it into a string and then to a unint8_t but didn't succeed.

Here's my code:

Code: [Select]

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

// Setup a oneWire instance to communicate with any OneWire devices
OneWire  ds(2);  // Data wire is plugged into pin 2 on the Arduino
DallasTemperature sensors(&ds);   // Pass our oneWire reference to Dallas Temperature.
DeviceAddress device;   // Assign the addresses of your 1-Wire temp sensors.
const char* newAddy;

void setup(void)
{
  Serial.begin(9600);    // start serial port to show results
  sensors.begin();     // Initialize the Temperature measurement library
  sensors.setResolution(device, 10);     // set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)zzz
  TemperatureAddress();
}

void TemperatureAddress(void) {
  int i;
  byte addr[8];
  int addx[8];
 
 
  Serial.println("Looking for 1-Wire devices...\n\r");
  while(ds.search(addr)) {
    String myString  = "";
     Serial.print("Address: ");                           //0x28, 0xFF, 0x1C, 0xB4, 0x54, 0x15, 0x03, 0x9E
                                                            //0x28, 0xFF, 0x4B, 0x85, 0x54, 0x15, 0x03, 0x9D

    for( i = 0; i < 8; i++) {
      Serial.print("0x");
      myString+="0x";
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i]);
      addx[i]=addr[i];
      {
       
       
        String dig = "";
        int temp = addx[i] % 16;
        if (temp>9)
        {
          switch(temp)
          {
            case 10:
                dig+='A';
                break;
               
            case 11:
                dig+='B';
                break;
               
             case 12:
                dig+='C';
                break;
               
            case 13:
                dig+='D';
                break;
               
            case 14:
                dig+='E';
                break;

            case 15:
                dig+='F';
                break;
            }
        }
        else
        {
          dig+=temp;
          }

      temp=addx[i]/16;
        if (temp>9)
        {
          switch(temp)
          {
            case 10:
                myString+='A';
                break;
               
            case 11:
                myString+='B';
                break;
               
             case 12:
               myString+='C';
                break;
               
            case 13:
               myString+='D';
                break;
               
            case 14:
               myString+='E';
                break;

            case 15:
               myString+='F';
                break;
            }
        }
        else
        {
         myString+=temp;
          }     
       
        myString+=dig;
       
        }
      if (i < 7) {
        Serial.print(", ");
        myString+=", ";
      }
    }
    Serial.println();

    Serial.println(myString);
   
   
    const char* newAddy = myString.c_str(); 
           DeviceAddress device =  { strtoul(newAddy, 0 ,16) };
   
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
        return;
    }

    sensors.requestTemperaturesByAddress(device);
           float tempC = sensors.getTempC(device);
           Serial.print("Temperature: ");
            if (tempC == -127.00)
   {
   Serial.println("Error getting temperature  ");
   }
   else
   {
    Serial.print("temperature in ");
   Serial.print("C: ");
  Serial.print(tempC);
   Serial.print(" F: ");
   Serial.println(DallasTemperature::toFahrenheit(tempC));
   }
  }
  Serial.println();
  Serial.print("That's it.");
  ds.reset_search();
  return;
 }
   





void loop(void) {
 
  }


Any help is appreciated

Rudraksha

Nick_Pyner

You could start by seriously questioning why you would want to do that. You can use the sensors by the "by index" method which absolves you from finding the addresses, or you can find the addresses in advance and then include them in your programme. I would never use the former, but either method has to be a lot better than what you are doing.

http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html


aldozan

Hi everybody,
I have a 1-wire network with 10 ds18b20 sensors for remote temperature monitoring of a thermal system. I use an Arduino Mega and a network shield for remote access. Results are displayed on an HD44780U LCD and on web browser. Everything has been working fine for the last two years.

Recently I decided to improve the system replacing the two line HD44780U LCD with a ILI9341 TFT screen, and I am experiencing an issue. The system works fine when I am in the test environment, with the sensors mounted on a breadboard, but when I move to the real environment the screen starts flickering and soon it gets dark.

The sensors network works fine with the HD44780U LCD version of the system. The maximum lenght of the bus is 20mt.
My guessing is that the bus drains too much power and the TFT screen does not work correctly because of that.

Has anybody got the same problem? any suggestion on how to fix it?

Thanks for your help

yv1hx

Hi everybody,
I have a 1-wire network with 10 ds18b20 sensors for remote temperature monitoring of a thermal system. I use an Arduino Mega and a network shield for remote access. Results are displayed on an HD44780U LCD and on web browser. Everything has been working fine for the last two years.

Recently I decided to improve the system replacing the two line HD44780U LCD with a ILI9341 TFT screen, and I am experiencing an issue. The system works fine when I am in the test environment, with the sensors mounted on a breadboard, but when I move to the real environment the screen starts flickering and soon it gets dark.

The sensors network works fine with the HD44780U LCD version of the system. The maximum lenght of the bus is 20mt.
My guessing is that the bus drains too much power and the TFT screen does not work correctly because of that.

Has anybody got the same problem? any suggestion on how to fix it?

Thanks for your help

Have you checked your power supply while the TFT is running?

Probably your PS is aging, what about replacing it temporarily with another and check the circuit behavior?
Marco-Luis
Researcher, Telecom Specialist at www.meteoven.org

albien27

hi everyone

ı have one question for u... thank u for interest...
ı am making multiple DS18B20 temperature sensör devices so ı want to measure 10 temperature sensör and I want to choose the highest one how can ı make this?
thank u...

aldozan

What do you mean with "the highest one"? Temperture or sensor ID?

in any case the solution is to compare each data in the row with the others, and take out the highest. With temperature is simple, with Sens ID a bit more complex but you can do it anyway!

BenBoyRuben

Hi. I'm connecting two sets of multiple DS18B20 into one arduino Uno. So in my code how should i include them. I want the readings of a set of multiple DS18B20 separately and another set in separate.   

aldozan

You should have two different instances of the OneWire class on two different pins.

Have a look at the post from robtillaart Jun 07, 2014 just in this thread page 1.


Go Up