stealthmonkey99 / OctoPrint-PWMBuzzer

M300 gcode handler (PWM buzzer via GPIO) for OctoPrint
6 stars 1 forks source link

OrangePi compatibility #25

Open JMVS opened 3 months ago

JMVS commented 3 months ago

Hello, I'm trying to use this plugin with a OrangePi Zero 3 but I can't seem to get it working. I've tried different speakers (same model) like this one: imagen

But I wasn't able to make it work. Is this plugin compatible with the OrangePi? Is there anything I can do to make it work?

Thanks.

stealthmonkey99 commented 3 months ago

Hi @JMVS - unfortunately I've never worked with an OrangePi before and don't have one to test... my guess is that the library I'm using for software PWM doesn't work with the OrangePi, but I wonder if you could use hardware PWM instead? From some searching around it seems like PWM might be disabled by default on the GPIO pins of that device. Try using orangepi-config to enable it (see these instructions), since it will be configured in /boot/orangepiEnv.txt instead of /boot/config.txt, and then configure this plugin to use the pin you enabled.

Please let me know if you have any success with that.

JMVS commented 3 months ago

Hi @stealthmonkey99, thank you for your reply. I've managed to get the speaker working according to these instructions. Actually, I'm avoiding su and using sudo instead. These get me the speaker emmiting sound:

echo 1 | sudo tee /sys/class/pwm/pwmchip0/export
echo 1000000 | sudo tee /sys/class/pwm/pwmchip0/pwm1/period
echo 500000 | sudo tee /sys/class/pwm/pwmchip0/pwm1/duty_cycle
echo 1 | sudo tee /sys/class/pwm/pwmchip0/pwm1/enable

Having PWM hardware enabled in the plugin only allows me to select these GPIOs: imagen

I assume that I should be selecting GPIO1 for my case? How could I do that? May I edit the config file for the plugin directly?

EDIT: I went ahead and modified config.yaml to use GPIO1 and I see these in the logs:

octoprint.plugins.pwmbuzzer - WARNING - GPIO could not be initialized. Hardware buzzer will not be supported. octoprint_pwmbuzzer.buzzers.HardwareBuzzer - WARNING - Error reading '/boot/config.txt': [Errno 2] No such file or directory: '/boot/config.txt' octoprint_pwmbuzzer.buzzers.HardwareBuzzer - WARNING - Hardware PWM Timer enabled but not configured, must add '' to /boot/config.txt

EDIT 2: Would using something like this work? https://pypi.org/project/gpiowrapper/

Thanks for your time.

JMVS commented 5 days ago

Any progress on this? Can I help debbuging/testing somehow?