DHT-22 and Beaglebone

Hi everyone!

I’m compiling the files for the dht 22 on the beaglebone with your makefile and i’m getting error on the usleep function (undefined reference). It seems the library is not included.
Does it happened to anyone else?

I think i solved the problem. I compiled with eclipse an worked.
However the results seems a bit strange. I always give error on checksum. When i remove the checksum check, i get temperatures about 80C and humidity of 220%...
I m trying to compare this code with one from arduino i have tested and works fine. I will let you know as soon as i find out.

By the way, anyone got plausible results?

I get the same problem, also working on a solution

I found a solution.
I’ll share with you as soon as i can.

Try this code I uploaded. It’s based on the original posted here with some minor changes and it worked for me.
I’m new to github, so if anyting worng, just tell me.


I’m fairly wet behind the ears when it comes to C++

ran g++ on the beaglebone with your scripts and got the following


g++ Beagle_GPIO.cpp Beagle_GPIO_dht22.cpp

/tmp/ccNXFgIu.o: In function main': Beagle_GPIO_dht22.cpp:(.text+0x21c): undefined reference to clock_gettime’
collect2: error: ld returned 1 exit status

g++ Beagle_GPIO.cpp

/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/…/…/…/crt1.o: In function _start': init.c:(.text+0x34): undefined reference to main’
collect2: error: ld returned 1 exit status


running newest version of angstrom

When compiling you have to add the option -lrt

took me a few days to remember to check this, now it compiles (thank you)

when I run it with a DHT connected it says “Bus error” and exits
when I change the pin or remove the DHT it runs in an endless empty loop

any ideas?

Regarding the Bus error: this can help you:


Why not use the kernel driver for the DHTxx chips?

Care to point me to where that is?

It’s been an elusive issue for me, constructing a greenhouse controller have all my analog pins and relays working, the DHT has proven difficult without a working knowledge of C to fall back on

Starting to understand, the post you reference refers to a bash script that “exports all pins” included in a library you released though I wasn’t able to find the library – suspect I could figure it out with a couple hours of hacking around but would save quite a bit of time with something to reference…

thanks you

This post was a followup to the earlier discussion so it does not
contain all the details repeated from the earlier posts, but explains
what causes the exception.
You can find the script at


thank you, I see what the script is doing but don’t understand where the pin numbers used are coming from?
I can see they are GPIO pins but unsure what the reference is,

ex: for a beaglebone black how would I go find the value for P8_11 if I were to adapt the script to
echo P*_11 > /sys/class/gpio/export # Dummy code

The numbers in the script are not critical. They just have to activate
the GPIO modules. The kernel knows nothing about assignments of the
signals to the pins on the connectors, so using pin names will not
work. Instead you have to use GPIO line numbers. You can find
assignment table in many places on the web. I put together a
spreadsheet with all useful mappings I could find:
This is also a good resource:


thank you, the google doc shows being restricted vs public

your spreadsheet and this site http://adis.ca/post/beaglebone-gpio/
got me far enough to get a workable output, calibration seems rather off but I think that can be adapted

additional reference for anyone hunting in the future

Header Table Reference

calibration… running this on P9_12 or linux pin 60

output from a loop of 20::

Temp = -102.3°C, Hum = 45.8%
Temp = 102.3°C, Hum = 93.2%
Temp = 614.2°C, Hum = 3463.2%
Temp = 51.1°C, Hum = 47.6%
Temp = 102.3°C, Hum = 46.6%
Temp = 23.9°C, Hum = 46.5%
Temp = 25.5°C, Hum = 33.8%
Temp = 25.5°C, Hum = 45%
Temp = 51.1°C, Hum = 46.6%
Temp = 51.1°C, Hum = 46.6%
Temp = 51.1°C, Hum = 46.5%
Temp = 51.1°C, Hum = 46.4%
Temp = 51.1°C, Hum = 195.4%
Temp = 51.1°C, Hum = 46.5%
Temp = 460.7°C, Hum = 3370%
Temp = 51.1°C, Hum = 91.4%
Temp = 102.3°C, Hum = 93.2%
Temp = 25.5°C, Hum = 46.4%
Temp = 102.3°C, Hum = 93.2%
Temp = 102.3°C, Hum = 93%

humidity in this room is near 46.4 – temp is near 16C
any ideas?

My first guess is that you're missing the timings. What language do you use?


mostly python – that is output from a quick bash loop