Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Does anyone know why I always get at gipo4 20ms low pulse, regardless of whether I have a 100us delay or 500000us? Wathewer i do it does not effect any change? Thank you!
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
In the C code in file dht.c the following snippet occurs:
I do not understand the line nanosleep(1) here, because according to the manual page for nanosleep() it needs two parameters:
What is the effect of calling nanosleep(1)?
Code: Select all
// read data!
for (int i=0; i< MAXTIMINGS; i++) {
counter = 0;
while ( bcm2835_gpio_lev(pin) == laststate) {
counter++;
nanosleep(1); // overclocking might change this?
//delay(1);
if (counter == 100)
break;
}
Code: Select all
Name
nanosleep - high resolution sleep (REALTIME)
Synopsis
#include <time.h>
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
New to pi. Trying to get an am2302 (dht22 w/resistor) sensor working and just getting all zeros with the C code from adafruit. Tried compiling my own version with 500ms sleep and it runs (after compiling with errors), but still returns all zeros.
Would someone be willing to share their compiled working C prog?
Would someone be willing to share their compiled working C prog?
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
I'm no expert and I'm dusting off my C programming skills from over 20 years ago. I have an AM2302 bought from eBay. I got it working by changing the following code block from the orginal ...
So just changed "usleep(500000)" between setting the PIN HIGH and LOW. After compiling the code (running make) it returns good values for me 99% of the time.
Code: Select all
// Set GPIO pin to output
bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_write(pin, HIGH);
usleep(500000);
bcm2835_gpio_write(pin, LOW);
usleep(20000);
bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_INPT);
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
@Buckers
I changed the sleep time as you suggested an it got big improvement

