[Solved]Help with GPIO not working!

After much research and trial and error, I solved the problems!

I am leaving this description here in case anyone else needs it in the future.

I started again with a clean installation, in which the only software installed was CUPS and python3, leaving i2c and spi disabled.

Before the first start-up, I modified dietpi.txt on the boot partition, unmasking the logind service by setting the option to 1:

AUTO_UNMASK_LOGIND=1

Since I was already there, I also set the host name and static IP.

Once I had completed the initial start-up by setting passwords, region, time and language, I moved on to testing that logind was actually working:

root@DietPi:~# systemctl status systemd-logind
● systemd-logind.service - User Login Management
     Loaded: loaded (/lib/systemd/system/systemd-logind.service; static)
     Active: active (running) since Wed 2023-04-19 16:29:25 BST; 1min 54s ago
       Docs: man:sd-login(3)
             man:systemd-logind.service(8)
             man:logind.conf(5)
             man:org.freedesktop.login1(5)
   Main PID: 422 (systemd-logind)
     Status: "Processing requests..."
      Tasks: 1 (limit: 9203)
     Memory: 1.3M
        CPU: 61ms
     CGroup: /system.slice/systemd-logind.service
             └─422 /lib/systemd/systemd-logind

So I added the following lines to /boot/firmware/config.txt:

#-------poweroff button------



dtoverlay=gpio-shutdown,gpio_pin3,active_low=1,gpio_pull=up


I rebooted and found that finally, by closing gpio3 to GND, the Raspberry shut down.

I then moved on to installing:

sudo apt install python3-gpiozero python3-lgpio

Then I created a led.py file on /home/dietpi/:

import sys

from gpiozero import LED

red = LED(17)

while True:

red.on()

sys.exit()

I launched dietpi-autostart, which creates a bash file

/var/lib/dietpi/dietpi-autostart/custom.sh

and inserted the following line of code:

/usr/bin/python3 /home/dietpi/led.py &

Then I moved on to installing the drivers for the printer, etc.

So I have a print server that I can turn on and off as I please, without compromising the SD card, and which lights up an LED at the end of the start-up process to show that it is operational!

Thanks to everyone who helped me…

See you next time.

Valter :grinning_face: :waving_hand: