I covered some of this in the comments on my last post but thought it made sense to do a separate post detailing it.
The DHT22, also known as the AM2302 and RHT03 is a relatively cheap combined digital temperature and humidity sensor that with a little manipulation will go straight onto my TinyTX sensor board (or previous stripboard versions) in place of the DS18B20 temperature sensor.
The DHT22 is widely available and costs around £6 on eBay with delivery so not too expensive, don’t be tempted by the cheaper DHT11, in my tests the readings it returned were wildly inaccurate and it will only return integer values and only covers 0-50°C compared to -40 to 125°C for the DHT22. Someone also commented in the previous post that they had the same experience of inaccurate results with the DHT11 so it seems it wasn’t just a one off bad unit that I had.
The DHT22 has four pins but the third (looking at it face on) isn’t used, by bending the unused pin out of the way and bending the fourth in slightly it will fit into the pads for the DS18B20, the only other change required for the hardware is to swap the 4K7 resistor for a 10K. Load the ATtiny with some modified code and we’re good to go.
The gotcha here is that the DHT22 only works down to around 3V, once it dropped below 2.96V in my tests it started to return bad readings. For the moment I am just running one off 2xAA batteries (a starting voltage of 3.19V) and will see how long I can get from it. My ATmega based temperature sensor took 6 months before the voltage dropped to 3V so I should get at least that long and I could then recycle the batteries in one of my DS18B20 sensors. Failing that I could use a boost converter to keep the voltage up at 3.3V or add another battery or two and use a voltage regulator to drop it to 3.3V.
The code for using the DHT22 sensor is available on my GitHub here. The sensor uses a one wire type protocol but is incompatible with the Dallas OneWire system, I’m using the library from here although thanks to a comment from Troels in my last post I realised it has a bug regarding negative temperatures, I’ve fixed that and submitted a pull request but in the meantime you can use my fork here.
I’ve also been looking at other humidity sensors, the Sensirion SHT1x and SHT7x look good, work down to 2.4V and are easily available but they are pricey (~£20+), the HYT131 is a bit cheaper (~£15+) but not widely available. All these use a 2 wire bus to communicate so wouldn’t be as easy to use with this board as the DHT22. Probably something to look at closer for the next version of the TinyTX.
There is now a dedicated page for the TinyTX.



