Sunday, February 19, 2017

Library for reading internal temperature sensor on AVR microcontrollers

A few AVR microcontrollers have internal on-chip temperature sensors. The sensor is a diode that produces a temperature dependent voltage. This voltage is measured with the ADC. According to Atmel the typical accuracy of temperature measurements over the full temperature range of the AVR is ±10°C but after calibration the accuracy can be ±1°C over 20°C to 55°C using one-point calibration.

Library for reading internal temperature sensor on AVR microcontrollers

The calibration can be done using one-point calibration and compensation or two-point calibration and compensation. One-point calibration is the easiest - subtract the ambient

Friday, February 10, 2017

DHT11 Library Temperature and Humidity Sensor

 Interfacing DHT11 sensor with an AVR Microcontroller

This post describes how to interface a DHT11 temperature and humidity sensor with an AVR microcontroller and how to read and display the data on an LCD using the DHT11 library.

DTH11 is a low cost hobby digital sensor used to measure temperature and relative humidity. Digital means that the sensor incorporates a 8 bit microcontroller inside that takes care of ADC measurements for you. With an analog sensor you would have to set up an ADC and measure the sensor resistance directly and interpret the data. The DHT11 sensor uses a proprietary 1-wire protocol which is described down bellow.
The DHT11 sensor comes in a single row 4-pin package, breadboard friendly, and operates from 3.5 to 5.5V. It can measure temperature from 0-50 °C with an accuracy of ±2°C and relative humidity ranging from 20-95% with an accuracy of  ±5%. During measurement it draws 0.3mA and in standby 60uA.
The sampling rate is 0.5 Hz in some datasheets and 1 Hz on others; this means it is not recommended to read the sensor more than once every second or every two seconds. The recommended sample rate is 5 seconds to prevent the display changing to often.

DHT11 pinout

DHT11 Pinout