Skip to content

ingeniadevteam/clysema-raspberry-gpio

Repository files navigation

@clysema/raspberry-gpio

npm (scoped) npm bundle size (minified)

Simple wrapper for the onoff package.

Install

$ npm install @clysema/raspberry-gpio

Config

config/raspberry-gpio.json

[
  {
    "name": "IN1",
    "gpio": 22,
    "type": "input",
    "edge": "falling",
    "debounceTimeout": 100
  },
  {
    "name": "IN2",
    "gpio": 23,
    "type": "input"
  },
  {
    "name": "OUT1",
    "gpio": 24,
    "type": "output",
    "init": 1
  }
]

Usage

Is an event emitter:

// subscribe to data
app.modules["raspberry-gpio"].emitter.on("data", (data) => {
  console.log(data);
  // { name: 'IN1', value: 1 }
});

// subscribe to errors
app.modules["raspberry-gpio"].emitter.on("error", (error) => {
  console.log(error);
});

Read/Write:

console.log(await app.modules["raspberry-gpio"].readOutputs());
await app.modules["raspberry-gpio"].setOutput("OUT1", 0);
console.log(await app.modules["raspberry-gpio"].readOutputs());

About

Simple wrapper for the onoff npm package.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published