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

Oderlando
Posts: 25
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby Oderlando » Wed Nov 21, 2018 11:01 am

Hi mnf. In the proteus simulator this flowchart is not working. Nothing appears on the display. I used GetHumidityWole, as you said. I simulated the proteus and also did not show the humidity reading. The difference is that now the display lights, but only shows a zero value. I'm posting the flowchart
Attachments
Humidity_Control.JPG
Humidity_Control.JPG (145.13 KiB) Viewed 2444 times
Controle_Umidade3.fcfx
(10.93 KiB) Downloaded 39 times

mnf
Valued Contributor
Valued Contributor
Posts: 493
Joined: Wed May 31, 2017 11:57 am
Has thanked: 52 times
Been thanked: 278 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby mnf » Wed Nov 21, 2018 12:32 pm

Hi,

Not sure about in Proteus - it works in Flowcode simulation.

Can you look at what SampleSensor returns in the simulation - maybe it is never reading the humidity. As a test - set Humidity = 67 (pick a value) at the start of your program - if this is displayed then GetHumidityWhole is never been called - if it changes to 0 then GetHumidityWhole is always returning 0 in simulation.

Martin

Oderlando
Posts: 25
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby Oderlando » Wed Nov 21, 2018 8:43 pm

Hi mnf. I tested your code and the display remained off. I could not determine why. I made some modifications to the flowchart that I had posted earlier. I used GetHumidityWole, as you said, and got the flowcode simulation to work. When I tested the proteus, the display shows something, but only shows a zero value. I can not understand why this is happening. I am posting the flowchart that I tested.
Attachments
Controle_Umidade.fcfx
(10.93 KiB) Downloaded 34 times

Oderlando
Posts: 25
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby Oderlando » Wed Nov 21, 2018 8:50 pm

You were right. GetHumidityWole is not being called. Insert a value for moisture at the beginning of the program and it is appearing in the simulation. Any suggestions on what might be happening?

claudemir
Posts: 45
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 11 times
Been thanked: 4 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby claudemir » Tue Dec 04, 2018 12:14 am

Hello
I am having a very similar problem with DHT22, I am mounting a project with DHT22 next to PIC18F4620, where I can only get the checksum error response, in the simulation it works normally, I have another project with the mega 2560 and it runs perfectly on the hardware, but it does not I'm not sure if it will work with pic16f, I've switched the oscillator from 10MHZ to 16 and 20Mhz, I put delay, but nothing works with correct information like temperature and humidity, if you have someone to help me put it to work or inform if it works with PIC18f4620, because I did not understand what is wrong with my project.
In the attachment I have a small project to test, but the official project uses the TMR0, but I believe that it is not the one that is disturbing because in this attachment the DHT22 does not work either.
Attachments
dht22.fcfx
(13.37 KiB) Downloaded 37 times

claudemir
Posts: 45
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 11 times
Been thanked: 4 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby claudemir » Tue Dec 04, 2018 9:48 pm

Hello
Today I made a few attempts with the DHT22 with my Pic18f4620, I switched the external oscillator to 4MHZ, but it still does not work, anyhow the DHT22 in the mega arduino 2560 works, but in PIC18F it does not want to work, I always get a checksum error, that's it. I believe that the DHT22 does not work with the pic18f, Personal that sees this component, so that I can use with the PIC18F4620

User avatar
Benj
Matrix Staff
Posts: 14142
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4329 times
Been thanked: 4075 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby Benj » Wed Dec 05, 2018 10:58 am

Hello,

I am mounting a project with DHT22 next to PIC18F4620, where I can only get the checksum error response


Looks like clock speed is your issue. You have set the project options clock speed to 10MHz but in the configuration you are using HS-PLL which will take the input crystal frequency and attempt to multiply it by 4 which probably won't work on the 4620. That is unless you're using a 2.5MHz crystal.

See here for help getting the clock speed correct, Once you have done this hopefully DHT22 should work correctly for you.
https://www.matrixtsl.com/wiki/index.ph ... ED_flasher
These users thanked the author Benj for the post:
claudemir (Wed Dec 05, 2018 3:11 pm)
Rating: 5.56%
 

claudemir
Posts: 45
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 11 times
Been thanked: 4 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby claudemir » Wed Dec 05, 2018 3:10 pm

