Zuno DHT Library
An Arduino library for the DHT series of low-cost temperature/humidity sensors. The library can work with any pin For more infomation about pins of Z-Uno here Note that DHT uses shared peripherals: TIMER0 или TIMER1.The library will try to use TIMER 0, if it is busy then it will try to use TIMER1
Peripherals can be used by only one biocell at a time.
Also, during the polling of the sensor, one DMA channel is used for a short time. Polling the sensor more than once every 2 seconds is useless.
#include "Arduino.h"
#include "ZUNO_DHT.h"
#define MY_SERIAL Serial0
DHT dht22_sensor(9, DHT22);
/* the setup function runs once, when you press reset or power the board */
void setup() {
MY_SERIAL.begin(115200);
dht22_sensor.begin();
MY_SERIAL.println("\n **** Sketch is starting... ****\n");
}
/* the loop function runs over and over again forever */
void loop() {
byte result;
byte i;
byte raw_data[5];
MY_SERIAL.print("Millis:");
MY_SERIAL.println(millis());
result = dht22_sensor.read(true);
if (result == ZunoErrorOk) {
MY_SERIAL.print("DHT read result:");
MY_SERIAL.println(result);
MY_SERIAL.print("Raw data: { ");
dht22_sensor.getRawData(raw_data);
for(i=0;i<5;i++) {
MY_SERIAL.print(raw_data[i], HEX);
MY_SERIAL.print(" ");
}
MY_SERIAL.println("} ");
MY_SERIAL.print("Temperature:");
MY_SERIAL.println(dht22_sensor.readTemperature());
MY_SERIAL.print("Humidity:");
MY_SERIAL.println(dht22_sensor.readHumidity());
}
else
MY_SERIAL.println("Error reading temperature!");
delay(2000);
}