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

Post by Oderlando »

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.12 KiB) Viewed 10034 times
Controle_Umidade3.fcfx
(10.93 KiB) Downloaded 297 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Post by mnf »

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

Post by Oderlando »

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

Oderlando
Posts: 37
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

Post by Oderlando »

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: 58
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Post by claudemir »

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

claudemir
Posts: 58
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Post by claudemir »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Post by Benj »

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

claudemir
Posts: 58
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Post by claudemir »

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

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

Re: Measurement of temperature and relative humidity using DHT11

Post by Benj »

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.

claudemir
Posts: 58
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Post by claudemir »

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.

Oderlando
Posts: 37
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

Post by Oderlando »

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).

claudemir
Posts: 58
Joined: Sat Nov 03, 2012 7:43 am
Has thanked: 12 times
Been thanked: 5 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Post by claudemir »

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

Re: Measurement of temperature and relative humidity using DHT11

Post by benchhida »

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;

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Measurement of temperature and relative humidity using DHT11

Post by medelec35 »

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

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

Re: Measurement of temperature and relative humidity using DHT11

Post by benchhida »

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

Re: Measurement of temperature and relative humidity using DHT11

Post by benchhida »

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

Post Reply