Problem in reading the DHT11 sensor
-
- Posts: 37
- Joined: Tue Jul 17, 2018 11:30 am
- Has thanked: 7 times
- Been thanked: 3 times
- Contact:
Problem in reading the DHT11 sensor
Hi. I set up my flowchart to show the humidity values, read by a DHT11 sensor, to be shown on a 7-digit 4-digit display. Flowcode simulation works, but does not work on Proteus. The proteus shows the display with a zero value. I noticed that for some reason the sensor is not being read because the variable "SampleSensor" returns a value of 1. Can anyone identify the error here? I've exhausted my possibilities and I've been thinking about it for days.
- Attachments
-
- Controle_Umidade.fcfx
- (13.42 KiB) Downloaded 271 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: Problem in reading the DHT11 sensor
Hello,
Is the Proteus simulation of the DHT11 sensor known to work well?
I would test on actual hardware if you can to rule out any potential problems with the Proteus software.
Which version of Flowcode are you using? Can you post your project file so we can see if your maybe doing anything incorrectly?
Is the Proteus simulation of the DHT11 sensor known to work well?
I would test on actual hardware if you can to rule out any potential problems with the Proteus software.
Which version of Flowcode are you using? Can you post your project file so we can see if your maybe doing anything incorrectly?
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: 37
- Joined: Tue Jul 17, 2018 11:30 am
- Has thanked: 7 times
- Been thanked: 3 times
- Contact:
Re: Problem in reading the DHT11 sensor
I used this same hardware to simulate the proteus for reading an ADC and it worked perfectly. I do not think it's a proteus problem. The problem only arises when I try to read the DHT11 sensor. I'm sending the zipped proteus file. proteus showed no problems emulating DTH11 with another code
- Attachments
-
- Controlador_Umidade.zip
- (16.65 KiB) Downloaded 306 times
Last edited by Oderlando on Fri Nov 23, 2018 1:00 pm, edited 1 time in total.
- 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: Problem in reading the DHT11 sensor
Hello,
v7 of Flowcode is known to work well with the DHT11, it could be that our code and the proteus code is just not getting on but in real life the code works fine with the sensor so this sounds like a Proteus problem to me.
I don't have access to the Proteus simulator so I cant try and replicate the problem here.
I suggest you rig up a real world micro with the DHT11 and see how you get on. Simulation is great but I wouldn't rely on it 100%.
Now if you tell me the real world code isn't working then that is something I can investigate for you.
v7 of Flowcode is known to work well with the DHT11, it could be that our code and the proteus code is just not getting on but in real life the code works fine with the sensor so this sounds like a Proteus problem to me.
I don't have access to the Proteus simulator so I cant try and replicate the problem here.
I suggest you rig up a real world micro with the DHT11 and see how you get on. Simulation is great but I wouldn't rely on it 100%.
Now if you tell me the real world code isn't working then that is something I can investigate for you.
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: 37
- Joined: Tue Jul 17, 2018 11:30 am
- Has thanked: 7 times
- Been thanked: 3 times
- Contact:
Re: Problem in reading the DHT11 sensor
Hi, Benj. I mounted the circuit according to the proteus simulation and recorded the microcontroller with the HEX file generated by FlowCode and the result of the circuit was the same as the one emulated by the proteus: the DHT11 sensor returns with value 1 (error). The value that was shown in the display was the one that was emulated by the proteus. I am sending the Flowcode flowchart and circuit diagram to the attached proteus. I hope you can help me. Thank you.
- Attachments
-
- FlowCode_Error.zip
- (19.58 KiB) Downloaded 251 times
Last edited by Oderlando on Sun Nov 25, 2018 9:27 pm, edited 1 time in total.
-
- Valued Contributor
- Posts: 1191
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Problem in reading the DHT11 sensor
Hi Oderlando,
Try - the following code. I have it working here with a DHT11 sensor and it works AOK.
A couple of things - don't have the output in an interrupt routine. Interrupts are best kept as short as possible, not really the place for outputting to a display.
The DHT11 sensor is fairly slow - I've used a two second delay between readings.
I've output data to the UART - I don't have the same display as you..
Gives me:
Martin
Note - also that I use MCU pins to power the DHT11 - I never like jumper wires? - but the board I have has data at the 's' end, VCC as the centre pin and GND as the third pin - and I'd wired the DHT11 incorrectly in the first instance - so here the pins don't tally (and I had to use jumpers )
Try - the following code. I have it working here with a DHT11 sensor and it works AOK.
A couple of things - don't have the output in an interrupt routine. Interrupts are best kept as short as possible, not really the place for outputting to a display.
The DHT11 sensor is fairly slow - I've used a two second delay between readings.
I've output data to the UART - I don't have the same display as you..
Gives me:
(I'm using 'putty' as a terminal program)Temp = 19.0
Humidity = 65.0
Sample = 0
Temp = 19.0
Humidity = 65.0
Sample = 0
Martin
Note - also that I use MCU pins to power the DHT11 - I never like jumper wires? - but the board I have has data at the 's' end, VCC as the centre pin and GND as the third pin - and I'd wired the DHT11 incorrectly in the first instance - so here the pins don't tally (and I had to use jumpers )
-
- Valued Contributor
- Posts: 1191
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Problem in reading the DHT11 sensor
& a jumperless version:
This with the DHT11 pins at D4-D6 of the Arduino. Modified for D4 as data D5 as VCC and D6 as Gnd
Martin
This with the DHT11 pins at D4-D6 of the Arduino. Modified for D4 as data D5 as VCC and D6 as Gnd
Martin
-
- Posts: 37
- Joined: Tue Jul 17, 2018 11:30 am
- Has thanked: 7 times
- Been thanked: 3 times
- Contact:
Re: Problem in reading the DHT11 sensor
Hi ! I have a flow chart for the Atmega8. It worked well on proteus simulation. Probably works well in real life. I'm sending the flowchart and proteus file. I tried to modify the flowchart to work with PIC16F88 and I am not able to compile the file. Can you take a look at me? I could not identify the problem. I've been there a few days, but I've learned a lot so far. Thanks for all the help you have so far.
- Attachments
-
- Nova pasta (4).zip
- (25.86 KiB) Downloaded 238 times
-
- Valued Contributor
- Posts: 1191
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Problem in reading the DHT11 sensor
Hi Oderlando,
- what errors are you getting. I've modified the file slightly (take a look at PriemBitovSimplified - you can index into your array much more simply) - what are you trying to accomplish here? read of the dht11 by bit-banging port A5?? Did you get things to work using the DHT11 component?
Also - see the comments in VivoD/H - I'm not sure why you are writing the digits to the display repeatedly rather than just once followed by a delay.
Please could you add some comments on what each macro is trying to do, and we'll try and help some more....
Martin
- what errors are you getting. I've modified the file slightly (take a look at PriemBitovSimplified - you can index into your array much more simply) - what are you trying to accomplish here? read of the dht11 by bit-banging port A5?? Did you get things to work using the DHT11 component?
Also - see the comments in VivoD/H - I'm not sure why you are writing the digits to the display repeatedly rather than just once followed by a delay.
Please could you add some comments on what each macro is trying to do, and we'll try and help some more....
Martin
-
- Posts: 37
- Joined: Tue Jul 17, 2018 11:30 am
- Has thanked: 7 times
- Been thanked: 3 times
- Contact:
Re: Problem in reading the DHT11 sensor
I'm more lost than I imagined. I think I'll need some time to study FlowCode and then go back to doing projects I decided to use this diagram to read the DTH11 because the other diagram I sent here had a problem reading the sensor, but it ended up becoming even more complicated to follow this path.Can you take a look at the "FlowCode_Error" file and say what may be wrong? In Flowcode simulation it works fine but in real life the sensor is not read.I apologize for my lack of knowledge. I'll have to study a lot more
- 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: Problem in reading the DHT11 sensor
Hello,
Using your DHT11_16F88 program I get this error being generated by the compiler.
Main -> InitDat -> PriemBitov -> ProverkaCRC -> InitDat -> ....
So there is a recursive loop going on which needs to be resolved.
Ideally to keep things easy to follow and straightforward you should always return back to Main and avoid functions calling functions calling functions unless this helps the overall program flow. Move as many of the function calls as you can into Main and this will free up stack giving you more usable RAM.
Start off simple with the basics, test on the hardware as you're going and add to the functionality as you get things working. This is the best way to achieve the end goal in a timely manner.
Using your DHT11_16F88 program I get this error being generated by the compiler.
This basically means you have called a function which ends up calling itself and at a certain point you will run out of stack and the program will crash and become unpredictable or the microcontroller will reset.DHT11_16F88.c: 262: (1089) recursive function call to "_FCM_InitDat"
I can see why, here is a potential call chain.it ended up becoming even more complicated to follow this path
Main -> InitDat -> PriemBitov -> ProverkaCRC -> InitDat -> ....
So there is a recursive loop going on which needs to be resolved.
Ideally to keep things easy to follow and straightforward you should always return back to Main and avoid functions calling functions calling functions unless this helps the overall program flow. Move as many of the function calls as you can into Main and this will free up stack giving you more usable RAM.
Start off simple with the basics, test on the hardware as you're going and add to the functionality as you get things working. This is the best way to achieve the end goal in a timely manner.
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: 37
- Joined: Tue Jul 17, 2018 11:30 am
- Has thanked: 7 times
- Been thanked: 3 times
- Contact:
Re: Problem in reading the DHT11 sensor
Thank you all for the help and support you have given me. I will continue the studies with the flowcode and gradually evolve with it. Thank you.