[plugin] GPIO control: control GPIO with Volumio 3 events (now RPi5 compatible!)

I took the version (range) for “onoff” from “package.json” of the Volumio 2 version of the plugin… Probably that version is too old. Try

npm install --prefix "/data/plugins/system_controller/gpio_control" onoff@^6.0.0

It could also be necessary to do the same for the module “sleep”:

npm install --prefix "/data/plugins/system_controller/gpio_control" sleep@6.2.0

Still in error :

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

So the installation of the module went through, I guess.

Please show the result of

ls -al /data/plugins/system_controller/gpio_control/node_modules

`ls -al /data/plugins/system_controller/gpio_control/node_modules`
drwxr-xr-x 65 volumio volumio 3072 Jan 28 15:57 .
drwxr-xr-x  4 volumio volumio 1024 Jan 28 15:56 ..
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 after
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 arraybuffer.slice
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 backo2
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 balanced-match
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 base64-arraybuffer
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 better-assert
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 bindings
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 blob
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 brace-expansion
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 callsite
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 child_process
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 component-bind
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 component-emitter
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 component-inherit
drwxr-xr-x  4 volumio volumio 1024 Jan 28 15:56 concat-map
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 debug
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 engine.io-client
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 engine.io-parser
drwxr-xr-x  6 volumio volumio 1024 Jan 28 15:56 epoll
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 file-uri-to-path
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 fs-extra
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 fs.realpath
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 glob
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 graceful-fs
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 has-binary
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 has-cors
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 imurmurhash
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 indexof
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 inflight
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 inherits
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 isarray
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 json3
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 jsonfile
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 kew
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 klaw
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 lodash.debounce
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 minimatch
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 ms
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 multimap
drwxr-xr-x  4 volumio volumio 1024 Jan 28 15:56 nan
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 object-component
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 once
drwxr-xr-x  4 volumio volumio 1024 Jan 28 15:57 onoff
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 options
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 parsejson
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 parseqs
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 parseuri
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 path-is-absolute
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 rimraf
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 sleep
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 slide
drwxr-xr-x  4 volumio volumio 1024 Jan 28 15:56 socket.io-client
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 socket.io-parser
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 to-array
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 ultron
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 universalify
drwxr-xr-x  4 volumio volumio 1024 Jan 28 15:56 v-conf
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 wrappy
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 write-file-atomic
drwxr-xr-x  3 volumio volumio 1024 Jan 28 15:56 ws
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 wtf-8
drwxr-xr-x  5 volumio volumio 1024 Jan 28 15:56 xmlhttprequest-ssl
drwxr-xr-x  2 volumio volumio 1024 Jan 28 15:56 yeast

Ok, I just tried it and succeeded installing the plugin like this:

  1. Remove the installed plugin, i.e. uninstall it.
  2. Unzip the downloaded .zip package (assuming you are in “/home/volumio”):

miniunzip gpio_control.zip -d gpio_control

  1. Run (not tested if this is strictly necessary)

rm -rf gpio_control/node_modules

rm gpio_control/package-lock.json

  1. Then execute

cd gpio_control

npm install onoff@^6.0.0

npm install sleep@^6.2.0

volumio plugin install

2 Likes

It works ! :laughing:
You have a great knowledge, I don’t know exactly what I’ve done but thank you for your support :slight_smile:
Now I control my backligt screen !

@supercrab : some suggestions for futur GPIO Control releases :

  • add configurable delay for each command (could be useful to switch off a screen some secondes after playing)
  • manage the screensaver event from “Touch Display” plugin
  • allow pwm values (could be useful to dim a screen)

Thanks a lot !

2 Likes

Great plugin supercrab!!

I was wondering if there is a possibility where instead of just leaving a gpio pin high, - I could make a gpio pin go high, delay 1 second and then gpio pin low?

I want to make it act like a digital momentary button press…

Thanks

1 Like

Thanks have noted your suggestions too! :+1:t4::sunglasses:

Thanks for your suggestions will try it when I get some time

Thanks for the tips!! I’m gonna have to pull my finger out and get this plugin and my mod_plugin updated!

`
D’oh I have both onoff and sleep modules in /data/plugins/system_hardware/gpio_control/node_modules but I still get cannot find module 'onoff'

What could be wrong?

I don’t use the plugin, but just tried if installing and starting it on Volumio 3 works.

After installing the “build-essential” package by running

sudo apt-get update
sudo apt-get -y install build-essential

I downloaded “gpio_control.zip” from volumio-plugins/plugins/volumio/armhf/system_controller/gpio_control at gh-pages · volumio/volumio-plugins · GitHub and executed the steps lined out in post #67.

Although this is not the recommended way to install a plugin in Volumio 3 and especially lacks a Volumio 3 compliant “package.json”, it was sufficient to make the plugin start.

1 Like

Thanks for your help!

I don’t use the plugin either - I’m trying to update it to Volumio 3 so other people can use it.

I’ve already installed build-essential. I’ve re-created the plugin from fresh, updated the code and created an updated package.json. I followed the steps and manually updated onoff and sleep as needed in the plugin directory in /data/plugins/system_hardware/gpio_control/node_modules. So the modules are present and valid. It’s really strange why it doesn’t work. :frowning:

I wanted to upgrade the plugin and going to try and add some of the new functionality that people have been asking for. :’(

Don’t update the modules in “/data/plugins/system_hardware/gpio_control/node_modules”, i.e. after installing the plugin, but before installing it in the location where the extracted files from the plugin .zip reside (e.g. “/home/volumio/gpio_control”). That is what my post #67 describes.

I haven’t installed the plugin as such because I’m creating a brand new one from scratch. The plugin refresh procedure should automatically update the modules - I didn’t have this issue in v2. I’ll keep trying though. :muscle:t4:

Got it working somehow. :slight_smile: Combination of running npm i and doing volumio plugin refresh && volumio vrestart

I’ve implemented the delay functionality. Question is how to get this plugin submitted…

Hi @supercrab

I noticed you tried to publish your plugin for Volumio3, but it’s not being merged because the submit process was not performed well

Please have a look to the comments from @mervinio , when the submit is done properly your plugin should be available immediately setting the plugins in test mode

1 Like

Thanks! I tried to do the submit but it failed. The submit process seem is too complicated even for experienced developers like me! I don’t have a pi to develop on an more due to the shortage :frowning:

1 Like