All Projects → xreef → DHT12_sensor_library

xreef / DHT12_sensor_library

Licence: other
DHT12 complete library (Original DHT clone library with same command and some addiction). I2c and OneWire support, connection schema of Arduino UNO, esp32 and esp8266 with examples.

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to DHT12 sensor library

Filters
An Arduino finite impulse response and infinite impulse response filter library.
Stars: ✭ 36 (+63.64%)
Mutual labels:  arduino-library
SparkFun Micro OLED Arduino Library
Arduino library for the SparkFun Micro OLED - a breakout board for a monochrome, 0.66", 64x48 OLED display.
Stars: ✭ 72 (+227.27%)
Mutual labels:  arduino-library
Adafruit DAP
port of free-DAP to standalone arduino
Stars: ✭ 63 (+186.36%)
Mutual labels:  arduino-library
AndroidCar
Arduino library to control an Android Autonomous Vehicle by Team Pegasus
Stars: ✭ 41 (+86.36%)
Mutual labels:  arduino-library
SevSeg
Seven Segment library for Arduino
Stars: ✭ 75 (+240.91%)
Mutual labels:  arduino-library
modbus-esp8266
Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.
Stars: ✭ 332 (+1409.09%)
Mutual labels:  arduino-library
Adafruit VL6180X
Arduino library for Adafruit VL6180X
Stars: ✭ 29 (+31.82%)
Mutual labels:  arduino-library
BME680
Arduino Library to access the Bosch BME680 - temperature, pressure, humidity and gas sensor
Stars: ✭ 30 (+36.36%)
Mutual labels:  arduino-library
Arduino-Blinkenlight
Non-blocking blinking patterns and smooth fade effects for your LEDs.
Stars: ✭ 26 (+18.18%)
Mutual labels:  arduino-library
FastPID
A fast, integer based PID controller suitable for Arduino.
Stars: ✭ 112 (+409.09%)
Mutual labels:  arduino-library
arduino-mcp23017
Complete support of MCP23017
Stars: ✭ 44 (+100%)
Mutual labels:  arduino-library
arduino-google-maps-api
An Arduino library for communicating with the Google Maps Api
Stars: ✭ 42 (+90.91%)
Mutual labels:  arduino-library
DL1414
Arduino Library for DL1414 type 4 character miniature screen modules.
Stars: ✭ 14 (-36.36%)
Mutual labels:  arduino-library
esp arduino sqlite3 lib
Sqlite3 library for ESP8266 Arduino core
Stars: ✭ 78 (+254.55%)
Mutual labels:  arduino-library
Arduino-Log
Simple application log library. supporting multiple log levels, custom output & flash memory support.
Stars: ✭ 132 (+500%)
Mutual labels:  arduino-library
esp-homekit-arduino-sdk
Arduino wrapper for ESP-IDF HomeKit library
Stars: ✭ 34 (+54.55%)
Mutual labels:  arduino-library
MouseTo
Arduino library for moving mouse pointer to absolute screen coordinates
Stars: ✭ 47 (+113.64%)
Mutual labels:  arduino-library
Seeed Arduino AS5600
The library comes with AS5600. Through this library, we can realize read the angles 、get magnetic from a magnet underneath the sensor.
Stars: ✭ 59 (+168.18%)
Mutual labels:  arduino-library
sqlite micro logger arduino
Fast and Lean Sqlite database logger for Microcontrollers
Stars: ✭ 128 (+481.82%)
Mutual labels:  arduino-library
T-BOTS
Software for controlling and analysing T-Bots (Balancing robots)
Stars: ✭ 21 (-4.55%)
Mutual labels:  arduino-library
Support forum DHT12 English
Forum supporto DHT12 italiano

Additional information and document update here on my site: DHT12 Article.

Here a comparison of the major competitor of the sensor: Temperature humidity sensors comparison (Specifications) Part 1

Temperature humidity sensors comparison (Code configuration) Part 2.

Temperature humidity sensors comparison (Data) Part 3.

This is an Arduino and esp8266 library for the DHT12 series of very low cost temperature/humidity sensors (less than 1$) that work with i2c or one wire connection.

AI read that sometime seems that need calibration, but I have tree of this and get value very similar to DHT22. If you have calibration this problem, open issue on github and I add implementation.

06/04/2022: v1.0.2 Fix package size

Tutorial:

To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder DHT12. Check that the DHT folder contains DHT12.cpp and DHT12.h. Place the DHT library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.

Reef complete DHT12 Humidity & Temperature

This libray try to emulate the behaivor of standard DHT library sensors (and copy a lot of code), and I add the code to manage i2c olso in the same manner.

The method is the same of DHT library sensor, with some adding like dew point function.

To use with i2c (default address and default SDA SCL pin) the constructor is:

DHT12 dht12;

