Comments (9)
onoff uses the GPIO sysfs interface for userspace GPIO. This interface has been deprecated for quite some time (see here). I don't know if the GPIO sysfs Interface for userspace GPIO is supported on the Raspberry Pi 5 so I asked here on the Raspberry Pi forum.
from onoff.
Never mind, I thought the new gpio numbers were now the pin numbers, but they are the 4xx range!
Hi @rhysmorgan134 , what you did to be able to use onoff with the raspberry pi 5?
I have this simple code:
const Gpio = require("onoff").Gpio;
const led = new Gpio(4, "out");
led.writeSync(1);
And I get a error message saying:
Error: EINVAL: invalid argument, write
from onoff.
@rodsnts To understand how GPIO numbering works on the Pi5, it's important to read this post: https://forums.raspberrypi.com/viewtopic.php?t=359302
Assuming you want to use GPIO4, which is PIN7 on the GPIO header, then you'll need to replace this:
const Gpio = require("onoff").Gpio;
const led = new Gpio(4, "out");
led.writeSync(1);
with this:
const Gpio = require("onoff").Gpio;
const led = new Gpio(403, "out");
led.writeSync(1);
In other words, what used to be GPIO4 is now GPIO403 on the Pi5. Give this a try to see if it works.
from onoff.
@rhysmorgan134 Please take a look at the forum post. I need to do some more testing but everything appears to be working, including interrupt detection. However, the GPIO numbering is completely different.
from onoff.
Thanks alot @fivdi just ran some tests now, and after upgrading I appear to now be getting these errors, I will have an investigate!
node:internal/fs/utils:350
throw err;
^
Error: EINVAL: invalid argument, write
at Object.writeSync (node:fs:936:3)
at Object.writeFileSync (node:fs:2330:26)
at exportGpio (/home/pi/SocketMost/node_modules/onoff/onoff.js:18:8)
at new Gpio (/home/pi/SocketMost/node_modules/onoff/onoff.js:172:36)
at new OS8104A (/home/pi/SocketMost/dist/driver/OS8104A.js:46:26)
at new SocketMost (/home/pi/SocketMost/dist/server/SocketMost.js:107:23)
at Object.<anonymous> (/home/pi/SocketMost/examples/server.js:3:20)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32) {
errno: -22,
syscall: 'write',
code: 'EINVAL'
}
Node.js v18.18.2
from onoff.
Never mind, I thought the new gpio numbers were now the pin numbers, but they are the 4xx range!
from onoff.
As an extra spi-device works out of the box, great stuff, and thanks for the help and the libraries!
from onoff.
@rhysmorgan134 Thanks for confirming that both onoff and spi-device are now working for you.
from onoff.
@fivdi Worked!! Please marry me.
from onoff.
Related Issues (20)
- Problem using watch function with relay HOT 10
- Initialize GPIO without change pin status. HOT 6
- GPIO not working in a worker_thread - nodejs 14.15 HOT 2
- EACCES: permission denied, open '/sys/class/gpio/export' as superuser HOT 2
- Cannot run on non Rpi system HOT 1
- TypeError: writeSync is not a function HOT 4
- Raspberry Pi GPIO control in electron App HOT 8
- My computer does not have a /sys/class/gpio directory, but has /dev/gpiochip* HOT 1
- Interrupt misfire HOT 3
- Raspberry 4 - malloc(): corrupted top size HOT 3
- Error: EPERM: operation not permitted, write HOT 4
- Does not work with Compute Module 4. HOT 2
- Event is fired multiple times
- Superb library - I am running on Node v20 HOT 2
- Compatibility with ppp asked?
- RPI 5 gpio numbers HOT 1
- fs error HOT 6
- Newer version of epoll
- Button.watch spams endlessly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onoff.