Project

General

Profile

JeeNode Micro with DHT22

Added by urmel over 5 years ago

Hello everybody,

I’m new to the JeeNode stuff and I’m very excited about it. :)

I managed to get a JeeNode USB v6 and a JeeNode Micro v3 running and I can successfully run
the radioBlip2 sketch on the JN-Micro while receiving the counter on the JN-USB.

Now I’m trying to attach a DHT22 sensor. I first attached it to the JeeNode USB v6 and tried
the dht_demo sketch. That works fine; I can see the temperature and humidity values from the
sensor shown in the serial monitor.

Now I have the DHT22 attached to the Micro and modified the radioBlip2 sketch to include
temperature und humidity values in the payload struct. I added a DHTxx global variable in
the sketch, but I’m unsure about the port number to use.

Judging from the JN-Micro reference http://jeelabs.org/2013/03/23/jn-micro-v3-reference
I thought I should use

DHTxx (10); // connected to DIO/PA0 of JNm

to use the DIO/PA0 pin on the JN-Micro device, but the values sent in the payload structure
stay at 0 for unknown reason. As obviously debugging is not so easy with the JN-Micro I am
wondering if I just missed something very basic.

Did I use the wrong portnumber? Or do I have to first switch on DIO on the JN-Micro? What
else might be wrong?

Any ideas?

Best wishes,
Urte


Replies (24)

JeeNode Micro with DHT22 - Added by martynj over 5 years ago

urmel,

Do you have the JeeNode Micro Direct running from a coin cell?  This has at most 3.0V on the Vcc pin.  I think you need to check that the DH22 can work at 3.0V (on the JeeNode USB this is a 3.3V supply).
A quick check would be to take out the coin cell and feed in 3.3V ‘borrowed’ from your JeeNode USB.

RE: JeeNode Micro with DHT22 - Added by JohnO over 5 years ago

Take a look at http://jeelabs.net/boards/7/topics/3229?r=3242\#message-3242 to improve the debugging capability of JeeNode Micro.

RE: JeeNode Micro with DHT22 - Added by urmel about 5 years ago

martynj

Good point. Yes, I run the JN-Micro from a coin cell. From the specs the DHT22 should be fine with anything from 3 to 5 V.

http://learn.adafruit.com/dht/overview

Borrowing 3.3V from the JeeNode USB and receiving the values through DIO on the JN-Micro ends up with the values sent still being all zero.

@JohnO

I’ll have a closer look into debugging the JN-Micro from the link you mentioned.

Best wishes,
Urte

RE: JeeNode Micro with DHT22 - Added by urmel about 5 years ago

Update after some struggling with the debugging capabilities using the serial output ….

The dhtxx.reading() method contains a loop where there is some response expected from the
sensor. When the timer expires reading() returns false and this seems to be the place where
I end up when the sensor is connected to the JN-Micro (no transition seen):

// each bit is a high edge followed by a var-length low edge
for (byte i = 7; i < 48; +i) {
// wait for the high edge, then measure time until the low edge
byte timer;
for (byte j = 0; j < 2;j)
for (timer = 0; timer < 250;
+timer)
if (digitalRead(pin) != j)
break;
#if DEBUG_DHT
times[i] = timer;
#endif
// if no transition was seen, return
if (timer >= 250) {
sei();
return false;
}
// collect each bit in the data buffer
byte offset = i / 8;
data[offset] <<= 1;
data[offset] |= timer > 7;
}

The sensor still works fine when connected to the JeeNode USB. I’m still taking the sensor power from
the JeeNode USB, the only sensor wire connected to the JN-Micro is the data line on DIO. But no values
are received.

Any other ideas?

Best wishes,
Urte

RE: JeeNode Micro with DHT22 - Added by JohnO about 5 years ago

Have you exercised the relevant pin to verify the hardware?

Perhaps a wiring diagram.

RE: JeeNode Micro with DHT22 - Added by ozzy about 5 years ago

You do have a ground wire between the two ?

RE: JeeNode Micro with DHT22 - Added by martynj about 5 years ago

urmel,

Since that timing loop is purely CPU bound, doesn’t it need correction for the different clock speed on the JeeNode Micro?

RE: JeeNode Micro with DHT22 - Added by AndreasZoeller about 5 years ago

I have also tested the JeeLib and found that there is a problem. I then changed to this lib : http://nathan.chantrell.net/20120707/using-the-tinytx-with-dht22-temperaturehumidity-sensor/
It works real fine. I have 4 JeeMicro in and around our house and they work well. I am using 3 AAA-cells which are a little bit older and have only app. 1.2 Volt each, so that the total voltage is something from 3.0 to max. 3.8 Volt. I think all other kind of regulated powersuplly has a quiescent current which is higher than the current which is need for the JeeMicro itself. I am reding the sensor each minute and sending the data only if there is some changement. For the humidity i set a treshold of 1% humidity changement to send the data.

