Ender 3 V2 + Raspberry Pi Zero 2W + Octoprint running using docker compose + PSU Control pluggin not working

What is the problem?

I have an Ender 3 V2 printer and I used a Raspberry Pi Zero 2W to run the octoprint docker image using docker compose. I have no issues when I try to connect to the Octoprint UI via web browser, once the docker image is up.

The problem comes when I install the PSU Control plugin and the PSU Control - RPi.GPIO pluggin. When I install those plugins I can see their tabs as usual, the problem is not here. Thus, in the PSU Control tab, I am able to set the Switching Method as Plugin. Then, I am also able to set the Switching Plugin as PSU Control - RPi.GPIO.

Finally, in the PSU Control - RPi.GPIO tab I can define the GPIO Mode and the Switching Pin, which are BCM mode and the pin 11 (GPIO 17), respectively. I have created a simple circuit with a LED to check if everything works fine.

For me it seems everything is OK at this point, but the truth is that the Toggle PSU button, that appears at the top of the UI, doesn't really activates anything. It doesn't turn green either.

Anybody had the same problem? Or at least tried something different to run Octoprint using docker image with PSU Control operational?

What did you already try to solve it?

I tried to remove the docker image and reinstall it again.
I tried to remove the pluggins, restart the octoprint and reinstall the pluggins again.
I tried to uninstall the PSU Control - RPi.GPIO plugin and work only with the PSU Control plugin.
I searched for a solution but I haven't found one yet.

Have you tried running in safe mode?

I haven't tried running in safe mode. Next step.

Did running in safe mode solve the problem?

I will post the results once I try.

Systeminfo Bundle

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

octoprint-systeminfo-20250206174452.zip (112.5 KB)

Additional information about your setup

OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ... as much data as possible

Octoprint version: Version 1.10.3
PSU Control plugin version: 1.0.6
PSUControl - RPi.GPIO plugin version: 1.0.4
Printer: Ender 3 V2
Browser: Chrome
RPi board: Raspberry Pi Zero 2 W

Alright, I didn't know, but in safe mode the thirdparty plugins are disabled, so it isn't useful for me if I run Octoprint in safe mode. I received a message in Octoprint UI saying:

The server is currently running in safe mode. Third party plugins and language packs are disabled and cannot be enabled.
Reason: Setting in config.yaml

Well looking at your log file you have this:

2025-02-06 17:34:50,251 - octoprint.plugins.psucontrol - DEBUG - Polling PSU state...
2025-02-06 17:34:50,252 - octoprint.plugins.psucontrol - DEBUG - isPSUOn: False
2025-02-06 17:34:50,679 - octoprint.plugins.psucontrol - INFO - Switching PSU On
2025-02-06 17:34:50,680 - octoprint.plugins.psucontrol - DEBUG - Switching PSU On Using PLUGIN: psucontrol_rpigpio
2025-02-06 17:34:50,680 - octoprint.plugins.psucontrol_rpigpio - DEBUG - Switching PSU On Using GPIO: 11
2025-02-06 17:34:50,680 - octoprint.plugins.psucontrol - ERROR - Error while executing callback <bound method PSUControl_RPiGPIO.turn_psu_on of <octoprint_psucontrol_rpigpio.PSUControl_RPiGPIO object at 0x7f91c41fc0>>
Traceback (most recent call last):
  File "/octoprint/plugins/lib/python3.10/site-packages/octoprint_psucontrol/__init__.py", line 495, in turn_psu_on
    r = callback()
  File "/octoprint/plugins/lib/python3.10/site-packages/octoprint_psucontrol_rpigpio/__init__.py", line 181, in turn_psu_on
    o = GPIO.HIGH
NameError: name 'GPIO' is not defined

Very likely the root of your issues. I am not sure what your settings should be but it seems that using the GPIO as the control for your IO is not correct or maybe you are missing the supporting sub plugin? Running this in a container might also be part of the issue. Might not be able to interact with the IO directly or something like that. Not sure really but seems like something easy to test and generally a good place to start given the error.

Hi @jcassel ! Thank you very much for your reply.

Thanks to your answer, I tried the following:

$ sudo docker exec -it b724158257d5 bash

root@b724158257d5:/octoprint# pip list | grep RPi.GPIO
RPi.GPIO                     0.7.1

It seems the RPi.GPIO python package is installed in the docker image.

Then I tried the following and I got:

root@b724158257d5:/octoprint# python3 -c "import RPi.GPIO as GPIO; print('RPi.GPIO is working')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/octoprint/plugins/lib/python3.10/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!

A bit weird error, since I'm using a Raspberry Pi Zero 2W...

I investigated a little bit, because you mentioned "Running this in a container might also be part of the issue. Might not be able to interact with the IO directly or something like that.", and I found that the problem is that RPi.GPIO doesn't have proper hardware acces inside the container. Thus, I modified the docker-compose.yml and I added the following line in the octoprint service:

privileged: true

My docker container will be as follows:

services:
  octoprint:
    image: octoprint/octoprint
    restart: unless-stopped
    ports:
      - 80:80
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
      - /dev/video0:/dev/video0
    volumes:
     - octoprint:/octoprint
    environment:
     - ENABLE_MJPG_STREAMER=true
     - MJPEG_STREAMER_INPUT=input_raspicam.so -fps 25
    privileged: true
    
volumes:
  octoprint:

Finally I restarted the container and... it worked !!!! Now I'm able to activate the desired GPIO by pressing the Toggle PSU Button.

I will update this post if something new happens related to this topic, but for now, it is solved.

Thank you very much!