I changed the sleep time as you suggested an it got big improvement


Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
I had no problems with the downloaded code from the adafruit website but my humidity is always reading very low - 37% say, when a fine-offset head unit sitting beside it is telling me 57%. Anyone else checked the validity of their data coming from the DTH11?
http://goatstownweather.eu.pn
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Actually, perhaps it's right! I just breathed onto the sensor and the humidity went up. A few minutes later, it's back down to 38-39% again, from 65% when I breathed on it. Also, a bit of googling suggests that 30-50 is a normal indoor percentage, so it's spot on there! Happy days!kenmc wrote:I had no problems with the downloaded code from the adafruit website but my humidity is always reading very low - 37% say, when a fine-offset head unit sitting beside it is telling me 57%. Anyone else checked the validity of their data coming from the DTH11?
http://goatstownweather.eu.pn
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Thanks to Buckers, now my temperature and humidity reading also works for me.
Can anyone help me with atached error?
Which connection is intendet? If I do not specifie right user name and pass, or spreadsheet key i'll get an error that something is wrong. So i supose that connection to spreadsheet is established.
Thanks in advance!
Can anyone help me with atached error?
Which connection is intendet? If I do not specifie right user name and pass, or spreadsheet key i'll get an error that something is wrong. So i supose that connection to spreadsheet is established.
Thanks in advance!
- Attachments
-
- pierror.jpg (39.99 KiB) Viewed 6959 times
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Not sure what you mean. You did specify login and password in Adafruit_DHT_googledocs.ex.py ?
If that's true there could be some problem with logging in to Google. I'm not sure it that's the case but checking your Google account if there isn't any security message about suspicious login.
And maybe first of all check if you have connections to the Internet (i.e. ping google.com)
If that's true there could be some problem with logging in to Google. I'm not sure it that's the case but checking your Google account if there isn't any security message about suspicious login.
And maybe first of all check if you have connections to the Internet (i.e. ping google.com)
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
If i don't specify right username and password I'll get:
"Unable to log in. Check your email address/password"
If i don't specify existing spreadsheet I'll get:
"Unable to open the spreadsheet. Check your filename: %s"
After that (without getting this errors) when the program appends the data to spreadsheet i got an error:
"Unable to append data. Check your connection?"
So if the program recognize the right password and username, and even an existing spreadsheet it must be connected to account?
"Unable to log in. Check your email address/password"
If i don't specify existing spreadsheet I'll get:
"Unable to open the spreadsheet. Check your filename: %s"
After that (without getting this errors) when the program appends the data to spreadsheet i got an error:
"Unable to append data. Check your connection?"
So if the program recognize the right password and username, and even an existing spreadsheet it must be connected to account?
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
A bit leftfield, but are you set up like this :discovery wrote:If i don't specify right username and password I'll get:
"Unable to log in. Check your email address/password"
If i don't specify existing spreadsheet I'll get:
"Unable to open the spreadsheet. Check your filename: %s"
After that (without getting this errors) when the program appends the data to spreadsheet i got an error:
"Unable to append data. Check your connection?"
So if the program recognize the right password and username, and even an existing spreadsheet it must be connected to account?
Pi <-- cable --> Laptop <--wifi---> Internet?
If so, I had the same problem, I managed to get 2 extra, empty rows created in my spreadsheet, but no data in it. Same "couldn't append" lark. I didn't persue it as I'm not looking to use this as a solution. Maybe there's some sort of issue with the connection through the laptop.... anyway, worth a shot...
http://goatstownweather.eu.pn
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
No, my setup is:
Pi <---cable---> getaway/modem (internet)
So directly to the internet.
Pi <---cable---> getaway/modem (internet)
So directly to the internet.
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
After my SD Card broke down I installed everything from scratch (latest Wheezy) . Now I get more or less right temperature but the humidity is 99%.
Maybe there where some changes that affected timings?
Or maybe my AM2302 got broken?
Maybe there where some changes that affected timings?
Or maybe my AM2302 got broken?
-
- Posts: 10
- Joined: Thu Oct 18, 2012 1:12 am
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Using a DHT22
I got it to work just the way it was given.
I want to turn stuff on and off according to temperature, so I put the code in an infinite loop.
It works great for 3-8 times and then the application just dies.
In debuging I figured out it is somehere in the "read data!" for loop section, but I can't figure out exactly where or why.
Here is my loop if someone else wants to see if it dies on them.
while (1)
{
printf("Temp Check\n");
readDHT(type, dhtpin);
delay(5000);
}
I got it to work just the way it was given.
I want to turn stuff on and off according to temperature, so I put the code in an infinite loop.
It works great for 3-8 times and then the application just dies.
In debuging I figured out it is somehere in the "read data!" for loop section, but I can't figure out exactly where or why.
Here is my loop if someone else wants to see if it dies on them.
while (1)
{
printf("Temp Check\n");
readDHT(type, dhtpin);
delay(5000);
}
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Same happened to me. In routine readDHT look for the line:
bits[bitidx++] = counter
and comment it out or delete it. Recompile. This statement was causing a buffer overflow.
bits[bitidx++] = counter
and comment it out or delete it. Recompile. This statement was causing a buffer overflow.
runfastman wrote:Using a DHT22
I got it to work just the way it was given.
I want to turn stuff on and off according to temperature, so I put the code in an infinite loop.
It works great for 3-8 times and then the application just dies.
In debuging I figured out it is somehere in the "read data!" for loop section, but I can't figure out exactly where or why.
Here is my loop if someone else wants to see if it dies on them.
while (1)
{
printf("Temp Check\n");
readDHT(type, dhtpin);
delay(5000);
}
-
- Posts: 128
- Joined: Sun Dec 23, 2012 9:44 pm
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Folks
The code on the Adafruit GIT download source appears to have been modified as per the earlier trials on timing - I had no need to change anything and it works well on a DHT11 - well, it reads and logs on GDocs, I have some suspicion about the humidity readings though from this rather cheap sensor.
Next step is to move data to COSM...
The code on the Adafruit GIT download source appears to have been modified as per the earlier trials on timing - I had no need to change anything and it works well on a DHT11 - well, it reads and logs on GDocs, I have some suspicion about the humidity readings though from this rather cheap sensor.
Next step is to move data to COSM...
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
I've another problem.
Sensor works fine for me about 24 hours and then simply hangs and only power cycle can resolve the problem.
"One capacitor valued 100nF can be added between VDD and GND for
wave filtering." anybody try it?
Sensor works fine for me about 24 hours and then simply hangs and only power cycle can resolve the problem.
"One capacitor valued 100nF can be added between VDD and GND for
wave filtering." anybody try it?
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
new info
sensor stop respond after several hours of work
strace output
"
...
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
...
"
I've made power cycle only for the dht22 and after this it works fine. (but don't know how long)
sensor stop respond after several hours of work
strace output
"
...
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
nanosleep({0, 1000}, NULL) = 0
...
"
I've made power cycle only for the dht22 and after this it works fine. (but don't know how long)
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
For the dht22, see my other thread, and my version of the app:
http://www.raspberrypi.org/phpBB3/viewt ... 37&t=27215
http://www.raspberrypi.org/phpBB3/viewt ... 37&t=27215
Where did you see this? I'm always keen to try something that means more soldering..asa_g wrote:I've another problem.
Sensor works fine for me about 24 hours and then simply hangs and only power cycle can resolve the problem.
"One capacitor valued 100nF can be added between VDD and GND for
wave filtering." anybody try it?
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
https://www.sparkfun.com/products/10167
there are datasheet and example program
yep, i'm using the latest adafruit driver for dht22
i've made changes in my program and now asking dht22 only one time in 15 seconds, may be this will help
there are datasheet and example program
yep, i'm using the latest adafruit driver for dht22
i've made changes in my program and now asking dht22 only one time in 15 seconds, may be this will help
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Maybe there is some counter on the DHT22 which overruns after too many reads and crashes the program on it. Anyways nothing we can do.
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
I've noted that if you google "dht11 capacitor", you land on pages and pages of Aduino users discussing this FAQ around why it is definitely required.asa_g wrote:I've another problem.
Sensor works fine for me about 24 hours and then simply hangs and only power cycle can resolve the problem.
"One capacitor valued 100nF can be added between VDD and GND for
wave filtering." anybody try it?
I'll try and get my hands on such a capacitor and report back.
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
In case someone wonders what's inside DHT22

