Using the DHT11

10 replies [Last post]
kim
Offline
Throwleigh, United Kingdom
Joined: 1 Dec 2010

So now I want to measure humidity in the house using a DHT11 delivered promptly from the shop.

The Jeenode Integration page refers to "The RoomNode2 sketch will also support the DHT11 sensor which is a drop in replacement for the DS18B20 and adds temperature and humidity; with change in the code to select this device instead."  Looking at the source for roomnode2.hex at http://livebox-hah.googlecode.com/svn/trunk/userapps/arduino/roomNode2/roomNode2.ino it looks as though DHT11 is already selected.  But it also says that "SHT11, ONE_WIRE and DHT11 are mutually exclusive." and since my temp sensor works when plugged in - I assume that #define ONE_WIRE_PIN 4 is active instead.

So ... I would like to try and compile my own change - and have started looking at WinAVR and other stuff.  Could someone advise me on the best (free) software to use.

Regards

Kim 

p.s.  I have already changed my Jeenode applet section to the following in readiness:

-- Keyed by NODE ID

local nodes = {

   [2] = RoomNode{base="dbzoo.livebox.2.jeenode:test", 

                  endpoints={temp=1,light=1,lobat=1,moved=1,humi=1}, ttl=360},

 

   [3] = BoilerNode{base="dbzoo.livebox.2.jeenode:util",

                  endpoints={temp=1,light=1,lobat=1,moved=1}, ttl=360},

 

   [4] = BoilerNodeTwin{base="dbzoo.livebox.2.jeenode:test2", 

                  endpoints={temp=1,light=1,lobat=1,moved=1,temp2=1}, ttl=360},

derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
Arduino

Hi Kim,

Good to see you experimenting!

The firmware for the HAHnodes is written using the freely available Arduino environment. 
http://arduino.cc/en/Main/Software - I'm using version 1.0.5

As with any new compiler environment, there are a few things to get used to. However, it's pretty straightforward.

I know that Brett dropped a DHT11 into one of his roomNodes. I think this replaced the DS18B20 - reasonable enough as the DHT11 does humidity and temperature. 

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Kim,as Derek rightly says,

Kim,

as Derek rightly says, arduino environment is best.

just open sketch, modify, save and upload. Simple.

You will need to connect your jeenodes via a FTDI USB interface, assume you will be using one of these to connect your base node to HAH so it should be easy, just use that one.

alternatively you can flash the chip directly in an arduino and then transfer to the nodes ( I do this so as to keep my HAH up and running whilst messing.

winavr and the like are only really required when your chips don't have boot loaders on them.

 

good luck

 

Garry

kim
Offline
Throwleigh, United Kingdom
Joined: 1 Dec 2010
Thank you....

.. for your helpful input - a bit of of learning curve going on.  I had naively thought I could just compile one file and load it into the jeenode.  

Interesting.

 

Kim 

kim
Offline
Throwleigh, United Kingdom
Joined: 1 Dec 2010
Progress .. finally

Well ... I got roomNode2.ino to compile but had to make a number of changes:

1) Having downloaded DallasTemperature, Jeelib and OneWire libraries I found I had over 30 compile errors

2) In OneWire.cpp I changed "WConstants.h" to "Arduino.h" to make it work with Arduino 1.0.5

3) Ditto with DallasTemperature.cpp

4) Then found I had to move "Arduino.h" to be above the extern "C" line

5) Finally I put in an "include <PortsSHT11.h> - not needed - see below!

Then I got no more errors.

I then commented out #define DHT11PIN 4

and removed comments from //#define SHT11_PORT 1

Then plugged in basenode with the jeenode chip into the pc usb port and told it to upload.  No visible sign of anything happened but after a while it said uploaded.

Then I spent a long while compiling this post saying how it wasn't working.... before I realised it IS a DHT11 and not an SHT11 !!! 

So now it works.  At least the humidity goes from 58 to 70 when I breathe on it.  PIR doesn't work though? Maybe something to do with the fact that the line enabling it is commented out.

You can see my novice level.  I only found out about the changes to be made by googling the errors!  Fun though - glad I didn't try for a career in programming.
Kim 
derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
Loving the Arduino

Great job Kim.

I also had a bit of a struggle moving from 'pre version 1.0' Arduino to the latest. Quite a few things changed. Thank goodness for google. By writing this note, you've made the transition easier for others. 

Anyway, it sounds like your perseverence has (nearly) paid off.

Do keep going 'till that PIR works too (& publish your final sketch!).

As for a job in programming ... given this effort ... I reckon that you'd do a lot better than most.

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Good work Kim,

I find the struggles help with the learning curve.

One note for future reference that on hindsight I should have mentioned. Use a SVN checkout service (like tortoise SVN for windows) and check out the google SVN from google code. You will then have all the code (and libraries!) to hand on your local drive. Easy to keep updated with Bretts current versions.

Garry

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Oh sorry about that I just

Oh sorry about that I just noticed that I was not using a sync from the SVN repo so what I had wasn't what was checked in.

Damn..  I've checked in a bunch of replacements for these OLD libraries you should be able to keep in sync with the SVN repo and it will all compile now.   Glad you figured it out thou - good practice.

Brett

kim
Offline
Throwleigh, United Kingdom
Joined: 1 Dec 2010
Now we are cooking ..

...  and the PIR works as well.  

Learning curve on SVNs went 

1) Download from google code - didn't compile with html (!) 

2) Download from source

3) Got bored doing that one at a time - found a little prog called DownloadSVN.exe

4) Put directly into arduino "libraries" at the wrong level and then imported - it recursively created a depth of over 500 directories before I manually turned off the computer - took two hours to sort!

Now I understand that if I use TortoiseSVN I can do it all automatically - great - thanks

So I can join the ranks of "just open sketch, modify, save and upload. Simple."  Although I did like to see the livebox doing the avrdude stuff - watching it roll by was reassuring.

I might try updating my BoilerNodeTwin to see if I can measure the compost humidity!  But for now I shall content myself with annoying SWMBO by going round the house quoting the humidity levels.

Thanks for all the help.

Kim

p.s. Derek - I haven't published the sketch 'cos its just a trivial (ha!) amendment to Brett's code and he may update it (sic!).

p.p.s Cacti works really well - got the data collecting on the pi several weeks ago and haven't touched it since - just sits there on its own in the corner of the study loading off the cached data.

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Kim all good stuff.There was

Kim all good stuff.

There was a little write on using SVN on this wiki page http://www.dbzoo.com/livebox/hah_arduino

In case you missed it.

Brett

kim
Offline
Throwleigh, United Kingdom
Joined: 1 Dec 2010
Thanks

... yup - missed that.  Very useful

K

Hardware Info