Measurement of temperature and relative humidity using DHT11

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Sun Dec 02, 2012 5:03 pm

Hello

I have got some requests to make the program in FCv4. But it's very time consuming as I have to re-write the whole code. I have taken screen shots of the whole code so that any one can write in FCv4 if they want. User can post after completing the code if that doesn't work. I can fine tune easily.
Attachments
DHT11.zip
(2.57 MiB) Downloaded 526 times
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Mon Dec 03, 2012 9:39 pm

Hello,

Please have a little help.I have some questions.

Picture 8 - function calculation can not see everything.

Picture number 12 and 13 can not see everything.

Picture 7, C code... is so OK
st_bit(intcon, TMR0|E);
tmr0=0x00;

I would have to window variables.

Thank you.

rr

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Mon Dec 03, 2012 11:13 pm

Figure 8 calculation box..

Code: Select all

RH_Byte1 = RH_Byte1 | (1 << (7 - i))

Picture number 12 and 13 can not see everything.
I can't see any problem in picture 12 & 13
st_bit(intcon, TMR0|E);
tmr0=0x00;
That should be..

Code: Select all

st_bit(intcon, TMR0IE);
tmr0=0x00;

After completing the code you can post..I will check that for you
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Tue Dec 04, 2012 6:57 pm

Hello.

Thanks for the information. I write code for AVR ATMEGA32.
I have a problem with sharing frequency. I can not share the frequency 20MHz clock with 1:4.
The figure below
What should I do?

One more question.

My mistake, picture number 12 and 13 is OK.

I have a question for Figure 10, calculation box. Missing C code.

Thank you very much.

rr
Attachments
Prescaler_AVR.jpg
Prescaler_AVR.jpg (26.42 KiB) Viewed 13812 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Tue Dec 04, 2012 8:09 pm

Ok..I see the TMR0 issue. I can sort that if you post the FCv4 AVR code when it is finished. I have to tune TMR0 initial value to make it working.
One more question.My mistake, picture number 12 and 13 is OK.I have a question for Figure 10, calculation box. Missing C code.

It is same as last c code I posted only RH_Byte2 is in place of RH_Byte1.

Code: Select all

RH_Byte2 = RH_Byte2 | (1 << (7 - i))
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Tue Dec 04, 2012 8:52 pm

Hello.

Thank you for answer.

I attach the program for DHT11 Flowcode4 for AVR ATMEGA32. It is necessary to set TMR0.
Please see, if everything is OK.

RR
Attachments
DHT11_in_DHT22_RR_konstrukcija_Matrixmultimedia.fcf_avr
(21.05 KiB) Downloaded 331 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Fri Dec 07, 2012 1:04 am

Hello

I have to correct lots of things like right syntax for AVR register. Enable and disable code for TMR0. Need to select 1:64 pre-scalar for TMR0 which is initialized to 0xC0 to get right interrupt frequency..Now the code compiles fine. Can you please test that in hardware and let me know?
Attachments
DHT11_RR_konstrukcija_MM.fcf_avr
(21.05 KiB) Downloaded 306 times
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Fri Dec 07, 2012 5:03 pm

Hello Enamul.

Thank you very much for the optimization Flowcode4 AVR for DHT11. Sorry, but program does not work.

Using DHT22 sensor. DHT11 works the same as DHT22.

I think the problem in ATMEGA32. The maximum frequency is 16MHz for atmega32. On the atmega32 is necessary to reduce the frequency.

Enamul, how to calculate the value of TCNT0, if you have a quartz 11059200MHz? Is this a big problem?

We can a little help;).


Greetings.

RR

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Fri Dec 07, 2012 7:20 pm

I can explain you how I have calculated that for 20MHz. You can find your own.
For AVR, I think the instruction cycle 0.05 us. so the delay I am looking for using TMR0 is 204.8 us. so clock is defining pre-scaler..like 1:64 for me at 20MHz.

204.8/(0.05 * 64)=64..so 64 increment should cause overflow of TMR0. We know TMR0 overflows at 256..so 256-64=192 should be initial value at TMR0 register(TCNT0 in AVR). That's it. so you can choose your clock and right pre-scaler and right initial value.
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Sun Dec 09, 2012 6:50 pm

Hello Enamul.

Thank you very much for the information. Very nicely explained.

I understand:
1/20000000Hz = 0,00000005s = 0,05us. One cycle takes 0,05us.

I do not understand: How to get value TMR0 is 204.8 us???
Can you explain that?

I understand:
204.8/(0.05 * 64)=64..so 64 increment should cause overflow of TMR0. We know TMR0 overflows at 256..so 256-64=192 should be initial value at TMR0 register(TCNT0 in AVR). That's it. so you can choose your clock and right pre-scaler and right initial value.

Thanks.

RR

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Sun Dec 09, 2012 10:11 pm

I understand:
204.8/(0.05 * 64)=64..so 64 increment should cause overflow of TMR0. We know TMR0 overflows at 256..so 256-64=192 should be initial value at TMR0 register(TCNT0 in AVR). That's it. so you can choose your clock and right pre-scaler and right initial value.
I am confused..did you mean you understand my explanation or not?
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Tue Dec 11, 2012 10:14 am

Hello.

Sorry for the bad question.

I do not understand how to calculate the value TMR0 is 204.8 us.

204.8 us how to get this value?
Thanks.

RR

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Tue Dec 11, 2012 10:35 am

