Simple wrapper for Bolt IoT API - https://cloud.boltiot.com/api
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/.
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
- 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.
Use any of the below two ways to import the package.
var BoltIoT = require('boltiot')
import BoltIoT from 'boltiot'
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.
- 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')
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.)
- digitalRead(pin)
- pin (integer) - Digital pin number of the Bolt Device - (0,1,2,3,4)
const res = await bolt.digitalRead(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])
- 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')
- 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'])
- analogRead(pin)
- pin (string) - Analog pin number of the Bolt Device - ('A0')
const res = await bolt.analogRead('A0')
- 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)
- serialBegin()
- No parameters required
const res = await bolt.serialBegin()
- serialRead(value)
- value (integer) - Value between 0 and 127 - (0 <= value <= 127)
const res = await bolt.serialRead(64)
- serialWrite(value)
- data (string): The data to be sent to the Bolt device via Serial.
const res = await bolt.serialWrite('Hello, Bolt!')
- 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!')
- 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)
- getHistoricalData()
- No parameters required
const res = await bolt.getHistoricalData()
- getVersion()
- No parameters required
const res = await bolt.getVersion()
- getDeviceStatus()
- No parameters required
const res = await bolt.getDeviceStatus()
- restartDevice()
- No parameters required
const res = await bolt.restartDevice()
- getDeviceList()
- No parameters required
const res = await bolt.restartDevice()
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.