DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Thibault666
Posts: 10
Joined: Fri Nov 09, 2018 9:16 pm
Has thanked: 1 time
Contact:

DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Thibault666 » Wed Mar 27, 2019 9:08 am

Our DHT11 is not measuring anything, we used the example code and only changed the LCD display component macro.
The SampleSensor keeps returning a '1' which resulsts in "No Reply" on the I2C LCD. We are using a PIC16F887 and the DHT11 is connected to the A0 pin.
If anyone could take a look at our program or give us any suggestion we will be very thankful.
Attachments
LCD+DHT11.fcfx
(12.86 KiB) Downloaded 52 times

jgu1
Posts: 1139
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1053 times
Been thanked: 280 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby jgu1 » Wed Mar 27, 2019 6:15 pm

Hi!
you wrote that the sensor is connected to A0, but in your program you set it at A1 :D Could be.

And you have a string ""Weerstation v2" after that there is no space to show the temp. :wink:

Br

Jorgen

Thibault666
Posts: 10
Joined: Fri Nov 09, 2018 9:16 pm
Has thanked: 1 time
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Thibault666 » Thu Mar 28, 2019 1:36 pm

Hi jgu1,

I'm sorry my fault! We tried some other pins but when when changed back to A0 we still measure no temperature or humidity. SampleSensor never gives a '0' and that's why the program never goes in the first loop. Why does it stay '1', (" No reply") on the display. We used a 4.7KOhm resistor and we tried a 10KOhm resistor, but still no difference.

EtsDriver
Valued Contributor
Valued Contributor
Posts: 431
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 346 times
Been thanked: 224 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby EtsDriver » Thu Mar 28, 2019 3:16 pm

Do you have the +5V pullup resistor in place on the data pin of DHT11? Cant read, haha :D

Have you tried using one of the digital pins, and printing to serial terminal directly? Some cloned boards have some kind of shielding resistors/fuses in series with the analogue pins. Does your arduino run at 16MHz?
Ill just keep the good work up!

Thibault666
Posts: 10
Joined: Fri Nov 09, 2018 9:16 pm
Has thanked: 1 time
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Thibault666 » Sat Apr 13, 2019 12:30 pm

Hi Etsdriver,

Yes we have a pull-up resistor but we haven't tried to use a digital pin. We will try that next week!

Thanks for your reply :D

gonzogonzo
Posts: 51
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 17 times
Been thanked: 16 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby gonzogonzo » Mon Apr 15, 2019 2:38 pm

Hello,

In my experience with Flowcode there is a problem with DHT11 and DHT22: the operation is ok only with high clock frequencies (32MHz or higher). This problem is evident with the free version of the XC8 compiler as artificial delays are introduced that make it impossible to read the data correctly from the sensors at lower frequencies, while it is less evident with the PRO version of XC8 (the operation is ok starting from from 20 MHz clock). However, there is something strange in the DHT11 and DHT22 component because with the same circuit (8MHz and lower clock) and program written with CCS C compiler it is fully functional.
You can test this using a other Pic with 32MHz (or more) clock and You can see working ok.

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

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Benj » Mon Apr 15, 2019 4:51 pm

Hello,

Let me have another look at the component code. I may be able to increase the success on the slower 8-bit PIC devices using the free XC8 compiler.

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

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Benj » Mon Apr 15, 2019 5:16 pm

Right I've now had a go and hopefully improved things a bit just for the 8-bit PIC devices.

I don't want to push this as a public fix just yet so for now you will have to manually copy the file into your "C:\ProgramData\MatrixTSL\FlowcodeV8\Components" folder and restart Flowcode.

DHT11.fcpx
(36.41 KiB) Downloaded 42 times


Let me know how you get on and I'll try and remember to bring a DHT11 into the office tomorrow. If this works well then I will also apply the workarounds to the DHT22 sensor components.
These users thanked the author Benj for the post (total 2):
jgu1 (Mon Apr 15, 2019 7:50 pm) • chipfryer27 (Tue Apr 16, 2019 7:50 am)
Rating: 10%
 

jgu1
Posts: 1139
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1053 times
Been thanked: 280 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby jgu1 » Mon Apr 15, 2019 7:50 pm

Hi Ben!

I have used the DHT 22 in several project with Arduino, working perfect. If you make some correction, hopefully it will not have affect
in the Arduino devices :wink:

Br Jorgen

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

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Benj » Tue Apr 16, 2019 10:38 am

Hello,

Right with the DHT11 I have made a few more 8-bit PIC only changes and have the component confirmed working now at 8MHz and 32MHz. I'm using the pro compiler here and can't seem to find a way to switch it off so interesting to see how this runs on the free version. I've now pushed the component to the update system so let me know how you get on if you have a go.

I have used the DHT 22 in several project with Arduino, working perfect. If you make some correction, hopefully it will not have affect
in the Arduino devices :wink:


If it works better then I will apply a similar mod to the DHT22, no this shouldn't effect anything other than 8-bit PICs.
These users thanked the author Benj for the post:
jgu1 (Tue Apr 16, 2019 12:31 pm)
Rating: 5%
 

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

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Benj » Tue Apr 16, 2019 4:59 pm

Right I have found more issues using the free compiler.

I have now made more changes and tested the latest component with the following clock frequencies on 8-bit PIC devices.

