DHT21 / AM2301 sensor not measuring humidity

As per the datasheet, the DHT21 timings are shorter with 3.3V and longer with 5V. I switched it from 5V to 3.3V and now it reads the humidity properly. It seems that while in the Arduino you have it at 5V, the software side/routines for the banana pi and raspberry are assuming it is connected at 3.3V.

From the software mentioned in the question, the fastest seems to be lol_dht22. I am using a slightly changed version of it (by myself), that creates files in /var/run aprox every 9-10 seconds to feed rpimonitor.

temp

As @ChrisStratton correctly says, this method of bit banging/polling is highly prone to errors, especially when running in user land.

The simple protocol checksum implemented by the DHT21 is clearly not strong enough to weed out most of the errors/spikes (and there are many). I had to add simple software correction routines to ignore out of place values, and even then there are spikes.

The code for reading the DHT11/DHT21/DHT22 sensors is at my github https://github.com/ruyrybeyro/rdht .

graph

I was also in doubt wether I would need to touch the R1 device tree configuration, as I did to configure the 1Wire protocol with another temperature sensor. It was not needed.

As an additional note, care must be taken when following blindly schematics online. While the Arduino bus operates at +5V, raspberry and compatibles operate at +3V; while apparently it is not the case of the DHT21 (I stress apparently as the R1 bus is more resilient than the rpi bus), feeding at random devices/sensors from +5V connected to an rpi bus can be potentially harmful to your SBC.

The measured temperature(s) also seems consistently to be higher +2 Celsius than what they should be, and these temperature inconsistencies are reported by many others using DHT21 devices.

Tags:

Gpio

Sensor

Arm7