cancel
Showing results for 
Search instead for 
Did you mean: 

has anyone try to DHT11 or DHT22 with stm32f7 or stm32H7?

M abouhasem
Associate II
 
18 REPLIES 18
M abouhasem
Associate II

the same code worked fine with same sensor with both f4 and f0 MCUs as per datasheets its mandatory requirement to pullup and wait

0693W000007ZscSQAS.jpg

"the same code worked fine with same sensor with both f4 and f0 MCUs"

So, again, compare what happens with your working code against what happens with your non-working code - that will show you where it's going wrong.

"its mandatory requirement to pullup"

Did you read my previous reply?

"Pullup" means that you let the pullup resistor do the pulling - you do not want the controller to actively drive high.

It's exactly the same principle as used for I2C: the drivers only ever pull down - it's the pullup resistors which do the pulling up.

That's why you see the rounded rising edges:

0693W000007ZswqQAC.png 

Hello Andrew.

You have resolved a question that was giving me headaches. I was wondering after this, why this code wasn't working for me. I have this board and it already has installed a pull-up resistor. But the guy from controllerstech, was using the sensor without the board, so no pull-up is included. He actively set pin high, with HAL_GPIO_WRITE_PIN() function. But in my case, my datasheet shows a rounded edge as you mentioned. 

I had no idea this could affect, could you please tell me where to read more about this? Maybe I have to know something about electronics?

Thanks in advance.


@pablo1409 wrote:

could you please tell me where to read more about this? 


About what, exactly?

 


@pablo1409 wrote:

Maybe I have to know something about electronics?


Yes, you do: this is an electronic issue about what happens with the voltages & currents on the physical wire

 

Hello again, I forgot to write the answer

 

@Andrew Neil wrote:

@pablo1409 wrote:

could you please tell me where to read more about this? 


About what, exactly?

 


I mean, in the datasheet you knew that a rounded edge represents that this pin have to be activated with a pullp/up resistor, how do you know that? Electronics sounds to me like a big field, could you please be more speciffic about the branch, maybe digital electronics?


@pablo1409 wrote:

you knew that a rounded edge represents that this pin have to be activated with a pullp/up resistor, how do you know that? 


That's characteristic of a capacitor being charged through a resistor:

 

AndrewNeil_2-1712757385386.png

https://www.webassign.net/question_assets/ncsulcpem2/lab_4/manual.html

 

In this case, the "capacitor" is the capacitance of the cable, PCB trace, etc; and the resistor is the pullup.

 


@pablo1409 wrote:

Electronics sounds to me like a big field, could you please be more speciffic about the branch, maybe digital electronics?




Yes, it is.

The basics are all analogue - the world is analogue - digital electronics is just a specialisation of that.

Here's some good basic electronics info:

https://electronicsclub.info/capacitors.htm 

 

#BasicElectronics

Thanks for the reply

One last question. I had a hard time finding this problem about resistors. I would like you to tell me what the basics are that I need to know, so that when a similar problem arises, I can go to them to solve it, and not find myself so lost without knowing where to go until I find the answer by chance. I don't know if I explain myself.
My intention is for you to tell me: Pablo, you need to learn x, y, and z, before starting to do embedded systems projects, because otherwise it will be very difficult for you to solve basic problems like this

You need to understand voltage, current, resistance, capacitance, etc.

There are plenty of books and online resources, courses, etc.

One pretty much at random from a search for "basic electronics":

https://www.open.edu/openlearn/science-maths-technology/an-introduction-electronics/content-section-0?active-tab=description-tab

You're not going to do this overnight; if it were a class in school (so along with other subjects) you'd probably be looking at 2 years.

 


@pablo1409 wrote:

otherwise it will be very difficult for you to solve basic problems like this


I guess that depends on what you mean by "basic" problems.

Developing an interface like this from first principles is not really a beginner problem - perhaps you would be better looking at Arduino (or similar). At least, that would allow you to be getting some software stuff done while you're learning the hardware stuff ...

 


@pablo1409 wrote:

otherwise it will be very difficult for you to solve basic problems like this


I guess that depends on what you mean by "basic" problems.

Developing an interface like this from first principles is not really a beginner problem - perhaps you would be better looking at Arduino (or similar). At least, that would allow you to be getting some software stuff done while you're learning the hardware stuff ...


In this case, with "basic" I mean being able to read data from a sensor that uses a simple protocol such as 1-wire, perhaps the Arduino thing is not a bad idea, to be able to focus on those hardware details that maybe on boards like the stm32 are taken for granted. I chose the stm32 because everyone said that if you wanted to learn at a low level, at a register level, bare-metal, etc., you better avoid Arduino. I have a background in programming, I know about system architecture, etc., it may not be difficult for me to assimilate these new electronic concepts, but I do see a good idea in isolating them, since in the stm32 the complexities are different, since these electronic fundamentals are perhaps taken for granted. The bad thing is that on Arduino it is difficult to find bare-metal code, for example when I searched about this sensor, most of the code was something like:
dht11.getTemperature()

And what interests me is being able to read the datasheet of both the sensor and the mcu, and write my own library (I know that there are cases such as bluetooth and wifi that this option is almost unthinkable, but for simpler communication protocols, I think it is good for me to develop that deep thinking about how things really happen under the hood)