Nathan, wonderful project! I have the OpenEnergyMonitor system working, and had looked at your earlier posts, bought the parts, and even ordered the DHT22 to see if could also get this going. Now I see you have done all the hard work – thanks! I plan to have several such distributed sensors / transmitters. Have you considered offering the PCB (and components) for sale, perhaps via the OEM website if they wish to collaborate? I imagine setting up an e-commerce site is a lot of work. I think there would be demand!
By the way, can the TinyTX version have multiple DS18B20 sensors all connected with the common bus? I assume so, but it is good to check!
Cheers
andy
Thanks Andy. I’ve got some ideas brewing for the next version and have been thinking about offering some for sale as a few people have asked, wouldn’t be hard to do through Paypal.
You can run multiple DS18B20 sensors by daisy chaining them in the normal way.
To read them you can just do something simple like this:
tinytx.temp0=(sensors.getTempCByIndex(0)*100);
tinytx.temp1=(sensors.getTempCByIndex(1)*100);
tinytx.temp2=(sensors.getTempCByIndex(2)*100);
and add the variables to the Payload data structure.
or if you plan on adding more sensors later it would be better to use the direct addressing method to identify each sensor so the variables don’t move round as you add more. There are some examples of how to do that in the emontx code somewhere.
Hi Nathan, Thanks! I will definitely try this project (on stripboard to start with), but look forward to being able to buy some PCBs in future. I suspected that multiple temp sensors would work on a single unit, so I’m glad this is the case. I can see lots of applications for internal/external temp/humidity (calculating dew points and making recommendations when to open windows on hot evenings), as well as monitoring of the boiler, water tank, solar heating system. Cheers Andy.
Hello
great project but hard to find. I was looking for a wireless temp sensor reader that can read mutliple wireless sensors. As far as I followed your posts, you currently use only one wireless sensor.
My goal is to have different wireless temp/humidity sensors spread over the rooms of the house and one outside and fead there data into a web server, so I can read the values from the network.
Is it possible to use multiple sensors with your code?
thanks
Josef
PS, sorry, I submitted to fast.
Actually I have three wireless sensors using OOK at 430 Mhz. In the meantime I realized that it will be very hard to read there values although there are some descriptions out there to read there data (TFA Dorstmann sensors).
So I turned around and would like to start with RFM12B based wireless sensors.
regards
Josef
Hi Josef,
Yes, I’m only using one sensor on each board and putting multiple boards around the house, saves running wires for additional sensors.
It doesn’t look like the DHT22 can’t be daisy chained like the DS18B20 sensor so to run multiple sensors would require a separate pin for each sensors data line. Looks like it would be easy enough to adapt the code for that.
Cheers,
Nathan
I am coming to this late. Moving some projects from arduino to rpi.
The humidity from DHT11 is as often as not garbage. I am doing some sensor -> web “domestic” projects, and do weather application software for a living. I reckon only about half DHT11′s give a decent RH. (I’ve wired up a few now). Half are 15-20% out which will make a mess of a dewpoint applications. I suppose you get what you pay for. The temps from DHT11 and for that matter TMP36 / LM35 / BMP085 etc all look OK and comparable but for real weather apps you obviously need sensors that range down to -40 (well not really that far).
Outdoor sensors make for much more interesting real applications but present the problems of preventing water ingress, dew and solar heating whilst still getting good ventilation. Real McCoy shields and screens come at a hefty price, and attract vandals and nosey pokey fingers IMHO. An incongruous home-made gubbins is a fun challenge.
Regards / MikeR
Yes, outdoor sensors are tricky, I initially had problems with solar heating mid morning until I moved them from the rear of the house to the front, they are currently situated under a sheltered outrigger which keeps them out of direct sunlight and rain, not ideal but ok for my purposes. I’m currently waiting for one of the Air Quality Egg kits, a project that has suffered many delays, not least of which has been the design of a suitable enclosure for the sensors, it will be interesting to see how it performs. The AQE is also built on AVR/RFM12B technology so should be a good match for my existing setup. Looking forward to eventually receiving it, latest estimate was end of this month.
Hi, i think the fix for negative temp does not work for me. It reads 32706 instead of minus degrees. I Try to fix that later..
@Beat – That’s strange, it has been working fine here and we’ve had plenty of sub zero temperatures lately. Do let me know if you work out what it was.
I solved it the lazy way: switched to Adafruit’s Library https://github.com/adafruit/DHT-sensor-library. Had immediately correct values and some bytes less ram usage….
Hello Hathan,
were you trying to run rfm12b at 4V? Right now I’m trying to solve problem with voltage and DHT21 (3 NIMHs are way cheaper than stepup from one AA battery). From datasheet there is up to 3.8V operating… The voltage will drop quite quickly below 3.8 but I’m starting at 4.0V…
Thank you
Jan
No, I was trying it with 2xAA but I was only getting a few months before the battery dropped too low for the DHT22. In the end I decided to use a boost converter to give a constant 3v3 output from 2xAA batteries. There’s a picture here of one with a Sparkfun boost converter: http://www.flickr.com/photos/nathanchantrell/7983690702/in/set-72157627035836187
Cheers,
Nathan
Have been working with the DHT11 sensor and as far as I can asertain by using a wet/dry hygrometer its humidity readings are of no use so I gave up on them. I went searching and found these: HIH-6130, HIH-6121 made by Honeywell they are I2C and their readings are proving to be accurate the HIH-6121 seems to be the best value for money with inbuilt filter, they cost more than the DHT sensors but if you want actual readings of humidity they give you that the only drawback is they all have the same slave address so only one per buss.
Yes I found the DHT11 to be useless too, it has been sitting in my parts box since. The DHT22 is much much better though and still pretty cheap compared to the I2C sensors.