and take the default value for SDA SCL pin. (It's possible to redefine with specified contructor for esp8266, needed for ESP-01). or

DHT12 dht12(uint8_t addressOrPin)

addressOrPin -> address to change address.

To use one wire:

DHT12 dht12(uint8_t addressOrPin, true)

addressOrPin -> pin boolean value is the selection of oneWire or i2c mode.

You can use It with "implicit", "simple read" or "fullread": Implicit, only the first read doing a true read of the sensor, the other read that become in 2secs. interval are the stored value of first read.

		// The read of sensor have 2secs of elapsed time, unless you pass force parameter
		// Read temperature as Celsius (the default)
		float t12 = dht12.readTemperature();
		// Read temperature as Fahrenheit (isFahrenheit = true)
		float f12 = dht12.readTemperature(true);
		// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
		float h12 = dht12.readHumidity();
		
		
		// Compute heat index in Fahrenheit (the default)
		float hif12 = dht12.computeHeatIndex(f12, h12);
		// Compute heat index in Celsius (isFahreheit = false)
		float hic12 = dht12.computeHeatIndex(t12, h12, false);
		// Compute dew point in Fahrenheit (the default)
		float dpf12 = dht12.dewPoint(f12, h12);
		// Compute dew point in Celsius (isFahreheit = false)
		float dpc12 = dht12.dewPoint(t12, h12, false);

Simple read to get a status of read.

		// The read of sensor have 2secs of elapsed time, unless you pass force parameter
		bool chk = dht12.read(); // true read is ok, false read problem

		// Read temperature as Celsius (the default)
		float t12 = dht12.readTemperature();
		// Read temperature as Fahrenheit (isFahrenheit = true)
		float f12 = dht12.readTemperature(true);
		// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
		float h12 = dht12.readHumidity();
		
		// Compute heat index in Fahrenheit (the default)
		float hif12 = dht12.computeHeatIndex(f12, h12);
		// Compute heat index in Celsius (isFahreheit = false)
		float hic12 = dht12.computeHeatIndex(t12, h12, false);
		// Compute dew point in Fahrenheit (the default)
		float dpf12 = dht12.dewPoint(f12, h12);
		// Compute dew point in Celsius (isFahreheit = false)
		float dpc12 = dht12.dewPoint(t12, h12, false);

Full read to get a specified status.

		// The read of sensor have 2secs of elapsed time, unless you pass force parameter
		DHT12::ReadStatus chk = dht12.readStatus();
		Serial.print(F("\nRead sensor: "));
		switch (chk) {
		case DHT12::OK:
			Serial.println(F("OK"));
			break;
		case DHT12::ERROR_CHECKSUM:
			Serial.println(F("Checksum error"));
			break;
		case DHT12::ERROR_TIMEOUT:
			Serial.println(F("Timeout error"));
			break;
		case DHT12::ERROR_TIMEOUT_LOW:
			Serial.println(F("Timeout error on low signal, try put high pullup resistance"));
			break;
		case DHT12::ERROR_TIMEOUT_HIGH:
			Serial.println(F("Timeout error on low signal, try put low pullup resistance"));
			break;
		case DHT12::ERROR_CONNECT:
			Serial.println(F("Connect error"));
			break;
		case DHT12::ERROR_ACK_L:
			Serial.println(F("AckL error"));
			break;
		case DHT12::ERROR_ACK_H:
			Serial.println(F("AckH error"));
			break;
		case DHT12::ERROR_UNKNOWN:
			Serial.println(F("Unknown error DETECTED"));
			break;
		case DHT12::NONE:
			Serial.println(F("No result"));
			break;
		default:
			Serial.println(F("Unknown error"));
			break;
		}

		// Read temperature as Celsius (the default)
		float t12 = dht12.readTemperature();
		// Read temperature as Fahrenheit (isFahrenheit = true)
		float f12 = dht12.readTemperature(true);
		// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
		float h12 = dht12.readHumidity();
		
		// Compute heat index in Fahrenheit (the default)
		float hif12 = dht12.computeHeatIndex(f12, h12);
		// Compute heat index in Celsius (isFahreheit = false)
		float hic12 = dht12.computeHeatIndex(t12, h12, false);
		// Compute dew point in Fahrenheit (the default)
		float dpf12 = dht12.dewPoint(f12, h12);
		// Compute dew point in Celsius (isFahreheit = false)
		float dpc12 = dht12.dewPoint(t12, h12, false);
	

With examples, there are the connection diagram, it's important to use correct pullup resistor.

Thanks to Bobadas, dplasa and adafruit, to share the code in github (where I take some code and ideas).

DHT12 PIN

DHT12 Pin

DHT12 connection schema

ArduinoUNO i2c

ArduinoUNO i2c

ArduinoUNO oneWire

ArduinoUNO oneWire

esp8266 (D1Mini) i2c

esp8266 (D1Mini) i2c

esp8266 (D1Mini) oneWire

esp8266 (D1Mini) oneWire

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].