Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ax1/a1-raspberry

🍓 Utilities for Raspberry PI devices
https://github.com/ax1/a1-raspberry

Last synced: about 23 hours ago
JSON representation

🍓 Utilities for Raspberry PI devices

Awesome Lists containing this project

README

        

# a1-raspberry

Utilities for Raspberry PI devices. Promise based. Zero dependencies.

> Note: this library uses the **BCM pinout** by default. See https://pinout.xyz/

## Installation

```bash
npm install a1-raspberry
```

## Usage

### GPIO pins

The module uses the `gpio` command installed in the raspberry. See http://wiringpi.com/the-gpio-utility/ for available options. For the sake of simplicity the module uses **the BCM pinout** (by adding the -g flag to the gpio command)

```javascript
const { gpio } = require('a1-raspberry')
const PIN = 4
await gpio.configure(PIN, 'out') // configure as output
await gpio.write(PIN, 1) // set pin to 3.3V
setTimeout(() => { gpio.write(PIN, 0) }, 5000)
const val = await gpio.read(PIN) // return 1 (3.3V)
gpio.execute('gpio -g write 4 1') // execute a custom command
```