Hi
You can follow this link..I have explained there
viewtopic.php?f=46&t=11641
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Tue Dec 11, 2012 10:57 am

Thank you very much. Very good explanation.

I understand now.

Good luck!

RR

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Has thanked: 14 times
Been thanked: 4 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby nc56 » Sat Dec 22, 2012 10:16 pm

Hi ;
I want to know if I can show humidity and temperature on 7 segment ?
I think It must be converted to bcd form
Thanks

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Sat Dec 22, 2012 11:53 pm

Yes, you can show the value in 7-segment LED and u don't need to make to BCD just need to separate the digits to display in 7 segment. Flowcode can easily help you to display those in 7 segment.
Enamul
University of Nottingham
enamul4mm@gmail.com

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Has thanked: 14 times
Been thanked: 4 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby nc56 » Sun Dec 23, 2012 12:02 pm

Thanks Enamul
but in this case every number required 7 pins from the pic ,
so if i want to show temperature , humidity in the same time
using a 16f or 18f family pic I can't do that
that's why i'am looking how to change to bcd
I found this thread viewtopic.php?f=29&t=7420&p=18900
and I'am trying

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Sun Dec 23, 2012 12:19 pm

In multiplexed display you will need 8 pin for a,b,c..g and dp and common cathode or anode will be driven by one pin for each 7 seg Led. So you need maximum 4 pin + 8 pin
These users thanked the author Enamul for the post:
nc56 (Sun Jan 20, 2013 1:23 pm)
Rating: 5%
 
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Fri Feb 01, 2013 1:39 pm

Hello.

It's me again :wink: .

Compiled program for reading DHT11, but does not work. I used atmega32 and 10MHz Quartz. I changed the value of TCNT0 = 0xE0. Prescaler 1:64. The program is written in Flowcode4
DHT11 sensor is purchased http://www.ebay.com/itm/370691456827?ss ... 1497.l2649

Or you can check program? What I do wrong? I would be very happy.

Thanks!

Rradojko
Attachments
DHT11_RR_konstrukcija_Matrixmultimedia_BY_Enamul.fcf_avr
(22.6 KiB) Downloaded 262 times

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 716 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby JohnCrow » Sun Feb 10, 2013 6:15 pm

DHT11 With Alarm Outputs

I have made a small addition to Enamuls code to add over/under alarms to both the temperature and humidiy readings.

The display shows

Temp = TL TH OK
Humidity = HL HH OK

Ive built a small pcb with RGB LEDS. (One for temperature and one for humidity)
Red = Over
Green = OK
Blue = Under

IMAG0073.jpg
Breadboard
IMAG0073.jpg (62.25 KiB) Viewed 13312 times


Sensor Board.jpg
Sensor Board
Sensor Board.jpg (83.17 KiB) Viewed 13312 times


DHT11 - Alarm-Eblock-Works.fcf
Ararms Flowchard
(48.51 KiB) Downloaded 363 times


The setpoints are changed by editing the values in the flowcode variables
Temp_Low = 16
Temp_High = 24
Humidity_Low = 40
Humidity_High = 60

This program only compares with the integer part of the measured value. I considered this would have enough accuracy considering the overall accuracy of the sensor.
These users thanked the author JohnCrow for the post (total 3):
Benj (Mon Feb 11, 2013 11:16 am) • Enamul (Mon Feb 11, 2013 12:46 pm) • medelec35 (Mon Mar 25, 2013 10:11 pm)
Rating: 15%
 
1 in 10 people understand binary, the other one doesn't !

belayat
Posts: 1
Joined: Tue Aug 03, 2010 3:15 pm
Has thanked: 9 times
Been thanked: 1 time
Contact:

Re: Measurement of temperature and relative humidity using D

Postby belayat » Mon Mar 25, 2013 2:40 pm

Hello enamul sir

could you please write the algorithm of the program "DHT11v1.01.fcf" for the beginners.

belayat
These users thanked the author belayat for the post:
Enamul (Tue Mar 26, 2013 1:10 pm)
Rating: 5%
 

rradojko
Posts: 38
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby rradojko » Mon Mar 25, 2013 8:45 pm

belayat wrote:Hello enamul sir

could you please write the algorithm of the program "DHT11v1.01.fcf" for the beginners.

belayat


Hello,

I agree. This would be good for beginners. My algorithm still does not work.
I would ask for an explanation DHT11.

Thank you very much.

RR

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Enamul » Tue Mar 26, 2013 1:10 pm

Hi

I will post that.
Enamul
University of Nottingham
enamul4mm@gmail.com

Sean Danaher
Posts: 13
Joined: Thu Oct 15, 2009 9:16 am
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Measurement of temperature and relative humidity using D

Postby Sean Danaher » Wed Mar 27, 2013 10:21 am

I also use the DHT11 but with a PIC 12F683 acting as a 1-wire slave emulator and a 1-wire master (PIC Arduino or commercial) to display the data. I find that the ability to emulate 1-wire slaves (mainly DS18B20s), is very useful.
Happy to post more details if anyone is intereted
Sean

jaquy
Posts: 1
Joined: Mon Mar 17, 2014 4:02 pm
Contact:

Re: Measurement of temperature and relative humidity using D

Postby jaquy » Tue Mar 18, 2014 2:30 pm

hello enamul,
I need your help, your program for the anemometer you set the pulse as follows:
1 pulse /1 second = wind speed 0.1 m / s.
but I will: 1 pulse / 2.25 seconde = wind speed 1 mph (0.44 m / s)