10.19.2013

Arduino Sensor: DS18B20 1-Wire Temp. Probe

This is the first of many posts which deal with setting up the environmental sensors on our submersible. The first sensor we experimented with was the DS18B20 Waterproof Temperature Sensor. This sensor was extremely easy to setup and therefore a good start for us.

We also decided to choose this temperature sensor because of its diverse capabilities. The DS18B20 is designed on a "1-Wire" data transfer technique. This allows for the easy addition of multiple temperature sensors on one Arduino.

Materials Needed:

  • Arduino UNO (and Arduino software)
  • DS18B20 Waterproof Temperature Sensor
  • 4.7k ohm resistor (***make sure it is 4.7k ohm NOT 4.7 ohm)
  • Wire cutters/strippers and electrical tap
  • Solder

1. Visit our Download Page and download our code + libraries in the folder: Arduino - DS18B20

2. Download the libraries and then move them into Documents---->Arduino---->Libraries (may have to make  the library folder).

3. Acquire a DS18B20. There will be three different wires (white=data, red=power, black=ground)

4. Stip off the waterproof casing from the first 6 inches of the sensor.

5. Cut both the power and data wires about 1 inch from the end of the casing.

6. Solder one side of the resistor onto the data wire and the other side to the power wire.

7. Solder on pins to the end of each sensor wire.

8. A picture of the final product is below (we recommend wrapping the open wire in electrical tape):






and this is a sketch of the setup we used (yellow=data):


and here is a picture of the sensor and our Arduino. 


9. Upload the code to the Arduino. You should see a serial monitor output (baud 9600) like this:



Stay updated for tutorials on how to use Java to display Serial Outputs from the Arduino over the Video Stream. To output the data using Python on the Raspberry Pi check out the Arduino UNO: Serial Outputs to Raspberry Pi. To use the DS18B20 through Java check out this post.

2 comments:

  1. This was an awesome introductory tutorial to 1-wire sensors!! Only one thing needs to be amended. The setup shows the data pin going into PWM pin 10 on the arduino. However, the sketch sets up the OneWire communication on pin 2. By changing the #def used to specify the data pin from "2" to "10", this worked with my sensor/arduino. THANKS!!

    ReplyDelete
    Replies
    1. We're glad it was useful!

      I Just edited the code on our downloads page. Everything is now up-to-date. Thanks for pointing out the discrepancy between the picture and the code.

      Delete