boltiot

1.0.2 • Public • Published

Bolt IoT API Wrapper

NPM Version

Simple wrapper for Bolt IoT API - https://cloud.boltiot.com/api

About

The Bolt IoT Node Package is a powerful and convenient wrapper for the Bolt IoT platform's core APIs. This package allows developers to easily interact with the Bolt Cloud API using Node.js, enabling seamless integration of the Bolt IoT platform into their applications and projects. This node package acts as a wrapper for the existing Bolt Cloud's API. This package is inspired from its official Python's package https://pypi.org/project/boltiot/.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install boltiot

or,

$ npm i boltiot

Geting Started

  • Obtain Your API Key: To access the Bolt IoT services, you need an API key from the Bolt Cloud platform. If you don't have one, sign up on the Bolt Cloud platform to obtain your API key.
  • Instantiate the BoltIoT Class: To begin using the package, you first need to import the BoltIoT class and instantiate it with your API key and device name.

Import

Use any of the below two ways to import the package.

var BoltIoT = require('boltiot')
import BoltIoT from 'boltiot'

Class: BoltIoT

Constructor

The BoltIoT class is used to interact with the Bolt Cloud API. You need to provide your API key and device name when instantiating the class.

Parameters

  • api_key (string): Your Bolt Cloud API key obtained from the Bolt Cloud platform.
  • device_name (string): The name of the Bolt device you want to control. Ensure that the device is linked to your Bolt Cloud account and is online.
const bolt = new BoltIoT('YOUR_API_KEY', 'YOUR_DEVICE_NAME')

Methods

Once you have instantiated the BoltIoT class, you can use the following methods to interact with the Bolt Cloud API. Please use async/await to call the methods or else Promise will be returned.

(Note: The package documentation assumes basic familiarity with the Bolt Cloud API. For detailed information on the Bolt Cloud API, refer to the official Bolt Cloud API Documentation.)

  1. digitalRead(pin)
  • pin (integer) - Digital pin number of the Bolt Device - (0,1,2,3,4)
const res = await bolt.digitalRead(1)
  1. digitalMultiRead(pins)
  • pins (array) - Digital pin number of the Bolt Device - (0,1,2,3,4)
const res = await bolt.digitalMultiRead([0,1,3])
  1. digitalWrite(pin, value)
  • pin (integer) - Digital pin number of the Bolt Device - (0,1,2,3,4)
  • value (string) - Digital pin values - ('HIGH', 'LOW')
const res = await bolt.digitalWrite(0, 'HIGH')
  1. digitalMultiWrite(pins, values)
  • pins (array) - Digital pin number of the Bolt Device - (0,1,2,3,4)
  • value (array) - Digital pin values - ('HIGH', 'LOW')
const res = await bolt.digitalMultiWrite([0,1,3], ['HIGH', 'LOW', 'HIGH'])
  1. analogRead(pin)
  • pin (string) - Analog pin number of the Bolt Device - ('A0')
const res = await bolt.analogRead('A0')
  1. analogWrite(pin, value)
  • pin (integer) - Pin number of the Bolt Device - (0,1,2,3,4)
  • value (integer) - Analog pin value between 0 and 255 - (0 <= value <= 255)
const res = await bolt.analogWrite('A0', 128)
  1. serialBegin()
  • No parameters required
const res = await bolt.serialBegin()
  1. serialRead(value)
  • value (integer) - Value between 0 and 127 - (0 <= value <= 127)
const res = await bolt.serialRead(64)
  1. serialWrite(value)
  • data (string): The data to be sent to the Bolt device via Serial.
const res = await bolt.serialWrite('Hello, Bolt!')
  1. serialWriteRead(till, data)
  • till (integer) - Value between 0 and 127 - (0 <= value <= 127)
  • data (string): The data to be sent to the Bolt device via Serial.
const res = await bolt.serialWriteRead(124, 'Hello Bolt!')
  1. servoWrite(pin, value)
  • pin (integer) - Digital pin number of the Bolt Device - (0,1,2,3,4)
  • value (integer) - Value between 0 and 127 - (0 <= value <= 180)
const res = await bolt.servoWrite(1, 45)
  1. getHistoricalData()
  • No parameters required
const res = await bolt.getHistoricalData()
  1. getVersion()
  • No parameters required
const res = await bolt.getVersion()
  1. getDeviceStatus()
  • No parameters required
const res = await bolt.getDeviceStatus()
  1. restartDevice()
  • No parameters required
const res = await bolt.restartDevice()
  1. getDeviceList()
  • No parameters required
const res = await bolt.restartDevice()

Contribution

We welcome contributions from the community. If you find any issues or have ideas for improvements, feel free to create a pull request. Also, please keep an eye on active issues.

License

MIT

Package Sidebar

Install

npm i boltiot

Weekly Downloads

6

Version

1.0.2

License

MIT

Unpacked Size

15.5 kB

Total Files

5

Last publish

Collaborators

  • ujjwalravi