Libgpiod on navio2 for use of PWM servo rail for GPIO

** edit. using the gpioinfo command ( part of the same libgpiod package ) I can confirm that the gpioset command is in fact working: ‘gpioset –mode=time -s 100 2 10=1’ does set pin 10 on the servo header in the same way as ‘echo 510 > /sys/class/gpio/export’ does. With this I have answered my own question. Still, if anyone has experience with this library for use of the navio2 rc servo header and maybe has working examples, please share **

Per the navio2 servo rail pins can be used as GPIO pins.

The appropriate, modern way for doing this seems to be through libgpiod, and I found a nice intro here:

The library comes with command line tools.

The gpiodetect command confirms availability of the PWM pins for GPIO purposes on navio2:

gpiochip0 [pinctrl-bcm2835] (54 lines)
gpiochip1 [raspberrypi-exp-gpio] (8 lines)
gpiochip2 [Navio PWM pins as GPIO] (16 lines)

I am testing this, by setting a pin high, and using a multimeter to confirm that this is working… The following call should enable pin 10 on gpiochip2 as GPIO pin, and set it high for 100 seconds.

gpioset –mode=time -s 100 2 10=1

However, I cannot confirm that pin 10 (or any other pin) is set.

Is anyone familiar with this library, and has maybe working examples for navio2 for using servo rail pins for GPIO ?

Hi Rolf,

Thanks for sharing the solution that worked for you!

As the main steps are described in this section of our guide, we don’t have any additional examples of working with libgpiod library. Hopefully, some of our users can share them with you!

I’d also recommend checking the quick Introduction to libgpiod on Raspberry Pi and several examples here.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.