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

https://github.com/clebert/node-plant-sensor

A Node.js API for the Xiaomi Plant Sensor with native TypeScript support.
https://github.com/clebert/node-plant-sensor

Last synced: 11 months ago
JSON representation

A Node.js API for the Xiaomi Plant Sensor with native TypeScript support.

Awesome Lists containing this project

README

          

# Node.js Plant Sensor

> A Node.js API for the
> [Xiaomi Plant Sensor](https://xiaomi-mi.com/sockets-and-sensors/xiaomi-huahuacaocao-flower-care-smart-monitor/)
> with native TypeScript support.

This package runs only on Linux and uses BlueZ and D-Bus under the hood.

## Installation

```
npm install @clebert/node-plant-sensor @clebert/node-bluez @clebert/node-d-bus
```

## Features

- Designed from the ground up with TypeScript.
- Supports reading the temperature, illuminance, moisture, and conductivity.
- Supports reading the battery level and firmware version.

## Usage example

```js
import {Adapter} from '@clebert/node-bluez';
import {PlantSensor} from '@clebert/node-plant-sensor';

await Adapter.use(async (adapter) => {
const plantSensor = new PlantSensor(adapter, `XX:XX:XX:XX:XX:XX`);
const data = await plantSensor.getData();

console.log(`Temperature (°C):`, data.temperature);
console.log(`Illuminance (lx):`, data.illuminance);
console.log(`Moisture (%):`, data.moisture);
console.log(`Conductivity (µS/cm):`, data.conductivity);

const properties = await plantSensor.getProperties();

console.log(`Battery level (%):`, properties.batteryLevel);
console.log(`Firmware version:`, properties.firmwareVersion);
});
```

## Configure D-Bus user permissions

Create the `/etc/dbus-1/system.d/node-bluez.conf` configuration file. The
username may need to be modified.

```xml








```