Measurement of temperature and relative humidity using DHT11
- 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
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.
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 772 times
-
- Posts: 40
- 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
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
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
- 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
Figure 8 calculation box..
After completing the code you can post..I will check that for you
Code: Select all
RH_Byte1 = RH_Byte1 | (1 << (7 - i))
I can't see any problem in picture 12 & 13Picture number 12 and 13 can not see everything.
That should be..st_bit(intcon, TMR0|E);
tmr0=0x00;
Code: Select all
st_bit(intcon, TMR0IE);
tmr0=0x00;
-
- Posts: 40
- 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
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
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 (26.42 KiB) Viewed 22223 times
- 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
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.
It is same as last c code I posted only RH_Byte2 is in place of RH_Byte1.One more question.My mistake, picture number 12 and 13 is OK.I have a question for Figure 10, calculation box. Missing C code.
Code: Select all
RH_Byte2 = RH_Byte2 | (1 << (7 - i))
-
- Posts: 40
- 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
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
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 563 times
- 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
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?
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 539 times
-
- Posts: 40
- 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
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
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
- 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
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.
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.
-
- Posts: 40
- 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
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
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
- 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
I am confused..did you mean you understand my explanation or not?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.
-
- Posts: 40
- 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
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
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
- 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
Hi
You can follow this link..I have explained there
http://www.matrixmultimedia.com/mmforum ... 46&t=11641
You can follow this link..I have explained there
http://www.matrixmultimedia.com/mmforum ... 46&t=11641
-
- Posts: 40
- 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
Thank you very much. Very good explanation.
I understand now.
Good luck!
RR
I understand now.
Good luck!
RR
-
- 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
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
I want to know if I can show humidity and temperature on 7 segment ?
I think It must be converted to bcd form
Thanks
- 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
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.
-
- 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
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
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
- 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
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
-
- Posts: 40
- 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
Hello.
It's me again .
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
It's me again .
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 404 times
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
- Contact:
Re: Measurement of temperature and relative humidity using D
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
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.
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
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 !
-
- 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
Hello enamul sir
could you please write the algorithm of the program "DHT11v1.01.fcf" for the beginners.
belayat
could you please write the algorithm of the program "DHT11v1.01.fcf" for the beginners.
belayat
-
- Posts: 40
- 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
Hello,belayat wrote:Hello enamul sir
could you please write the algorithm of the program "DHT11v1.01.fcf" for the beginners.
belayat
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
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
-
- 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
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
Happy to post more details if anyone is intereted
Sean
Re: Measurement of temperature and relative humidity using D
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)
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)