[PLUGIN] GPIO CONTROL: CONTROL GPIO WITH VOLUMIO2 EVENTS

Alrighty I’ll have another bash :+1:t4::sunglasses: now that v3 is released :laughing:

Hi.
i have exactly the same issue that folks had when this topic was started.
I was expecting that when Play is started- GPIO will be on, but on other event (on Stop for example) - the same GPIO will be off.
But in reality- every event is processed once and when GPIO is ON- it will be ON until restart or plugin deactivation.

Is it possible to have only one GPIO for Play, Pause, Stop events to be active at a time?

it is definitely possible. please look at this example for GPIO26

Sure. With one GPIO it is possible.

But I have 3 LEDs and looking for an option to lit one of them depending on playback mode - Play, Pause, Stop

OK I got your problem, I don’t think it is possible with the current plugin

Seems there are some issues with GPIO and Buster. Same goes for GPIO_Buttons. Unable (besides GPIO26) to make it work on GPIO’s that are default Low. the ports that are default High, with added pullup resistor, do work.

example for GPIO4:
image

Darmur, may be you know any alternative?

Unfortunately no, with the plugin as-it-is it’s not possible to achieve what you want.

Maybe with an updated plugin, including more GPIOs for the same action, you will be able to do so, but it’s up to the author of the plugin itself if to release a new version

Are you sure you are reading the right pins to correspond with the gpio’s.
IMO the whole naming thing is confusing, actual pin vs name vs BCM vs wPi

SSH into the pi and do a gpio readall it will do a print out, showing the header and their state.
Then all you need to do is work out which one the author of the plugin used in the settings.

The rotary encoder II and GPIOButtons plugins settings seem to correspond with the BCM column

This is Volumio 3.173 default state ie no external pull-up, pulldown added.

GPIO default

If you are using a Pi4 and get a cant read board error you need to upate wiringPi

cd /tmp
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb

yes i did. Did upgrade wiringPI. I am able to read the pins with Python. It will flag the used pins. However none of the three GPIO plugins seems to be able to deal with GPIO that are default LOW.

Compared 3 rPi’s 4 all with the same result.

1 Like

Strange, as the default high pins are the only ones I am using. pin5 with GPIO Buttons for shut down.
pin10,24,26 with rotary encoder II.
Not using any added pullup either just a 1k resistor inline and a 60nf cap switch side between signal and ground.This works fine with rotary encoder II.

Although with GPIObuttons pin5 doesnt like the inline resistor just doesnt work with it, so now its just a momentary switch between pin5 and ground. Maybe this is your problem too

I’m in the middle of turning a new external volume control which I plan on adding extra buttons to (next,back), Plan on using pins 29 and 31, I supose I’ll find out soon enough how they like to be wired.

Tried both with and without resistors, but couldn’t get it work on GPIO23,24,24,19,20. The event to set them 0 or 1 just didn’t work. Next I moved the push button to GPIO 4,5,6 and it worked instantly.

You said that youre have problems with the default high pins, but then you say GPIO 4,5,6 work fine. They are default high.

Sorry, default LOW. It;s getting confusing hehe

Ive not tested yet but maybe the part of the software that sets the logic state is not working in buster.
So you are not relying on the software to set the state. For the default low pins have you tried having the switch between 3.3v and the GPIO obviously through a 1k resistor.
So a default low pin is pulled high when the button is pressed. This shoould still register a change of state.

Not with Wiringpi. Scanned a lot with gpio readall, but no registration (change) in V.
Even wrote a small script to cintniously reading the GPIO, no change of state.

Strange enough, using pyhton on GPIO23,24,25 it did work. As bash script using GPIO it didn’t
So this is working:

from gpiozero import Button
import os

Button.was_held = False
# Add GPIO (4,17,27,22,5,6,13,19,26,18,23,24,25,12,16,20,21) to monitor
GPIO_23 = Button(23)
GPIO_24 = Button(24)
GPIO_25 = Button(25)
	
def pressed(btn):
	print (str(btn.pin) + "  button was pressed")
	
def held(btn):
	btn.was_held = True
	
	action_held(btn)

def action_held(btn):
	print(str(btn.pin) + " button was held not just pressed, execute held")
	
def released(btn):
	if not btn.was_held:
		print(str(btn.pin) + " button was released")
	btn.was_held = False
	
def check_button(btn):
	btn.when_pressed = pressed
	btn.when_held = held
	btn.when_released = released

while True:
	# Set action for defined GPIO's (4,17,27,22,5,6,13,19,26,18,23,24,25,12,16,20,21)
	check_button(GPIO_23)
	check_button(GPIO_24)
	check_button(GPIO_25)

This it’s not registering any keypress, (did gpio export for some pins)

