In this lesson, we will show how to use the DS18B20 Temperature Sensor Module with an OSOYOO UNO, we will monitor the output of the DS18B20 Temperature Sensor Module. With this sensor you can get the temperature in your room, car, whatever.
Arduino IDE (version 1.6.4+)
Arduino library: OneWire.h
Arduino library: DallasTemperature.h
The DS18B20 comes in different forms and shapes, so you have plenty of choice when deciding which one works best for you. There are 3 variations available: 8-Pin SO (150 mils), 8-Pin µSOP, and 3-Pin TO-92. If you look at online shop, some friends have packaged the TO-92 version in a waterproof housing so you can use it directly in your fish-tank, water boiler, outside your house or even your freezer, without having to worry about water/moisture shortcutting your electronics (these have 3 wires: Black (GND), Red (Vdd) and white or yellow (Data)).
DS18b20 – Available Packages The DS18B20 is quite versatile. It can be powered through the data line (so called “parasite” mode, which requires only 2 wires versus 3 in normal mode), it operates in a 3.0V to 5.5V range, measures Temperatures from -55°C to +125°C (-67°F to +257°F) with and ±0.5°C Accuracy (from -10°C to +85°C). It converts a temperature in 750ms or less to a up to 12 bits value.
Another cool feature is that you can connect up to 127 of these sensors in parallel, and read each individual temperature. Not sure what I’d do with that, but the ability to combine one or two, for example for the temperature of your fridge and freezer, is a nice option, specially when other pins of your Arduino are being used for other things …
In this lesson, we use the DS18B20 Module to work with the OSOYOO UNO board, we will show more info about this sensor as follow:
The three pins of the Temperature module are
This is DS18B20 digital temperature sensor module for Arduino -55°C~125°C
Digital signal output
Detect ambient air temperature
Compatible with Arduino DIY project
Main chip: DS18B20 temperature sensor
Material: PCB
Resolution adjustment range :9-12
With mounting holes for easy installation, Aperture: 2.5
Temperature measuring range: -55 ~ +125 ℃
Temperature measurement accuracy: 0.5 ℃
Working voltage: DC 5V
Size: 28mm x 12mm x 10mm
The connection scheme is very easier. We have only three pins to connect. Connect the temperature module to the Arduino as shown in the figure.
You’ll need to install the OneWire Library and DallasTemperature Library.
Click this line to get how to install libraries for Arduino IDE.
After installing the needed libraries, upload the following code to your Arduino board.
#include
#include
// Data wire is conntec to the Arduino digital pin 2
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
void setup(void)
{
// Start serial communication for debugging purposes
Serial.begin(9600);
sensors.begin();
}
void loop(void){
sensors.requestTemperatures();
Serial.print(“Celsius temperature: “);
Serial.print(sensors.getTempCByIndex(0));
Serial.print(” – Fahrenheit temperature: “);
Serial.println(sensors.getTempFByIndex(0));
delay(1000);
}
Finally, you should open the Arduino IDE serial monitor at a 9600 baud rate and you’ll see the temperature displayed in both Celsius and Fahrenheit:
DownLoad Url osoyoo.com