Can't get GPIO pin to work in Linux

What is the problem?

I am trying to get a relay to close when Octoprint shuts down. It worked in the past on a headless Pi, but now it doesn't seem to work.

What did you already try to solve it?

Replaced pi with another Pi 4B (8GB), and entered GPIO commands manually in the terminal window. Didn't help.

Have you tried running in safe mode?

no-problem seems to be outside Octoprint. Don't know how to run Octoprint in safe mode.

Did running in safe mode solve the problem?

Didn't run is safe mode.

Systeminfo Bundle

You can download this in OctoPrint's System Information dialog ... no bundle, no support!)

Didn't do this. Don't know how.

Additional information about your setup

What kind of hardware precisely, OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ... as much data as possible

Octoprint Ver 1.9.3 on a 8GB Pi4B Prusa MK4 printer with the following plugins:
Automatic Shutdown
Bed Visualizer
Classic Webcam
Dashboard
Enclosure Plugin
Firmware Check
GPIO Shutdown
PrintTimeGenius Plugin
Printer Dialogs
Printer Notifications
Virtual Printer

In any case, Octoprint runs fine.

In the server settings, I have the following for Shutdown system: /home/pi/sdown.sh

In the sdown.sh file, located in the pi@octopi directory, I have the following commands:
disconnect
gpio -g mode 27 out
gpio -g write 27 1
sudo shutdown -h now

This works, and shuts down the Pi, except that nothing is written to GPIO pin 27 (it still remains at 0). I tried manually entering the GPIO commands manually into the terminal window, and got no error message, but GPIO pin 27 never went high. GPIO pin 27 closes a relay that pulls power to the pi and the printer. I tried different GPIO pins, but nothing seems to work.

The GPIO pins within the Octoprint plugins seem to work fine, and I have a pushbutton and LED configured in the GPIO shutdown plugin, and they work fine.

This used to work fine when I ran Octoprint in a headless Pi (no display). When I rebuilt the Pi with the 7" Pi Touchscreen display, the GPIO commands don't seem to work anymore. I want to use the display to bring up the Chromium browser so I can control Octoprint from the Pi instead of having to log into Octoprint from another machine. This seems to work. The problem is the GPIO setting pin 27 to a 1 doesn't work.

I am a newbe to Linux.

I can't figure out why the GPIO commands don't set pin 27 to high.

I am using a darlington on the output of pin 27 to drive the relay, so there is very little current draw on pin 27.

Please help.

Thanks in advance.

When I posted this, I didn't know how to run Octoprint in safe mode. When I posted this, I got the link as to how to run Octoprint in safe mode. I ran Octoprint in safe mode, and that didn't fix the problem.

Can you please attach the systeminfo bundle to your next post.

octoprint-systeminfo-20240131165054.zip (54.1 KB)

It looks like the plugin itself is crashing here.

Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_GPIOShutdown/__init__.py", line 104, in sensor_callback
    self._logger.info("GPIO is '{0}' after Holdtime. NO shutdown".format(GPIO.input(self.pin_shutdown_)))

When you post code snippets, please use the preformatted text feature in the editor's menu:

Format

Sorry for the lack of understanding of the editor. I thought the 2 lines of code were really clear.

The GPIOShutdown problem could be related to the GPIO problem I am having. I'll investigate it. Anyway, I ran Octoprint in safe mode (no plugins), and I still have the GPIO problem

Please, someone MUCH more knowledgeable on the Pi please help me. I am a newbe in Linux and the Pi.

Steve

That post was for @opjose

I was responding to BOTH posts.

I really do need help with this problem.

Since the plug-in is crashing, you may want to go to the github page for the author and check any posts there about the crashing issue. At worst put up a new post asking for clarification or help.

The main question of the post is actually why these two commands are not working, rather than the plugin (which apparently works)

I've never used the gpio commands, so I can't really help unfortunately.

What Linux did you install?

Maybe you need to install a GPIO driver.

With OctoPi this is included.

The systeminfo bundle shows OctoPi 0.17.

1 Like

I installed Raspian. The gpio command is accepted, it just doesn't do anything, Octopi runs fine, including the plugin GPIOShutdown.

Tried a brand-new Pi in just to eliminate a bad set of I/O circuits. Nope, same issue.

Since the plug-in is crashing, you may want to go to the github page for the author and check any posts there about the crashing issue. At worst put up a new post asking for clarification or help.

The plugin is not my issue. It has been abandon. I am trying to find out why my two gpio commands don't do anything. Are there diagnostics to help me find the problem?

This may be of help: How can I test the GPIO pins

Oops... Sorry.

WiringPi(gpio command) has been deprecated since 2019 and the developers website doesn't even exist anymore. It might work but I wouldn't use it as a definitive test.

So what do I use instead to set the gpio pins in the shell environment?

This article is WAY out of date. It doen't work on my machine.