September 30, 2018

Please reload

Recent Posts

New! SNAR11 RC TANK ROBOT ARM INSTALL GUIDE

March 17, 2018

1/6
Please reload

Featured Posts

how to test Digital temperature sensor DS18B20 with arduino uno

April 29, 2020

There are many types of temperature sensors, which are divided into contact type and non-contact type according to the measurement method, thermal resistance and thermocouple according to the sensor material, and analog and digital according to the working principle. The previous article introduced the analog temperature sensor LM35, and this article introduced the use of the digital temperature sensor DS18B20.

Introduction to DS18B20
DS18B20 is a commonly used digital temperature sensor, which uses an integrated chip and uses a single bus technology to effectively reduce external interference and improve measurement accuracy. The output is a digital signal, and the wiring is very convenient. It can be applied to different occasions in different ways, such as pipe type, screw type, magnet adsorption type, and stainless steel package type.

 

 

 

 

Main feature:

Use a single bus interface. Only one data line is needed for bidirectional communication.


Wide measuring range and high accuracy. The measurement range is -55 ℃ — + 125 ℃, and the accuracy is ± 0.5 ℃ in the range of -10— + 85 ℃.
Multi-point networking function. Multiple DS18B20 can be connected in parallel on the only three lines to achieve multi-point temperature measurement.


Flexible power supply. Power can be obtained from the data line through internal parasitic circuits.


The measurement parameters are configurable. The measurement resolution of DS18B20 can be set to 9-12 bits through the program.
Power-off protection function. It contains EEPROM, after the system is powered off, it can still save the resolution and alarm temperature settings.

 

 

  1. Experimental materials
    Uno R3 development board
    Supporting USB data cable
    Breadboard and supporting cable
    DS18B20
    10K in-line resistor

  2. Install the library
    Two libraries are used in this experiment, namely “OneWire” and “DallasTemperature”, the former is a single bus library, and the latter is a library packaged for Dallas temperature sensors based on the former.

Click “Project”-“Load Library”-“Manage Library” in the IDE, find “OneWire”, select the latest version to install. The latest version is currently 2.3.4.

 

 

 

 

 

 

 

 

 

 

 

 

  1. Experimental steps

  2. Build the circuit diagram according to the schematic diagram.
    The line connection is very simple. The VCC, DQ, and GND of the DS18B20 are connected to the 5V, 2, and GND of the development board, respectively. A 10K resistor is connected to VCC at one end, and DQ is connected at the other end, and the pull-up resistor is used to improve the drive capability of the I / O port.

The experimental schematic diagram is shown below:

 code:

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

// 数据输出脚接开发板数字引脚2
#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup(void)
{
  Serial.begin(9600);
  sensors.begin();
}

void loop(void)

  sensors.requestTemperatures(); // 发送命令获取温度
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println(sensors.getTempCByIndex(0)); 
  delay(500); 
}

 

3.Connect the development board, set the corresponding port number and development board type, and download the program

 

 

Experimental phenomena
Open the serial monitor, the baud rate is set to 9600, the serial port will print the temperature value read cyclically

 

 

 

Tags:

Share on Facebook
Share on Twitter
Please reload

Follow Us
Please reload

Search By Tags
Please reload

Archive
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square

© 2012-2018, SINONING 

SINONING blog

  • Grey Facebook Icon
  • Grey Twitter Icon
  • Grey Instagram Icon
This site was designed with the
.com
website builder. Create your website today.
Start Now