cancel
Showing results for 
Search instead for 
Did you mean: 

built in pull up resistor

andrewg
Associate III

i'm thinking about interfacing DHT11 or DHT22 (AM2302)

https://www.mouser.com/datasheet/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf

https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf

a thing i noted about both of them requires a pull up resistor at the data line similar to i2c.

then in my google searches i noted this app note

AN4899 STM32 GPIO configuration for hardware settings and low-power consumption

https://www.st.com/resource/en/application_note/dm00315319-stm32-gpio-configuration-for-hardware-settings-and-lowpower-consumption-stmicroelectronics.pdf

mentions 3.3.1

The pull-up or pull-down resistors are activated depending on the value in the GPIOx_PUPDR register

but in rm0008 stm32f10x ref manual

https://www.st.com/resource/en/reference_manual/cd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

9.1 gpio functional descr figure 13, table 20

the pullup / pulldown resistor is specifically shown in the figure but the register mentioned in table 20 is given as PxODR

and GPIOx_PUPDR isn't present there.

hence i'd assume that this functionality is achieved in stm32f103 using

9.2.4 Port output data register (GPIOx_ODR) (x=A..G) mentioned in rm0008 ?

it is a little surprising as 9.2.4 GPIOx_ODR is deemed an output register to set the gpio output and in addition it isn't literally clear if in the case of output

if the pin is set as output open drain, would the internal pull up automatically be effective?

having to solder a resistor between 2 pins is slightly bothersome but it can probably be done using an smd resistor on the sensor pin itself.

but i'd prefer a direct interface if the internal pull up or pull down can be used

playing with dht-11, dht-22 is a little tricky as i've to flip the pin between output open drain and input pull up

7 REPLIES 7
TDK
Guru

ODR controls the pullup/pulldown but only when in input mode.

See "Table 20. Port bit configuration table" in the reference manual or:

https://electronics.stackexchange.com/questions/280758/arent-pull-up-pull-down-options-documented-for-stm32f103

If you feel a post has answered your question, please click "Accept as Solution".
andrewg
Associate III

thanks it sounds like when it is set as output open drain, the pull up won't be there and a resistor is needed after all?

i may try a different 'trick', when i'm setting output and triggering the dht11, dht22, i'd use normal push-pull instead. assuming that dht11, dht22 does 'open drain' it would then read that as a '1' (high). a slight risk is that the dht11, dht22 short that to ground instead, it would be somewhat a surprise as normally inputs is high impedance

berendi
Principal

That application note apparently does not apply to the STM32F1 series.

The internal pullup might not have worked anyway, because they are about 40 kΩ, and might take too much time to pull the line up.

I am not exactly convinced that the sensor would pull the line actively high, and not just rely on the external pullup that you are planning to omit.

Find some way to connect that resistor. What MCU board do you have? Can't you somehow fix the resistor (either SMD or through hole) on the back side?

andrewg
Associate III

i'm playing with a 'blue pill' stm32f103c8 board, i'd make an attempt without external pull up resistors nevertheless. i think dht11, dht22 are quit popular sensors after all as they are quite easily available adafruit, sparkfun, ebay, etc. I may be able to make do with open drain and input pull up. the notion is that dht11, dht22 needs a 1ms open-drain pull down as the signal/command to start converting. i may be able to combine that with stm32's internal pull up during read phase that would be convenient as it'd avoid needing additional resistors etc and the dht11, dht22 can go direct pin to pin. i checked the specs, the internal pull up is about 30k ohm, signalling speeds are rather slow in the 10s of us so i'd guess this may still be feasible.

berendi
Principal

> i checked the specs, the internal pull up is about 30k ohm

30 to 50 kΩ, typical 40 kΩ according to the datasheet.

I have checked a project where I am using it that way, it takes about 25 μs to reliably pull up the line to a level detectable as high. Which is quite close to 26 μs, the length of the 0 pulse, but it could work if the capacitance of your gear is not higher than that of mine.

TDK
Guru

I would estimate it's on the edge of working and not working.

I think adding an external pullup is going to save you more time in the long run than messing around with switching states. There's usually a good place to whitewire in a resistor on a board if you look for it.

If you feel a post has answered your question, please click "Accept as Solution".
andrewg
Associate III

it works ! it is kind of lucky for the edge case, no pull up resistors used (internal stm32 pullup) pin-to-pin dht22 😉

https://www.stm32duino.com/viewtopic.php?p=3517#p3517