Arduino temperature and humidity sensors
Currently I am expanding my sensor network with various environmental sensors. As a base I rely on Arduinos which are connected via KNX and provide data from temperature and humidity sensors.
As a sensor I have decided for a DHT22 temperature sensor. It is cheap, very precise and there is a ready Arduino library so that the query of the temperature and humidity values are relatively simple. You can install the required Arduino library directly from your Android IDE.
Circuit diagram
Arduino | DHT22 |
---|
GND | GND (PIN 4) |
Digital Input (Pin 4) | Data (PIN 2) |
VCC | VCC (PIN 2) |

Accuracy and calibration
As for accuracy. It must always be calibrated. There are no sensors that do not have to be calibrated. Even if they are pre-calibrated, they have to be recalibrated at the latest after 1-2 years as the properties of the components change slightly over time. It should also calibrate as close as possible in the later range of values. As a reference to calibrate the temperature I use the temperature measuring device GTH 175 PT from Greisinger. He “should be” very accurate for this price. The address where you can buy the measuring device can be found in my component list.
I will carry out the humidity via a saturation measurement. Simply fill a glass with saline. Some water on it. Put the bag together with the sensor and seal the air tight. After 24 - 48 hours and a temperature from approximately 20°C, an air humidity of 75.4% should be adjusted.
On average, my deviation from the reference point was between -0.1 ° C and +0.1 ° C, with 13 of 14 sensors. A sensor had a deviation of +0.3 ° C. So no bad values. The humidity was between 0% and 8%.
Power consumption
Mode | Consumption |
---|
Deep Sleep | 1.20mA (3,63mW) |
Measurement (min) | 4.73mA (15.60mW) |
Measurement (max) | 7,50mA (24.75mW) |
Here you can get better results if you:
1. You disable the “Progress” LED in the source code.
2. You disable the power LED. For this, however, one has to cut the cable on the conductor with a cutter knife.
Installation

On the last picture you can see a small slit on the bottom for better air circulation.
Component list
Arduino Sourcecode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
| #include <Arduino.h>
#include <avr/sleep.h>
#include <KnxTpUart.h>
#include <DHT.h>
#define DHTPIN 4
#define DHTTYPE DHT22 //DHT11, DHT21, DHT22
const String knxAddress = "1.1.99";
const String groupTemperatureAddress = "0/7/13";
const String groupHumidityAddress = "0/7/14";
const int interval = 60;
const int ledpin = 13;
DHT dht(DHTPIN, DHTTYPE);
KnxTpUart knx(&Serial, knxAddress);
void setup()
{
Serial.begin(19200);
UCSR0C = UCSR0C | B00100000; // Even Parity
knx.uartReset();
dht.begin();
watchdogOn(); // Enable watchdog timer.
// The following saves some extra power by disabling some peripherals I am not using.
ADCSRA = ADCSRA & B01111111; // Disable ADC, ADEN bit7 to 0
ACSR = B10000000; // Disable analog comparator, ACD bit7 to 1
DIDR0 = DIDR0 | B00111111; // Disable digitale inputbuffer, set analoge input pins 0-5 to 1
}
void loop()
{
// handle temperature
float temperature = dht.readTemperature(); // Read temperature
knx.groupWrite2ByteFloat(groupTemperatureAddress, temperature); // Send knx message
// dht22 datasheet means, we have to wait for 2 seconds between measurements
delay(3000); // wait for 3 seconds
// handle humidity
float humidity = dht.readHumidity(); // Read humidity
knx.groupWrite2ByteFloat(groupHumidityAddress, humidity); // Send knx message
// show Progress for 500 milliseconds
showProgress( 500 );
// randomize loop to avoid flooding knx bus with messages from different devices at the same time
pwrDown( random( 56, 66 ) ); // Shutdown ATmega328 for 56 - 66 seconds;
}
void showProgress(int milliseconds)
{
digitalWrite(ledpin, HIGH); // Enable LED
delay( milliseconds );
digitalWrite(ledpin, LOW); // Disable LED
}
void pwrDown(int seconds)
{
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Set deepest sleep mode PWR_DOWN
for(int i=0; i < seconds; i++)
{
sleep_enable(); // Enable sleep mode
sleep_mode(); // Start sleep mode
sleep_disable(); // Disable sleep mode
}
}
void watchdogOn()
{
MCUSR = MCUSR & B11110111; // Disable reset flag, WDRF bit3 of MCUSR.
WDTCSR = WDTCSR | B00011000; // Set bit 3+4 to be able to set prescaler later
WDTCSR = B00000110; // Set watchdog prescaler to 128K > is round about 1 second
WDTCSR = WDTCSR | B01000000; // Enable watchdog interrupt
MCUSR = MCUSR & B11110111;
}
ISR(WDT_vect)
{
//sleepcounter ++; // count sleepcycles
}
|
You like this page?
You can support me by visiting my advertising partners. Just click on the banner below.