2.1.3 • Published 12 months ago

@iiot2k/gpiox v2.1.3

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
12 months ago

@iiot2k/gpiox

platform

Raspberry Pi gpiox library

Thanks for the coffee !! 😁

Installation

npm install @iiot2k/gpiox

or add in your package.json:

"dependencies": {
    "@iiot2k/gpiox": "latest"
},

View on npm📌 View on GitHub📌 Report any issues here📌

Detail

  • This library works on Raspberry Pi with 32bit or 64bit OS
  • Works also on Raspberry Pi 5

Functions

  • Read/write/toggle/blink gpio
  • Watch gpio changes
  • PWM output
  • High speed gpio counter
  • Reads temperature from sensors (DS18B20) connected on gpio

Node.js API

Node.js API functions are explained in document API.md Node.js examples are on examples folder.

// node.js example turns output pin 20 on and after 3000ms off
"use strict";

const gpiox = require("@iiot2k/gpiox");

gpiox.init_gpio(20, gpiox.GPIO_MODE_OUTPUT, 1);

setTimeout(() => {
    gpiox.set_gpio(20, 0);
    gpiox.deinit_gpio(20);
}, 3000);

C++ API

This library uses C++ addon modules as interface to hardware. Therefore, there is also a C++ interface to the drivers. Unfortunately the C++ addon modules are not open source. I provide the C++ static link libraries. But if you are interested in the sources, I can send them to you. Please send me an email with your name to iiot2k@gmail.com I can only provide limited support for the C++ addon modules sources.

I have shown some C++ examples in the cpp directory and on GitHub📌 The C++ API functions are described in the header file gpiox_lib.h

// C++ example turns output on and after 3000ms off

#include <stdio.h>

#include "gpiox_lib.h"

void timeout_callback()
{
    gpiox::set_gpio(20, 0);
    gpiox::deinit_gpio(20);
}

int main()
{
    gpiox::init_gpio(20, gpiox::GPIO_MODE_OUTPUT, 1);
    gpiox::set_timeout(timeout_callback, 3000);

    return 0;
}