discovery
Posts: 5
Joined: Tue Sep 18, 2012 7:14 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Sat Sep 22, 2012 8:15 pm

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!

rtramon
Posts: 16
Joined: Sat Jul 07, 2012 10:06 am
Location: 't Gooi

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Sun Sep 23, 2012 3:30 pm

In the C code in file dht.c the following snippet occurs:

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;
    }
I do not understand the line nanosleep(1) here, because according to the manual page for nanosleep() it needs two parameters:

Code: Select all

Name

nanosleep - high resolution sleep (REALTIME)
Synopsis

#include <time.h>

int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); 
What is the effect of calling nanosleep(1)?

netmagi
Posts: 1
Joined: Tue Oct 02, 2012 5:37 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Tue Oct 02, 2012 5:40 am

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?

Buckers
Posts: 3
Joined: Tue Oct 02, 2012 8:14 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Tue Oct 02, 2012 8:21 pm

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 ...

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);
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.

p4trykx
Posts: 127
Joined: Wed Jan 11, 2012 2:55 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Thu Oct 04, 2012 3:32 pm

@Buckers
I changed the sleep time as you suggested an it got big improvement :) :D

kenmc
Posts: 58
Joined: Fri May 04, 2012 8:02 am
Location: Dublin, Ireland
Contact: Website

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Thu Oct 04, 2012 7:44 pm

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

kenmc
Posts: 58
Joined: Fri May 04, 2012 8:02 am
Location: Dublin, Ireland
Contact: Website

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Fri Oct 05, 2012 3:44 pm

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?
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!
http://goatstownweather.eu.pn

discovery
Posts: 5
Joined: Tue Sep 18, 2012 7:14 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Sat Oct 06, 2012 5:32 pm

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!
Attachments
pierror.jpg
pierror.jpg (39.99 KiB) Viewed 6959 times

p4trykx
Posts: 127
Joined: Wed Jan 11, 2012 2:55 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Sat Oct 06, 2012 9:13 pm

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)

discovery
Posts: 5
Joined: Tue Sep 18, 2012 7:14 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Sun Oct 07, 2012 6:47 am

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?

kenmc
Posts: 58
Joined: Fri May 04, 2012 8:02 am
Location: Dublin, Ireland
Contact: Website

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Sun Oct 07, 2012 8:34 pm

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?
A bit leftfield, but are you set up like this :

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

discovery
Posts: 5
Joined: Tue Sep 18, 2012 7:14 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Mon Oct 08, 2012 5:36 am

No, my setup is:
Pi <---cable---> getaway/modem (internet)

So directly to the internet.

p4trykx
Posts: 127
Joined: Wed Jan 11, 2012 2:55 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Fri Nov 02, 2012 11:17 pm

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?

runfastman
Posts: 10
Joined: Thu Oct 18, 2012 1:12 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Sun Nov 18, 2012 8:01 pm

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);
}

User avatar
pineapple
Posts: 4
Joined: Fri Nov 30, 2012 5:06 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Fri Nov 30, 2012 5:12 pm

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.

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);
}

chorlton2080
Posts: 128
Joined: Sun Dec 23, 2012 9:44 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Sat Jan 05, 2013 9:31 pm

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...

asa_g
Posts: 20
Joined: Tue Jan 08, 2013 7:43 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Tue Jan 08, 2013 8:11 am

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?

asa_g
Posts: 20
Joined: Tue Jan 08, 2013 7:43 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Tue Jan 08, 2013 10:56 am

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)

technion
Posts: 238
Joined: Sun Dec 02, 2012 9:49 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Wed Jan 09, 2013 6:03 am

For the dht22, see my other thread, and my version of the app:
http://www.raspberrypi.org/phpBB3/viewt ... 37&t=27215
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?
Where did you see this? I'm always keen to try something that means more soldering..

asa_g
Posts: 20
Joined: Tue Jan 08, 2013 7:43 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Wed Jan 09, 2013 7:46 am

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

p4trykx
Posts: 127
Joined: Wed Jan 11, 2012 2:55 pm

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Thu Jan 10, 2013 1:52 am

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.

technion
Posts: 238
Joined: Sun Dec 02, 2012 9:49 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Thu Jan 10, 2013 11:41 pm

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'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.

I'll try and get my hands on such a capacitor and report back.


technion
Posts: 238
Joined: Sun Dec 02, 2012 9:49 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Fri Jan 11, 2013 9:50 am

Regrettably, no real improvement with the capacitor.

That said, it's about a 5c part, there's kind of no excuse to avoid it.

technion
Posts: 238
Joined: Sun Dec 02, 2012 9:49 am

Re: DHT Humidity Sensing - Raspberry Pi with Google Docs log

Fri Jan 18, 2013 3:32 am

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.

Return to “Automation, sensing and robotics”