How can I pull-up on GPIO pins?

Hello,

I’m using balena os, but I’m having trouble setting up internal pull-up on the GPIO pins. I can’t seem to find a solution on GPIO Interface - Balena Documentation. What should I do? For Raspberry Pi, I know that you can add ‘gpio=18,20=pu’ to the config.txt file. - Raspberry Pi Documentation - The config.txt file

Thank you

Hello, you can use the gpio command (as detailed here: New "gpio" config command - Raspberry Pi Forums) in the balenaCloud dashboard either in the Device Configuration item “Allows GPIO pins to be set to specific modes and values at boot time.” or by adding a custom configuration named RESIN_HOST_CONFIG_gpio. In your example, enter "gpio=18,20=pu" for the value.

Hey @chester
When the pull-up resistor is enabled, the pin will be held at a high voltage level by default. When the pin is connected to a circuit or device that pulls the pin to a low voltage level, the pull-up resistor will provide resistance to prevent the pin from sinking too much current and potentially damaging the device.

The specific method for enabling the pull-up resistor will depend on the hardware and software you are using. It generally involve setting a register or configuring a pin mode in your code to enable the pull up resister.

Just wanted to update that this solution does not seem to work.
gpio=18,20=pu does not correctly pull up the pins according to our testing.

A solution detailed here that uses dtoverlay=w1-gpio
does not seem to allow you to pull up the gpios here.

When a Pi first boots, all gpios are set to input, and GPIOs 0 to 8 have pull-ups enabled - the rest have pull-downs enabled. reference

Many of these features for changing gpio settings during boot rely on specific kernel features.
So functionality of these features may vary between various versions of the OS like buster, bullseyes, bookworm, etc…
So versions added support for various dtoverlay commands, and some removed them, etc…
I think it’s best not to rely on it.

The solution right now is to use command line tools, or specific rpi4 gpio libraries, e.g.
raspi-gpio set 4 pu

1 Like