Page 1 of 1

Problem in reading the DHT11 sensor

Posted: Fri Nov 23, 2018 12:11 pm
by Oderlando
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.

Re: Problem in reading the DHT11 sensor

Posted: Fri Nov 23, 2018 12:39 pm
by Benj
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?

Re: Problem in reading the DHT11 sensor

Posted: Fri Nov 23, 2018 12:56 pm
by Oderlando
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

Re: Problem in reading the DHT11 sensor

Posted: Fri Nov 23, 2018 12:57 pm
by Oderlando
I am using version 7 of FlowCode

Re: Problem in reading the DHT11 sensor

Posted: Fri Nov 23, 2018 6:32 pm
by Benj
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.

Re: Problem in reading the DHT11 sensor

Posted: Sun Nov 25, 2018 8:44 pm
by Oderlando
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.

Re: Problem in reading the DHT11 sensor

Posted: Sun Nov 25, 2018 9:18 pm
by mnf
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..
dht11.fcfx
(11.45 KiB) Downloaded 359 times
Gives me:
Temp = 19.0
Humidity = 65.0
Sample = 0
Temp = 19.0
Humidity = 65.0
Sample = 0
(I'm using 'putty' as a terminal program)

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 :-( )

Re: Problem in reading the DHT11 sensor

Posted: Sun Nov 25, 2018 9:28 pm
by mnf
& a jumperless version:
PB250030.jpg
PB250030.jpg (191.67 KiB) Viewed 9434 times
This with the DHT11 pins at D4-D6 of the Arduino.
dht11.fcfx
(11.45 KiB) Downloaded 327 times
Modified for D4 as data D5 as VCC and D6 as Gnd

Martin

Re: Problem in reading the DHT11 sensor

Posted: Mon Nov 26, 2018 10:36 pm
by Oderlando
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.

Re: Problem in reading the DHT11 sensor

Posted: Mon Nov 26, 2018 11:55 pm
by mnf
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....
DHT11_Modified.fcfx
(31.88 KiB) Downloaded 310 times
Martin

Re: Problem in reading the DHT11 sensor

Posted: Tue Nov 27, 2018 1:26 am
by Oderlando
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 :(

Re: Problem in reading the DHT11 sensor

Posted: Tue Nov 27, 2018 11:12 am
by Benj
Hello,

Using your DHT11_16F88 program I get this error being generated by the compiler.
DHT11_16F88.c: 262: (1089) recursive function call to "_FCM_InitDat"
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.
it ended up becoming even more complicated to follow this path
I can see why, here is a potential call chain.

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.

Re: Problem in reading the DHT11 sensor

Posted: Thu Nov 29, 2018 6:28 pm
by Oderlando
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.