/node-flower-power

node.js lib for the Parrot Flower Power

Primary LanguageJavaScriptMIT LicenseMIT

flower-power-ble

Analytics

node.js lib for the Parrot Flower Power

Install

$ npm install flower-power-ble

Usage

var FlowerPower = require('flower-power-ble');

Discover

// Discover one Flower Power
FlowerPower.discover(callback(flowerPower));

// Discover all Flower Power's
FlowerPower.discoverAll(callback(flowerPower));

Connect and Setup

flowerPower.connectAndSetup(callback(error));

Disconnect

flowerPower.disconnect(callback(error));

Device Info

flowerPower.readSystemId(callback(error, systemId));

flowerPower.readSerialNumber(callback(error, serialNumber));

flowerPower.readFirmwareRevision(callback(error, firmwareRevision));

flowerPower.readHardwareRevision(callback(error, hardwareRevision));

flowerPower.readManufacturerName(callback(error, manufacturerName));

Other Info

flowerPower.readFriendlyName(callback(error, friendlyName));

flowerPower.writeFriendlyName(friendlyName, callback(error));


flowerPower.readColor(callback(error, color));

Battery Level

// batteryLevel range is 0 - 100
flowerPower.readBatteryLevel(callback(error, batteryLevel));

Sunlight

// sunlight units are photons per square meter
flowerPower.readSunlight(callback(error, sunlight));

Soil Temperature

flowerPower.readSoilTemperature(callback(error, temperature)); // C

Air Temperature

flowerPower.readAirTemperature(callback(error, temperature)); // C

Soil Moisture

// soilMoisture units is percentage (%)
flowerPower.readSoilMoisture(callback(error, soilMoisture));

Calibrated

// firmware versions 1.1 and above

flowerPower.readCalibratedSoilMoisture(callback(error, soilMoisture)); // %

flowerPower.readCalibratedAirTemperature(callback(error, temperature)); // C

flowerPower.readCalibratedSunlight(callback(error, sunlight)); // photons per square meter (mol/m²/d)

flowerPower.readCalibratedEa(callback(error, ea)); // no units

flowerPower.readCalibratedEcb(callback(error, ecb)); // dS/m

flowerPower.readCalibratedEcPorous(callback(error, ecPorous)); // dS/m

Live mode

// sunlightChange, soilTemperatureChange, airTemperatureChange,
// soilMoistureChange events are emitted (see below)

flowerPower.enableLiveMode(callback(error));

flowerPower.disableLiveMode(callback(error));

Calibrated live mode

// firmware versions 1.1 and above

// calibratedSoilMoistureChange, calibratedAirTemperatureChange,
// calibratedSunlightChange, calibratedEaChange, calibratedEcbChange,
// calibratedEcPorousChange events are emitted (see below)

flowerPower.enableCalibratedLiveMode(callback(error));

flowerPower.disableCalibratedLiveMode(callback(error));

LED

flowerPower.ledFade(callback(error));

flowerPower.ledOff(callback(error));

History

flowerPower.getHistory(index, callback(error, history));

Update firmware

flowerPower.updateFirmware(file.bin, callback(error));

Events

Disconnect

flowerPower.on('disconnect', callback);

Sunlight Change

flowerPower.on('sunlightChange', callback(sunlight));

Soil Temperature Change

flowerPower.on('soilTemperatureChange', callback(soilTemperature));

Air Temperature Change

flowerPower.on('airTemperatureChange', callback(airTemperature));

Soil Moisture Change

flowerPower.on('soilMoistureChange', callback(soilMoisture));

Calibrated Change

flowerPower.on('calibratedSoilMoistureChange', callback(soilMoisture));
flowerPower.on('calibratedAirTemperatureChange', callback(temperature));
flowerPower.on('calibratedSunlightChange', callback(sunlight));
flowerPower.on('calibratedEaChange', callback(ea));
flowerPower.on('calibratedEcbChange', callback(ecb));
flowerPower.on('calibratedEcPorousChange', callback(ecPorous));

TODO

  • discover
  • connect
  • discover
  • discover services and characteristics
  • read device info
    • system id
    • serial number
    • firmware revision
    • hardware revision
  • read battery level
  • read sunlight
  • read temperature
  • read soil moisture
  • live mode
    • sunlight
    • temperature
    • soil moisture
  • read fertilizer
  • read historic data
  • update firmware
  • use calculations to convert values (currently using lookup table)