@codingkiwi/airthings-wave-plus
v1.0.1
Published
A Node.js package for interacting with the Airthings Wave Plus device via Bluetooth, providing seamless data retrieval for humidity, temperature, radon levels, atmospheric pressure, carbon dioxide, and volatile organic compounds.
Downloads
13
Maintainers
Readme
Airthings Wave Plus NPM Package
Overview
The @codingkiwi/airthings-wave-plus NPM package is a convenient and easy-to-use tool for interacting with the Airthings Wave Plus device via Bluetooth. The package allows users to seamlessly connect to the Airthings Wave Plus, retrieve data, and disconnect as needed.
Installation
To install the package, run the following command:
npm install @codingkiwi/airthings-wave-plus
Usage
Importing the Package
import WavePlus from "@codingkiwi/airthings-wave-plus";
Creating an Instance
const wavePlus = new WavePlus();
You can also customize the discovery interval and timeout by passing options to the constructor:
const customOptions = {
discoverInterval: 2000, // Custom discovery interval in milliseconds
discoverTimeout: 15000, // Custom discovery timeout in milliseconds
};
const wavePlusWithCustomOptions = new WavePlus(customOptions);
Reading Data
Reading Once
const data = await wavePlus.readOnce();
This method connects to the device (if necessary), reads the data, and disconnects. It returns the retrieved data.
Continuous Reading
const continuousData = await wavePlus.read();
This method connects to the device (if necessary) and reads the data and keeps the bluetooth connection. It is useful for scenarios where you want to read data at regular intervals.
Connecting and Disconnecting
Connecting
await wavePlus.connect();
Connects to the Airthings Wave Plus device if necessary.
Disconnecting
await wavePlus.disconnect();
Disconnects from the Airthings Wave Plus device.
Note
The Airthings Wave Plus device delivers new data every 5 minutes. Keep this in mind when implementing continuous reading to avoid unnecessary connections.
Example
import WavePlus from "@codingkiwi/airthings-wave-plus";
async function getData() {
const wavePlus = new WavePlus();
try {
const data = await wavePlus.read();
console.log("Data:", data);
} finally {
await wavePlus.disconnect();
}
}
getData();
/**
{
humidity: 35.5,
temperature: 16.49,
radonStAvg: 35,
radonLtAvg: 31,
pressure: 970.32,
co2: 539,
voc: 48
}
*/
Feel free to customize the example based on your specific use case and requirements.
Debugging
For enhanced debugging capabilities, the @codingkiwi/airthings-wave-plus package integrates with the debug
npm package under the namespace "airthings." To enable debugging output, set the DEBUG
environment variable to "airthings" when running your application. For example:
DEBUG=airthings node your-app.js
This will activate debug messages specific to the @codingkiwi/airthings-wave-plus package, providing valuable insights into the internal processes, Bluetooth interactions, and overall functionality. Debugging can be particularly useful for troubleshooting and gaining a deeper understanding of the package's behavior. Explore the debug output to identify and resolve any issues during development or integration with your project.