http://dl.dropbox.com/u/96422972/dht22back.JPG

http://dl.dropbox.com/u/96422972/dht22front.JPG
http://dl.dropbox.com/u/96422972/dht22back.JPG
http://dl.dropbox.com/u/96422972/dht22front.JPG
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Regrettably, no real improvement with the capacitor.
That said, it's about a 5c part, there's kind of no excuse to avoid it.
That said, it's about a 5c part, there's kind of no excuse to avoid it.
Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log
Hey guys,
In line with what I consider important in good coding, there's a new version out.
This one features a method of preventing the app from being run too fast. You can see for example, the results of running it from two terminals within one second of each other. This will ensure that this particular issue isn't involved.
$ sudo /usr/local/bin/loldht
Raspberry Pi wiringPi DHT22 reader
www.lolware.net
Lock file is in use, waiting...
Humidity = 43.60 % Temperature = 25.30 *C
I've included much more stringent checks on return values and type casts, and used "splint" to verify the work.
Finally, there's an autoconf harness.
I haven't seen a dramatic improvement in output reliability, however, it gives us a much more reliable place to go from.
In line with what I consider important in good coding, there's a new version out.
This one features a method of preventing the app from being run too fast. You can see for example, the results of running it from two terminals within one second of each other. This will ensure that this particular issue isn't involved.
$ sudo /usr/local/bin/loldht
Raspberry Pi wiringPi DHT22 reader
www.lolware.net
Lock file is in use, waiting...
Humidity = 43.60 % Temperature = 25.30 *C
I've included much more stringent checks on return values and type casts, and used "splint" to verify the work.
Finally, there's an autoconf harness.
I haven't seen a dramatic improvement in output reliability, however, it gives us a much more reliable place to go from.