8MHz
12MHz
16MHz
32MHz

All are now working great for me.

I tried but can't get the code running at 4MHz so looks like 8MHz is currently the lower limit on 8-bit PIC for the DHT11.
These users thanked the author Benj for the post:
chipfryer27 (Tue Apr 16, 2019 5:06 pm)
Rating: 5%
 

gonzogonzo
Posts: 51
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 17 times
Been thanked: 16 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby gonzogonzo » Wed Apr 17, 2019 1:48 pm

Hi Benj,

after a quick test for me DHT22 NOT working if clock under 32MHz now also in PRO version XC8 (before working in PRO with 20MHz).

Thanks

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

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Benj » Wed Apr 17, 2019 3:05 pm

Hello,

I haven't yet touched the DHT22 component, no major changes for approx 9 months. I'll have a look at this either tomorrow or next week and see if I can replicate the results.

gonzogonzo
Posts: 51
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 17 times
Been thanked: 16 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby gonzogonzo » Wed Apr 17, 2019 3:44 pm

Hi Benj,

sorry but i have think that You have working also in DHT22 and not only DHT11 and my test are only for DHT22; in any case, for DHT22, there is a dipendence from compiler version and from PIC clock to see working or not DHT22.

Thank again for your patience and for my poor english.
These users thanked the author gonzogonzo for the post:
Benj (Thu Apr 18, 2019 9:52 am)
Rating: 5%
 

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

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Benj » Thu Apr 18, 2019 10:31 am

Hello,

I have now rolled out the DHT11 changes to the DHT22 component and the Grove DHT22 component.

I've also added some new properties to all the components to allow the clock adjustment to be manually controlled just in case it still has problems at certain clock speeds.

I've now pushed the changes to the update system, let me know how you get on.
These users thanked the author Benj for the post:
jgu1 (Thu Apr 18, 2019 12:44 pm)
Rating: 5%
 

gonzogonzo
Posts: 51
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 17 times
Been thanked: 16 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby gonzogonzo » Thu Apr 18, 2019 1:01 pm

Hello Benj,

after some short test i have DHT22 working with FREE compiler (2.X) and slower clock frequency at 11MHz (nops = 10); with PRO compiler (1.4x) working with slower frequency at 10MHz (nops= 24).
Interesting option nops but i think that some delay_us at slower frequency are not possible with XC8 compiler...

Thanks
These users thanked the author gonzogonzo for the post:
Benj (Thu Apr 18, 2019 1:25 pm)
Rating: 5%
 

Smartmultienergy
Posts: 9
Joined: Tue Jun 11, 2019 8:09 am
Been thanked: 6 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Smartmultienergy » Tue Jun 11, 2019 8:52 am

Hello Benj

I am having trouble with the DHT11 and DHT22. I am also having trouble with the clock speeds. Ive read through all the forums and tried changing the clock speed. I am using a 16F887 PIC which has a internal 20 MHz oscillator/clock input. If I change the clock speed to 8MHz it give me a "Checksum error" and if I change the clock 20 MHz then it gives me "no communication detected". Please help.....

I have attached my program
Attachments
DHT 22 After Update.fcfx
(13.52 KiB) Downloaded 17 times

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

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Benj » Tue Jun 11, 2019 10:59 am

Hello,

The 16F887 has an internal oscillator but the default speed is 4MHz and the fastest speed is 8MHz.

Use the IntOsc helper component to help you configure it for 8MHz using a C icon at the start of main and then set the project options speed to match.

To double check oscillator speed you can use the 1 second flasher technique.
https://www.matrixtsl.com/wiki/index.php?title=One_second_LED_flasher

Smartmultienergy
Posts: 9
Joined: Tue Jun 11, 2019 8:09 am
Been thanked: 6 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Smartmultienergy » Tue Jun 11, 2019 1:21 pm

Hi, still no luck, crc error, are we missing something?
Attachments
DHT 22 OSCCON.fcfx
(13.69 KiB) Downloaded 14 times

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

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Benj » Tue Jun 11, 2019 4:59 pm

8MHz is still quite low in terms of clock speed.

So to try and achieve the tight timings, in the DHT22 component properties try changing the Clock Adjustment setting from Auto to Manual.

Next try decrementing the 28us Nops property a couple of counts at a time and compiling to the target device. Hopefully it should start working correctly at a certain value. e.g. try 22, then 20, then 18 etc.

Once it's working correctly it should be stable to carry on working reliably.

Smartmultienergy
Posts: 9
Joined: Tue Jun 11, 2019 8:09 am
Been thanked: 6 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Smartmultienergy » Thu Jun 13, 2019 9:58 am

Hi Benj, still no luck, moving to another PIC selection with faster 20MHz external xtal oscillator, will update soon, thanks
These users thanked the author Smartmultienergy for the post:
Benj (Fri Jun 14, 2019 3:52 pm)
Rating: 5%
 

Smartmultienergy
Posts: 9
Joined: Tue Jun 11, 2019 8:09 am
Been thanked: 6 times
Contact:

Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD

Postby Smartmultienergy » Mon Jun 17, 2019 10:54 am

Hi Benj, ok 20Mhz external oscillator with PIC 18F4520 working 100%, many thanks 8)
These users thanked the author Smartmultienergy for the post:
Benj (Mon Jun 17, 2019 3:48 pm)
Rating: 5%