Skip to content

GPIO pins can not be used (onoff module fails) #9

@xKrummy

Description

@xKrummy

Using Raspberry 4b on GPIO pins 5 and 25.
But the logs list me errors related to your module. Can you tell me why / how to fix that?

[2025-02-05 20:18:28.083] [31m[ERROR][39m [31mWhoops! There was an uncaught exception...[39m 
[2025-02-05 20:18:28.111] [31m[ERROR][39m [31mError: EINVAL: invalid argument, write[39m
[31m    at Object.writeFileSync (node:fs:2367:20)[39m
[31m    at exportGpio (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/onoff/onoff.js:18:8)[39m
[31m    at new Gpio (/home/pi/MagicMirror/modules/MMM-Buttons/node_modules/onoff/onoff.js:172:36)[39m
[31m    at Class.intializeButton (/home/pi/MagicMirror/modules/MMM-Buttons/node_helper.js:89:19)[39m
[31m    at Class.intializeButtons (/home/pi/MagicMirror/modules/MMM-Buttons/node_helper.js:105:18)[39m
[31m    at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/MMM-Buttons/node_helper.js:28:18)[39m
[31m    at Socket.<anonymous> (/home/pi/MagicMirror/js/node_helper.js:91:10)[39m
[31m    at Socket.onevent (/home/pi/MagicMirror/node_modules/socket.io/dist/socket.js:462:26)[39m
[31m    at Socket._onpacket (/home/pi/MagicMirror/node_modules/socket.io/dist/socket.js:430:22)[39m
[31m    at /home/pi/MagicMirror/node_modules/socket.io/dist/client.js:214:24[39m
[31m    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {[39m
[31m  errno: -22,[39m
[31m  code: 'EINVAL',[39m
[31m  syscall: 'write'[39m
[31m}[39m 

EDIT:
After several try and errors i found a solution that somewhat seem to work based on https://stackoverflow.com/questions/78173749/use-raspberry-pi-4-gpio-with-node-js/78184108#78184108

Type cat /sys/kernel/debug/gpio into the terminal and use the high numbers for the corresponding GPIO pin. This way they got recognized.

Also: i needed to press the button several times before it got the actual input correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions