Skip to main content
5 votes
Accepted

Confusion with libgpiod and the gpiod user tools?

@Milliways is correct to say the gpiochip interface currently sets the GPIO back to defaults when the GPIO are released (explicitly by the program or by Linux when a user program terminates without ...
joan's user avatar
  • 71.2k
4 votes

Confusion with libgpiod and the gpiod user tools?

It is only possible to guarantee the state of an output line if that line is actively requested, i.e. the fd returned by the GPIO_V2_GET_LINE_IOCTL is still open. In libgpiod terms that means you ...
Kent Gibson's user avatar
4 votes
Accepted

High Impedance state for GPIO

Tri-state output circuitry as used for most computer busses can be set Low, High or HiZ. In fact many circuits actually have 4 states as they can be set as Inputs. The state of a bus (consisting of a ...
Milliways's user avatar
  • 60.4k
3 votes
Accepted

How fast are C & Python libraries

I wrote programs for a number of libraries, both c and python. These just toggle a GPIO pin as fast as possible. NOTE In case anyone misunderstands I am aware this is an artificial test with no real ...
Milliways's user avatar
  • 60.4k
2 votes

Why is gpioinfo not showing me pin names?

The pin names are elements of the device tree. Specifically, they are coded into the source files (*.dts), and eventually become one of the device tree blob (.dtb) files. Each model of RPi has a ...
Seamus's user avatar
  • 22.3k
2 votes

Confusion with libgpiod and the gpiod user tools?

This is the whole point of these tools. They are not intended to be used this way and clear any settings on completion. Whatever you do persists only for the duration of the code. If you enclose in a ...
Milliways's user avatar
  • 60.4k
1 vote

Confusion with libgpiod and the gpiod user tools?

On Raspberry Pi 3 Bullseye Linux rpi 5.15.32-v7+ and gpioinfo (libgpiod) v1.6.2 the command line seems to be persistent. I have a relay connected to gpio17 and the commands: gpioset 0 17=1 or gpioset ...
Riccardo's user avatar
1 vote
Accepted

Working code example for a button using GPIOd and Python

I have some code using gpiod. See https://raspberrypi.stackexchange.com/a/145544/8697 gpiod is poorly documented so it is not easy to use but my test worked but not fully tested on Pi5
Milliways's user avatar
  • 60.4k
1 vote

Current proper way to interface GPIO from C code?

The current "proper" way is libgpiod (a poor choice of name as it is not a daemon) although the current version in Bookworm is (at least) 3 years old, poorly documented and has absolutely NO ...
Milliways's user avatar
  • 60.4k
1 vote

I am looking for clarity on how the libgpiod works with higher functions (esp I2C)

libgpiod controls GPIO i.e. it allows pins to be sent to INPUT, OUTPUT (and pullups) and NOTHING ELSE. This is well documented and discussed if you search. If you want to use other functions e.g. I²C ...
Milliways's user avatar
  • 60.4k
1 vote
Accepted

Cannot write() i2c-dev after using libgpiod

You are using GPIO2 and GPIO3 with the /dev/gpiochip interface (also known as libgpiod). The /dev/gpiochip library is incomplete and does not really understand GPIO. It thinks they can only have two ...
joan's user avatar
  • 71.2k
1 vote

libpgiod vs wiringPI code/configuration

I am not impressed with libgpiod. Frankly it seems to be a retrograde step compared to sysfs. Here is some partial code which calls up other not included code. It should give you enough of an idea ...
joan's user avatar
  • 71.2k
1 vote

libpgiod vs wiringPI ports/pins etc

libgpiod (the replacement for sysfs for GPIO) uses Broadcom GPIO numbering. I.e. libgpiod GPIO x is Broadcom GPIO x. Broadcom numbering is indicated with BCM in the following. https://pinout.xyz/
joan's user avatar
  • 71.2k
1 vote
Accepted

How to read any connected DS18B20 temperature sensors with C/C++

I believe the methods presented in those examples are still relevant. libgpiod is the replacement for the sysfs method of directly talking to the GPIO as a Linux user. I.e. it replaces user functions ...
joan's user avatar
  • 71.2k
1 vote
Accepted

How to control a Servo via libgpiod on a raspberry PI

You will have to use delays/sleeps to implement the required 50 Hz pulses. The /dev/gpiochip interface has no built-in support for PWM. You will need two delays per pulse: high (delay from pulse ...
joan's user avatar
  • 71.2k

Only top scored, non community-wiki answers of a minimum length are eligible