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
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

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 576 times
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

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
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

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: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

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 15576 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

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: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

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 383 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

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 350 times
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

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
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

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: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

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
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

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: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

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
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

Hi
You can follow this link..I have explained there
http://www.matrixmultimedia.com/mmforum ... 46&t=11641
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

Thank you very much. Very good explanation.

I understand now.

Good luck!

RR

nc56
Posts: 60
Joined: Thu Nov 15, 2012 1:21 pm
Contact:

Re: Measurement of temperature and relative humidity using D

Post by nc56 »

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
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

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
Contact:

Re: Measurement of temperature and relative humidity using D

Post by nc56 »

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 http://www.matrixmultimedia.com/mmforum ... 20&p=18900
and I'am trying

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

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
Enamul
University of Nottingham
enamul4mm@gmail.com

rradojko
Posts: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

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 295 times

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Contact:

Re: Measurement of temperature and relative humidity using D

Post by JohnCrow »

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
Breadboard
Breadboard
IMAG0073.jpg (62.25 KiB) Viewed 15076 times
Sensor Board
Sensor Board
Sensor Board.jpg (83.17 KiB) Viewed 15076 times
DHT11 - Alarm-Eblock-Works.fcf
Ararms Flowchard
(48.51 KiB) Downloaded 398 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.
1 in 10 people understand binary, the other one doesn't !

belayat
Posts: 1
Joined: Tue Aug 03, 2010 3:15 pm
Contact:

Re: Measurement of temperature and relative humidity using D

Post by belayat »

Hello enamul sir

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

belayat

rradojko
Posts: 40
Joined: Thu Jun 21, 2012 8:53 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by rradojko »

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
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Enamul »

Hi

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

Sean Danaher
Posts: 13
Joined: Thu Oct 15, 2009 9:16 am
Contact:

Re: Measurement of temperature and relative humidity using D

Post by Sean Danaher »

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

Post by jaquy »

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)

Post Reply