best regards, a merry Christmas and a happy New Year

Andreas

RE: JeeNode Micro with DHT22 - Added by urmel about 5 years ago

Today I tested with a OneWire temperature sensor DS18B20.

I first connected it to the JeeNode USB on Port 1, the DHT22 still connected to Port 2.
Both worked fine, sending reasonable values with a difference of 0.3 °C between them.

Then I connected the DS18B20 to the DIO of the JN-Micro (same pin the DHT22 was connected
to before), modified my readout/sending sketch and after uploading I do receive temperature
values from the JN-Micro!

The problem seems to exist only with the combination JeeNode-Micro plus DHT22.

To answer your questions: Ground wire between sensor and board is connected. I can make a
wiring diagram, but I have none readily available. Judging from the DS18B20 test the DIO
pin of the JN-Micro should be fine. Concerning the clock speed I can’t tell if that’s the
reason for the DHT22 not working. Could be worth a try extending the timeout value to see
if the answer comes later with the JN-Micro. Is there a documentation on what to do when
modifying the JeeLib source code to build a new library?

@Andreas

Thank you for your reply. I will have a closer look at the library you linked to. If that
one works for me as well we might be able to figure out from the differences why JeeLib is
unable to readout the sensor values.

Stay tuned …

Best wishes, merry Christmas and a happy New Year! :)
Urte

RE: JeeNode Micro with DHT22 - Added by gbloice about 5 years ago

I am running a similar setup to what you are looking for and gave up on the Jeelib DHT22 library and went with this one: http://playground.arduino.cc/Main/DHTLib.

You can see the resulting sketch I’ve used at: https://github.com/gbloice/AirWick, note that I’ve used the pin marked Rx/PA2 which equates to pin 8. I’ve also changed the RFM Group to 5.

RE: JeeNode Micro with DHT22 - Added by urmel about 5 years ago

OK, here are the newest findings on my JN-Micro plus DHT22 problem:

I tested with the DHT22 class from http://nathan.chantrell.net/20120707/using-the-tinytx-with-dht22-temperaturehumidity-sensor/ (thanks to Andreas) as well as the DHT class from http://playground.arduino.cc/Main/DHTLib (thanks to gbloice).

With both classes I finally do receive values from my DHT22 sensor while it is attached to my JN-Micro (hurray). With both classes the temperature values look fine, but with both classes I receive unreasonable humidity values.

Currently the sensor is sitting outside and it’s raining. The humidity values tranferred are around 20% which is way too low; it should be something like 80+% … ??

I’m reading the values using myDHT22.getTemperatureCInt()/myDHT22.getHumidityInt() resp. dht.temperature/dht.humidity class values.

My sketch looks very much like the AirWick.ino from @gbloice.

Currently the sensor is connected using a breadboard; I wonder if I should solder it to make sure that this is not a contact issue.

Best wishes,
Urte

RE: JeeNode Micro with DHT22 - Added by plutonomore about 5 years ago

@Urte,

Am attaching a link, which from reading your previous posts, might be of interest. Included are tested sketch examples for
both the DS18B20 and DHT22 sensors. The post is #63, I think, anyway it begins with, @Bob, Yes the photo is of my clone!

http://jeelabs.net/boards/7/topics/2986?r=3260\#message-3260

cheers,

RE: JeeNode Micro with DHT22 - Added by urmel about 5 years ago

Thanks to all for your replies and ideas.

I tested with various DHT libraries finding that all of them work fine as long as the DHT sensor is connected to the JeeNode USB. When connecting it to the JN-Micro some do not work at all, sending zeroes for both temperature and humidity; the others work find for the temperature but none of them works for the humidity. Humidity values are always way too low (from 7% to 20% when it should be somewhere around 40%). There is no difference between using DIO1 or DIO2 on the JN-micro.

Please find attached two photos of my setup with the DHT sensor connected to the JeeNode USB resp. to the JN-micro. All I change between the two images is the data line connection (yellow). Power comes from the JeeNode USB in both cases to ensure good voltage (constantly 3.3V which should be OK for the sensor).

Maybe I should consider using another sensor for measuring humidity. Are there any recommendations other than the DHT22 known to work with the JN-micro?

Hoping to move forward next year … :)

Best wishes and happy new year,
Urte

DSCN4849.JPG (568 KB) DSCN4849.JPG DHT22 connected to JN-micro (wrong humidity)
DSCN4850.JPG (635 KB) DSCN4850.JPG DHT22 connected to JeeNode USB (OK)
1735
1736

RE: JeeNode Micro with DHT22 - Added by JohnO about 5 years ago

I find it hard to believe it is hardware. I guess the libraries are different.

