Published: 27.08.2018 Copyright by Joy-IT 4
Combi Sensor
This sensor does not output its measurement result as an analog signal on an output pin, but
communicates this digitally coded. There are several ways to control this sensor module. The
Adafruit_DHT Library, published by Adafruit under the following link under the OpenSource MIT license,
has proven to be parcularly accessible.
The example below uses this library - we recommend downloading it from Github, unpacking it and
copying it to the Arduino Library folder located by default at
(C:\User\[Username]\Documents\Arduino\libraries) to make it available for this code example and
subsequent projects. Alternavely, this is also included in the download package.
You can download the code example here or copy and paste the following secons:
3. CODE EXAMPLE ARDUINO
// Adafruit_DHT Library is inserted
#include "DHT.h"
// Here the respective input pin can be declared
#define DHTPIN 2
// The sensor is initialized
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
Serial.println("KY-015 Test - Temperatur und Luftfeuchtigkeits-Test:");
// Measurement is started
dht.begin();
}
// main loop
// The program starts the measurement and reads out the measured values
// A pause of 2 seconds is inserted between the measurements,
// so that a new measurement can be recorded during the next run.
void loop() {
// Zwei Sekunden Pause zwischen den Messungen
delay(2000);
// Two seconds pause between measurements
float h = dht.readHumidity();
// Temperature is measured
float t = dht.readTemperature();