Page 1 of 2
DHT11 to DHT22!
Posted: Thu Apr 24, 2014 11:22 am
by jgu1
Hi All!
I have played with Enamul's and John's fine examples of DHT11 which works very very well. I can see that DHT22 has greater accuracy. And I can see the data for the 2 sensors are not equal.
I've tried to look at the example of DHT11 (John's) FC to try to "decode" the program, but it contains C code which I am not able to read and therefore can not see how the 40 bits are read from DHT11.
I dare to ask, because I think it's a very good project and can be useful in many respects and deserves a DHT22 with greater accuracy, is it very difficult to change the program to a DHT22 sensor.

and someone will make the attempt. I myself am not able to do so.
John´s Poject http: //
www.matrixmultimedia.com/mmforums/viewt ... t11#p44939
I would be very grateful if anyone can help....
Best regard
Jorgen
Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 1:00 pm
by cubitus54
Hello,
I made this program for DHT11 or DHT22
It works very well

Warning this is a macro (macro import)
Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 1:46 pm
by jgu1
Hi Cubitus!
Thank you very much, I am very greatfull. I Will test it later today and you hear from me.
But I wonder how it is possible to use both DHT11 and 22 in same program.
Thanks in advance
Jorgen
Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 6:44 pm
by jgu1
Hi Again Cubitos!
I have tested your macro. I made a program (att.) The only thing I see in the display is 0,% and 0, c. I use a Pic16f876a and change the input for the DHT22 to C4
Are you able to se what i have done wrong?
Best regard
Jorgen
Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 7:30 pm
by cubitus54
Hello,
Must leave some time between acquisitions (eg 0.5 s)
Must adjust the value. "Chrono>
35" depending on the speed of the microcontroller. 35 is a PIC 64MHz. At 19MHz, your good value should be around the value 10.

- Image1.gif (8.15 KiB) Viewed 27302 times
Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 8:25 pm
by jgu1
Hi Again!
Now humidity seem to work

But not the temp. If I change the same Crono for temp I get the value 10,2c but it stuck´s same value all the time.
I don´t understand 100% where I have to place a delay for 500ms "Must leave some time between acquisitions (eg 0.5 s)".
B R.
Jorgen
Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 8:42 pm
by cubitus54
For the 500ms

- Image3.gif (6.03 KiB) Viewed 27295 times
You can try to change the value 8 9 10 11 12 of .chrono,
You can also try changing the first delay 2ms to 4ms
Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 8:56 pm
by jgu1
Hi Again and Again!
Meanwhile I found a bug ( I made ), now it Work

Wery nice, and looks very promising. Compared with my proff. reference humidity/temp. measure, they are very equal
again thank you very much your help.
Best regard
Jorgen
Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 9:06 pm
by cubitus54
I'm happy for you

Re: DHT11 to DHT22!
Posted: Thu Apr 24, 2014 9:25 pm
by jgu1
Hi!
If anyone is interested I would like to share with you all.
It works very fine the readout from DHT22 Cubitus made.
B Regard
Jorgen
Re: DHT11 to DHT22!
Posted: Fri Apr 25, 2014 7:53 am
by jgu1
Hi Cubitus!
Oooopps. During test I discovered when the temerature is lower than 10 degre the display begin to show 99,c and 98,c ect.
I could imagine it is the decimal place which is not correct when below 10,0c
Will you help me to correct this. Pls
Best regard
Jorgen
Re: DHT11 to DHT22!
Posted: Fri Apr 25, 2014 12:34 pm
by cubitus54
Re: DHT11 to DHT22!
Posted: Fri Apr 25, 2014 1:34 pm
by jgu1
Ok you Can se it!
But the only ting I understand is "To string funtion" and I could imagine this is not the problem
Is it possible to solve, and do you have an idea
B R.
Jorgen
Re: DHT11 to DHT22!
Posted: Fri Apr 25, 2014 4:02 pm
by cubitus54
Sorry, I do not understand your question ...
Re: DHT11 to DHT22!
Posted: Fri Apr 25, 2014 5:16 pm
by jgu1
Hi Again!
Sorry but my English is not so good.
What I meant, was that of all your calculations, in the calculation box, was the only thing I could figure out was the "to string" command.

