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.
- Host: GitHub
- URL: https://github.com/clebert/node-plant-sensor
- Owner: clebert
- License: mit
- Created: 2021-05-04T19:22:31.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-03-26T22:53:21.000Z (about 3 years ago)
- Last Synced: 2025-07-15T10:53:57.053Z (11 months ago)
- Language: TypeScript
- Homepage:
- Size: 69.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```