Arduino sensors

Currently I extend my sensor network. As a base I rely on Arduinos which are connected via KNX.

As a sensor I have decided for a DHT22. 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.

Connect the DHT22 sensor to the Arduino Mini Pro Board

Digital Input (Pin 4)
Data (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 have a GTH 175 PT from Greisinger. He "should be" very accurate for this price.

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

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.


On the last picture you can see a small slit on the bottom for better air circulation.

Arduino Sourcecode

#include <Arduino.h>

#include <avr/sleep.h>
#include <KnxTpUart.h>
#include "DHT.h"

#define DHTPIN 4     
#define DHTTYPE DHT22 //DHT11, DHT21, DHT22

// Room: Livingroom, KNX address: 1.1.49, GroupTemperature: 0/7/1, GroupHumidity: 0/7/2
const String deviceAddress           = "1.1.49";
const String groupTemperatureAddress = "0/7/1";
const String groupHumidityAddress    = "0/7/2";

const int interval = 60;
const int ledpin = 13;


KnxTpUart knx(&Serial, deviceAddress);

void setup()
  UCSR0C = UCSR0C | B00100000; // Even Parity

  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()
  float temperature = dht.readTemperature(); // Read temperature
  knx.groupWrite2ByteFloat(groupTemperatureAddress, temperature);


  float humidity = dht.readHumidity(); // Read humidity
  knx.groupWrite2ByteFloat(groupHumidityAddress, humidity);

  digitalWrite(ledpin, HIGH); // Set LED State to visualize progess  
  digitalWrite(ledpin, LOW);

  pwrDown(interval - 6); // Shutdown ATmega328 for "interval" seconds;

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;

  //sleepcounter ++; // count sleepcycles