DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
Moderator: Benj
-
- Posts: 10
- Joined: Fri Nov 09, 2018 9:16 pm
- Has thanked: 1 time
DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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 343 times
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
Hi!
you wrote that the sensor is connected to A0, but in your program you set it at A1
Could be.
And you have a string ""Weerstation v2" after that there is no space to show the temp.
Br
Jorgen
you wrote that the sensor is connected to A0, but in your program you set it at A1

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

Br
Jorgen
-
- Posts: 10
- Joined: Fri Nov 09, 2018 9:16 pm
- Has thanked: 1 time
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
-
- Posts: 444
- Joined: Tue Apr 15, 2014 4:19 pm
- Location: Kajaani, Finland
- Has thanked: 345 times
- Been thanked: 227 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
Do you have the +5V pullup resistor in place on the data pin of DHT11? Cant read, haha 
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?

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!
-
- Posts: 10
- Joined: Fri Nov 09, 2018 9:16 pm
- Has thanked: 1 time
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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
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

-
- Posts: 56
- Joined: Mon Aug 11, 2014 3:57 pm
- Has thanked: 18 times
- Been thanked: 17 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
- 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: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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
Br Jorgen
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

Br Jorgen
- 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: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
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.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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 56
- Joined: Mon Aug 11, 2014 3:57 pm
- Has thanked: 18 times
- Been thanked: 17 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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
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
- 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: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 56
- Joined: Mon Aug 11, 2014 3:57 pm
- Has thanked: 18 times
- Been thanked: 17 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
- 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: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 56
- Joined: Mon Aug 11, 2014 3:57 pm
- Has thanked: 18 times
- Been thanked: 17 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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
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
-
- Posts: 9
- Joined: Tue Jun 11, 2019 8:09 am
- Been thanked: 6 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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
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 228 times
- 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: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.ph ... ED_flasher
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.ph ... ED_flasher
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 9
- Joined: Tue Jun 11, 2019 8:09 am
- Been thanked: 6 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
Hi, still no luck, crc error, are we missing something?
- Attachments
-
- DHT 22 OSCCON.fcfx
- (13.69 KiB) Downloaded 209 times
- 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: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 9
- Joined: Tue Jun 11, 2019 8:09 am
- Been thanked: 6 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
Hi Benj, still no luck, moving to another PIC selection with faster 20MHz external xtal oscillator, will update soon, thanks
-
- Posts: 9
- Joined: Tue Jun 11, 2019 8:09 am
- Been thanked: 6 times
Re: DHT11 not measuring, SampleSensor stays '1' and show no reply on LCD
Hi Benj, ok 20Mhz external oscillator with PIC 18F4520 working 100%, many thanks 