#!/bin/bash
while :
do
	combstrprev=""

	for i in {0..40}
	do
		combstr+="$(sudo gpio read $i 2>&1)"
		if (i==0)
		then	
			combstrprev=combstr
		fi
		if !((combstr == combstrprev))
		then 
			echo "GPIO$i changed" 
		fi
		combstrprev=${combstr:1:$i}
	done
	echo -e $combstr
	sleep 0.1
	combstr=""
done

You’ve lost me with python.
Personally Id be testing with wiringPi and the plugin I need to get working.
I’ll be trying soon enough though, as soon as the volume control comes off the lathe and gets wired up.

until then

Maybe the onoff library needs to be updated as someone also said that the GPIO-buttons plugin doesn’t work either (which uses the same library). I’m not sure what the issue could be :pleading_face:. From my testing I only used GPIOs that were default low.

Hi, I have installed it on Volumio 3 and it refuse to start :sob: .
I was so happy to find this plugin to switch off my cheap touch screen when nothing is played.

journalctl -f (click here to expanse)
Jan 28 13:41:32 volumio volumio[741]: info: Enabling plugin gpio_control
Jan 28 13:41:32 volumio volumio[741]: info: Loading plugin "gpio_control"...
Jan 28 13:41:32 volumio volumio[741]: error: !!!! WARNING !!!!
Jan 28 13:41:32 volumio volumio[741]: error: The plugin system_controller/gpio_control failed to load, setting it to stopped. Error: Error: Cannot find module 'onoff'
Jan 28 13:41:32 volumio volumio[741]: Require stack:
Jan 28 13:41:32 volumio volumio[741]: - /data/plugins/system_controller/gpio_control/index.js
Jan 28 13:41:32 volumio volumio[741]: - /volumio/app/pluginmanager.js
Jan 28 13:41:32 volumio volumio[741]: - /volumio/app/index.js
Jan 28 13:41:32 volumio volumio[741]: - /volumio/index.js
Jan 28 13:41:32 volumio volumio[741]: error: Stack trace: Error: Cannot find module 'onoff'
Jan 28 13:41:32 volumio volumio[741]: Require stack:
Jan 28 13:41:32 volumio volumio[741]: - /data/plugins/system_controller/gpio_control/index.js
Jan 28 13:41:32 volumio volumio[741]: - /volumio/app/pluginmanager.js
Jan 28 13:41:32 volumio volumio[741]: - /volumio/app/index.js
Jan 28 13:41:32 volumio volumio[741]: - /volumio/index.js
Jan 28 13:41:32 volumio volumio[741]:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
Jan 28 13:41:32 volumio volumio[741]:     at Function.Module._load (internal/modules/cjs/loader.js:725:27)
Jan 28 13:41:32 volumio volumio[741]:     at Module.require (internal/modules/cjs/loader.js:952:19)
Jan 28 13:41:32 volumio volumio[741]:     at require (internal/modules/cjs/helpers.js:88:18)
Jan 28 13:41:32 volumio volumio[741]:     at Object.<anonymous> (/data/plugins/system_controller/gpio_control/index.js:6:12)
Jan 28 13:41:32 volumio volumio[741]:     at Module._compile (internal/modules/cjs/loader.js:1063:30)
Jan 28 13:41:32 volumio volumio[741]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
Jan 28 13:41:32 volumio volumio[741]:     at Module.load (internal/modules/cjs/loader.js:928:32)
Jan 28 13:41:32 volumio volumio[741]:     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
Jan 28 13:41:32 volumio volumio[741]:     at Module.require (internal/modules/cjs/loader.js:952:19)
Jan 28 13:41:32 volumio volumio[741]:     at require (internal/modules/cjs/helpers.js:88:18)
Jan 28 13:41:32 volumio volumio[741]:     at PluginManager.loadCorePlugin (/volumio/app/pluginmanager.js:235:29)
Jan 28 13:41:32 volumio volumio[741]:     at Promise._successFn (/volumio/app/pluginmanager.js:1837:19)
Jan 28 13:41:32 volumio volumio[741]:     at nextTickCallback (/volumio/node_modules/kew/kew.js:47:28)
Jan 28 13:41:32 volumio volumio[741]:     at processTicksAndRejections (internal/process/task_queues.js:75:11)
Jan 28 13:41:32 volumio volumio[741]: error: !!!! WARNING !!!!
Jan 28 13:41:32 volumio volumio[741]: info: Done.

Is there an update expected ? :frowning_face_with_open_mouth:
Do I create an issue to request updates?

Assuming the plugin is still installed in “/data/plugins/system_controller/gpio_control” try to run

sudo apt-get update
sudo apt-get -y install build-essential
npm install --prefix "/data/plugins/system_controller/gpio_control" onoff@^1.1.1