RE: JeeNode Micro with DHT22 - Added by plutonomore about 5 years ago

@Urte,

Just a thought, don’t know if you have tried SEVERAL of the DHT22 sensors or just the ONE? If the latter is the case
any chance that sensor could be faulty for humidity readings?

cheers,

RE: JeeNode Micro with DHT22 - Added by plutonomore about 5 years ago

@Urte,

Sorry, forget previous post, you did say the humidity sensor was OK when connected to the JeeNode USB, silly me!

Happy New Year,

RE: JeeNode Micro with DHT22 - Added by urmel about 5 years ago

plutonomore, I have two DHT22 sensors and both show the same behaviour. And yes, when using the JeeNode USB both work.

I also believe this is some software/library effect with the JN-micro/ATtiny84.

For now I’ll change my plan and connect DS18B20 temperature-only sensors to the mobile JN-micros and measure humidity only at the JeeNode USB until further insight.

Happy New Year!
Urte

RE: JeeNode Micro with DHT22 - Added by JohnO about 5 years ago

urmel could you post your full sketch?

I have ordered some DHT22 and would like to reproduce the problem you are seeing.

RE: JeeNode Micro with DHT22 - Added by martynj about 5 years ago

Reposting JCW’s comment:

Jumping in, but probably not adding much to this discussion: the DHT protocol is timing-specific. Have you checked that the µs timings are ok, given that the ATmega normally runs at 16 MHz and the ATtiny at 8 MHz? A scope snapshot should be able to make sure. Bit unlikely, given that the temp readout is ok. Voltage levels or noise, perhaps? Consider adding some cap(s) between + and - near the sensor.

RE: JeeNode Micro with DHT22 - Added by urmel about 5 years ago

@JohnO, sure! Please find them attached to this post.

The dht_demo_urmel.ino just sends out temperature and humidity values to serial monitor
every five seconds.

The jeenode_micro_urmel.ino transmits temperature and humiditiy values once every minute
via RF; you can capture them on the JeeNode USB using the standard RF12demo sketch.

I left in a couple of #if 0 / #endif statements reflecting my experiments with different
DHT libraries. This version uses http://nathan.chantrell.net/20120707/using-the-tinytx-with-dht22-temperaturehumidity-sensor/.

I’m curious about your findings! :)

Best wishes,
Urte

dht_demo_urmel.ino (4.63 KB) dht_demo_urmel.ino sketch for DHT22 connected to JeeNode USB
jeenode_micro_urmel.ino (8.78 KB) jeenode_micro_urmel.ino sketch for DHT22 connected to JeeNode Micro

RE: JeeNode Micro with DHT22 - Added by JohnO about 5 years ago

It will be a few weeks before I get the DHT22.

RE: JeeNode Micro with DHT22 - Added by gbloice about 5 years ago

urmel wrote:

> The jeenode_micro_urmel.ino transmits temperature and humiditiy values once every minute
> via RF; you can capture them on the JeeNode USB using the standard RF12demo sketch.
>
> I left in a couple of #if 0 / #endif statements reflecting my experiments with different
> DHT libraries. This version uses http://nathan.chantrell.net/20120707/using-the-tinytx-with-dht22-temperaturehumidity-sensor/.
>
> I’m curious about your findings! :)

urmel,

I’ve had a look at your Jeenode micro sketch and you are casting the temperature and humidity values to a byte. This limits each value to 25.5 with the scaling factor you’ve applied. This might be adequate for the temperature range you expect to see, but probably not for the humidity. You’ll need to allocate at list 10 bits for the humidity (1024 = 102.4% ). In my Airwick sketch I use an int for both temperature and humidity.

In the JeeNode USB you are using int’s hence the values are correct.

Regards,

RE: JeeNode Micro with DHT22 - Added by JohnO about 5 years ago

urmel, have you had a chance to verify the solution so kindly proposed bygbloice?

RE: JeeNode Micro with DHT22 - Added by urmel about 5 years ago

@JohnO, sorry for the delay in my response! I’m back at work so it’s harder to find some “JeeNode spare time”.

Also thanks a ton to @gbloice.

Indeed it turned out that using integer instead of byte makes the values look much better. I’m still in the progress of verifying correct humidity but the values do look quite reasonable now. Moreover in my sketch for the JN-micro I introduced temperature and humidity values as integer in the payload struct first, but unfortunately while testing various versions after experiencing the zero values I changed that to byte. Silly me!

For completeness regarding jcw/martynj’s comment on timing with the DHT class of the JeeLib: Before trying all the other DHT implementations I first doubled the timeout value in the for-loop from the dhtxx.reading() method using 500 instead of 250, but that didn’t change anything. I haven’t tried fiddling around with timings with any of the other DHT implementations.

Best wishes,
Urte

    (1-24/24)