Using multiple DS18B20 sensors with SD logger sheild

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
seneca
 
Posts: 26
Joined: Wed Feb 23, 2011 12:25 pm

Using multiple DS18B20 sensors with SD logger sheild

Post by seneca »

I'm brand new to Arduino, but I would like to use two DS18B20 sensors with the SD logger shield. How would I hook them up to the shield? I klnow they are digital instead of the analog ones that come with the shield. How would the code change?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Using multiple DS18B20 sensors with SD logger sheild

Post by adafruit_support_rick »

You can connect the sensors to the shield using the prototyping area. Both sensors share the same data pin. You need a single 4.7k resistor as a pullup, connected between the data pin and 5V.


There is a Dallas Temperature Control Library for arduino available here:
http://www.milesburton.com/?title=Dalla ... ol_Library

That library requires the general=purpose arduino One Wire library, available here:
http://www.pjrc.com/teensy/td_libs_OneWire.html

User avatar
seneca
 
Posts: 26
Joined: Wed Feb 23, 2011 12:25 pm

Re: Using multiple DS18B20 sensors with SD logger sheild

Post by seneca »

So how would the code in the sketch need to be modified now that I am using a digital sensor instead of the analog sensor?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Using multiple DS18B20 sensors with SD logger sheild

Post by adafruit_support_rick »

Well, if you're looking at the sample code from the tutorial, this section of code determines the temperature in degrees C:

Code: Select all

  tempReading = analogRead(tempPin);  
  
  Serial.print("Temp reading = ");
  Serial.print(tempReading);     // the raw analog reading
  
  // converting that reading to voltage, which is based off the reference voltage
  float voltage = tempReading * aref_voltage / 1024; 
 
  // print out the voltage
  Serial.print(" - ");
  Serial.print(voltage); Serial.println(" volts");
 
  // now print out the temperature
  float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((volatge - 500mV) times 100)
  Serial.print(temperatureC); Serial.println(" degrees C");
With the Dallas Temperature Control Library, you would replace that section of code with this:

Code: Select all

  float temperatureC = sensors.getTempCByIndex(0)); //  0 refers to the first DS18B20 on the wire
  Serial.print(temperatureC); Serial.println(" degrees C");
The example code shows how to set up the library and create the "sensors" object

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”