Code Monkey home page Code Monkey logo

Comments (9)

fivdi avatar fivdi commented on June 12, 2024 1

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.

rodsnts avatar rodsnts commented on June 12, 2024 1

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.

fivdi avatar fivdi commented on June 12, 2024 1

@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.

fivdi avatar fivdi commented on June 12, 2024

@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.

rhysmorgan134 avatar rhysmorgan134 commented on June 12, 2024

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.

rhysmorgan134 avatar rhysmorgan134 commented on June 12, 2024

Never mind, I thought the new gpio numbers were now the pin numbers, but they are the 4xx range!

from onoff.

rhysmorgan134 avatar rhysmorgan134 commented on June 12, 2024

As an extra spi-device works out of the box, great stuff, and thanks for the help and the libraries!

from onoff.

fivdi avatar fivdi commented on June 12, 2024

@rhysmorgan134 Thanks for confirming that both onoff and spi-device are now working for you.

from onoff.

rodsnts avatar rodsnts commented on June 12, 2024

@fivdi Worked!! Please marry me.

from onoff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.