( I do not have the deep experience with programming as you have).
I see you have been so kind to make a new FCF file or changes for me. I'll test it tomorrow. You hear from me.
So far, many thanks.
Jorgen
Re: DHT11 to DHT22!
Posted: Sat Apr 26, 2014 10:17 am
by jgu1
Hi Cubitus!
I have tested the temperature with coolspray: IT IS PERFECT :
For the humidity I am not able to test this. I have no dry air on spray

But i suppose you have corrected the bug for both.
Thank´s Again Cubitus.
Best regard
Jorgen
Re: DHT11 to DHT22!
Posted: Sat Apr 26, 2014 10:28 am
by cubitus54
Hello,
No, I did not correct the humidity, I do not know if this is really useful.
The humidity of the air diminishes very rarely below 30%
The principle is the same as for the temperature.
Re: DHT11 to DHT22!
Posted: Sun Jan 03, 2016 8:48 pm
by cubitus54
Hello
For the négative temp.

- temp_neg.gif (12.06 KiB) Viewed 25674 times
◎Special Instructions:
When the temperature is below 0 ℃, the highest position of the temperature data.
Example: -10.1 ℃ Expressed as 1 000 0000 0110 0101
Temp.:0000 0000 0110 0101 = 0065H(Hexadecimal)= 6×16 +5 = 101
=> Temp. = -10.1℃
Re: DHT11 to DHT22!
Posted: Mon Jan 04, 2016 11:21 am
by jgu1
Hi Cubitus!
Thank you very very much. I am really grateful.
I will test it tonigth, and you hear from me.
One more small thing. I have 10 pc of DHT22. When I test them in same program and hardware, I get 10 different result, in temp and humidity, small differences. So in my view, its the DHT22 which not is 100% accurate. If I have one DHT22 wich I want to use as reference, where in the program in calculationbox can I add + or - to adjust it so it fit to my reference.
Hope it´s not to much
Thank´s in advance.
Jorgen
Re: DHT11 to DHT22!
Posted: Mon Jan 04, 2016 11:41 am
by cubitus54
Hello
You put a variable or constant with offset
offset = 3 for example (+0,3°C)
Code: Select all
.temperature = .temperature + offset
.temperature = .temperature AND 0x03ff
.entier = .temperature / 10
...
OR
Code: Select all
.temperature = .temperature + 3
.temperature = .temperature AND 0x03ff
.entier = .temperature / 10
...

Re: DHT11 to DHT22!
Posted: Mon Jan 04, 2016 12:20 pm
by jgu1
Hi Again Cubitus!
Again thank´s. You get a reply.
BR.
Jorgen
Re: DHT11 to DHT22!
Posted: Mon Jan 04, 2016 5:20 pm
by jgu1
Hi Cubitus!
I am sorry, but the last version doesn't work. The temperaturen is stocking, never changing even when the temperature is changing. The display show the same temp when I start. The humidity seemed to work.
Br.
Jorgen
Re: DHT11 to DHT22!
Posted: Mon Jan 04, 2016 8:15 pm
by cubitus54
Hello,
I have not tested on the hardware ... Normally it should work.
Cubitus
Re: DHT11 to DHT22!
Posted: Mon Jan 04, 2016 9:00 pm
by jgu1
Hi Again
Ok, but it doesn´t Work. The temp is "stock" it only change temperature when I reset the Pic. If I put the "old" program in the same hardware Again, it Work Again (without minus)
Sorry.
Br. Jorgen
Re: DHT11 to DHT22!
Posted: Mon Jan 04, 2016 10:03 pm
by kersing
Jorgen,
Could you post the contents of the calculation box?