Thanks for the reply Benj
I already changed the oscillator to 4MHz and set the oscillator to HS and XT. I put a delay of 5 seconds before the "SampleSensor" but none of it solved, the lowest oscillator I have is 4MHz, but I have an aggravation, I use a glcd in the original design and has many variables being updated in glcd, so the oscillator can not be too low, plus I can not give up watching the DHT22 work.
Attachments
dht22.fcfx
(13.36 KiB) Downloaded 31 times

User avatar
Benj
Matrix Staff
Posts: 14142
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4329 times
Been thanked: 4075 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby Benj » Wed Dec 05, 2018 5:56 pm

Hello,

Have you tried the 1 second flasher test to confirm you have set the chip up correctly and you are running at the speed you think you are. If this isn't working then delays in general will be out and therefore anything timing related e.g. the DHT component will not work correctly.

Also 4MHz might be too slow for the uS delays to be accurate. Might be worth trying the 4MHz crystal with the x4 PLL to give you 16MHz, again confirming using the 1 second flash test.
These users thanked the author Benj for the post:
claudemir (Sun Dec 09, 2018 12:45 am)
Rating: 5.56%
 

claudemir
Posts: 45
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 11 times
Been thanked: 4 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby claudemir » Thu Dec 06, 2018 9:24 pm

Hello benj
I'm sorry for the delay in responding, but I ended up taking a trip to meet a client and I did not have any way to verify the settings, but as soon as I return from the trip I will continue with my project and keep informed of the changes.
These users thanked the author claudemir for the post:
Benj (Thu Dec 06, 2018 9:41 pm)
Rating: 5.56%
 

Oderlando
Posts: 25
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby Oderlando » Fri Dec 07, 2018 10:03 pm

I also had problems, but using a DHT Sensor. Only later did I find out that I was using crystals of very low speed (4 and 8 MHz). My problem was solved with a higher speed crystal (20MHz).
These users thanked the author Oderlando for the post:
claudemir (Sun Dec 09, 2018 12:45 am)
Rating: 5.56%
 

claudemir
Posts: 45
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 11 times
Been thanked: 4 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby claudemir » Sun Dec 09, 2018 12:45 am

Good night Benj.
I came back from a trip today, and I had the pleasure of seeing the DHT22 working, the only way the sensor worked was to leave the 4MHz crystal and configure the x4 PLL to give 16MHz, I put a 16MHz crystal and I configured it with HS, but this way the sensor does not work, I returned the crystal of 4MHz and x4 PLL.
I also used the Oderlando tip of a 20MHz crystal but it also does not work, the microprocessor speed running at 16MHz is not enough to operate glcd, because it has many variables to update at all times, but I will have to relocate and adapt my software to be able to use the DHT22 being the heart of the control.
Thanks for the tips

benchhida
Posts: 4
Joined: Mon Feb 06, 2017 10:19 am
Has thanked: 1 time
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby benchhida » Sat Jun 01, 2019 9:58 am

Please have a little help.I have question

(20.0 MHz, the TMR0 increments by 1 in every 0.8 μs (prescaler 1:4)).
without a prescaler =4 in the instruction
st_bit(intcon, TMR0IE);
tmr0=0x00;

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8330
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2381 times
Been thanked: 3393 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby medelec35 » Sat Jun 01, 2019 10:28 am

benchhida wrote:Please have a little help.I have question

(20.0 MHz, the TMR0 increments by 1 in every 0.8 μs (prescaler 1:4)).
without a prescaler =4 in the instruction
st_bit(intcon, TMR0IE);
tmr0=0x00;

What has this got to do with Re: Measurement of temperature and relative humidity using DHT11.
Not sure what you are asking?
Please do not make public your personal email address.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

benchhida
Posts: 4
Joined: Mon Feb 06, 2017 10:19 am
Has thanked: 1 time
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby benchhida » Sat Jun 01, 2019 4:17 pm

I do not understand there is not in the program an instriction which defines the prescaler 1/4
thank you
st_bit (intcon, TMR0IE);

benchhida
Posts: 4
Joined: Mon Feb 06, 2017 10:19 am
Has thanked: 1 time
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Postby benchhida » Mon Jun 03, 2019 11:45 am

Attachments
111.jpg
111.jpg (61.73 KiB) Viewed 909 times