// If true, wake up by an interrupt counts as a valid cycle for battery reports otherwise only uninterrupted sleep cycles would contribute (default: true)
voidsetBatteryReportWithInterrupt(boolvalue);
#endif
#if SLEEP_MANAGER == 1
// define if the board has to sleep every time entering loop (default: IDLE). It can be IDLE (no sleep), SLEEP (sleep at every cycle), WAIT (wait at every cycle)
voidsetSleepMode(intvalue);
// define for how long the board will sleep (default: 0)
voidsetSleepTime(intvalue);
// define the unit of SLEEP_TIME. It can be SECONDS, MINUTES, HOURS or DAYS (default: MINUTES)
voidsetSleep(intvalue1,intvalue2,intvalue3);
voidsetSleepUnit(intvalue);
// if enabled, when waking up from the interrupt, the board stops sleeping. Disable it when attaching e.g. a motion sensor (default: true)
voidsetSleepInterruptPin(intvalue);
#endif
// define the way the node should behave. It can be IDLE (stay awake withtout executing each sensors' loop), SLEEP (go to sleep for the configured interval), WAIT (wait for the configured interval), ALWAYS_ON (stay awake and execute each sensors' loop)
voidsetSleepMode(intvalue);
voidsetMode(intvalue);
// define for how long the board will sleep (default: 0)
voidsetSleepTime(intvalue);
// define the unit of SLEEP_TIME. It can be SECONDS, MINUTES, HOURS or DAYS (default: MINUTES)
voidsetSleepUnit(intvalue);
// configure the node's behavior, parameters are mode, time and unit
voidsetSleep(intvalue1,intvalue2,intvalue3);
// if enabled, when waking up from the interrupt, the board stops sleeping. Disable it when attaching e.g. a motion sensor (default: true)
voidsetSleepInterruptPin(intvalue);
// configure the interrupt pin and mode. Mode can be CHANGE, RISING, FALLING (default: MODE_NOT_DEFINED)
voidsetInterrupt(intpin,intmode,intpull=-1);
// optionally sleep interval in milliseconds before sending each message to the radio network (default: 0)
...
...
@@ -786,19 +945,16 @@ class NodeManager {
#endif
// set this to true if you want destination node to send ack back to this node (default: false)
voidsetAck(boolvalue);
// request and return the current timestamp from the controller
@@ -32,25 +32,95 @@ NodeManager includes the following main components:
Please note NodeManager cannot be used as an arduino library since requires access to your MySensors configuration directives, hence its files have to be placed into the same directory of your sketch.
## Upgrade
* Download the package
* Replace the NodeManager.cpp and NodeManager.h of your project with those just downloaded
* Review the release notes in case there is any manual change required to the existing sketch or config.h file
# Configuration
NodeManager configuration includes compile-time configuration directives (which can be set in config.h), runtime global and per-sensor configuration settings (which can be set in your sketch) and settings that can be customized remotely (via a special child id).
## Setup MySensors
Since NodeManager has to communicate with the MySensors gateway on your behalf, it has to know how to do it. Place on top of the `config.h` file all the MySensors typical directives you are used to set on top of your sketch so both your sketch AND NodeManager will be able to share the same configuration. For example:
@@ -58,8 +128,6 @@ Since NodeManager has to communicate with the MySensors gateway on your behalf,
Those NodeManager's directives in the `config.h` file control which module/library/functionality will be made available to your sketch. Enable (e.g. set to 1) only what you need to ensure enough space is left to your custom code.
~~~c
// if enabled, will load the sleep manager library. Sleep mode and sleep interval have to be configured to make the board sleeping/waiting
#define SLEEP_MANAGER 1
// if enabled, enable the capability to power on sensors with the arduino's pins to save battery while sleeping
#define POWER_MANAGER 1
// if enabled, will load the battery manager library to allow the battery level to be reported automatically or on demand
...
...
@@ -77,7 +145,7 @@ Those NodeManager's directives in the `config.h` file control which module/libra
// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
#define BATTERY_SENSOR 1
// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ML8511
// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ML8511, SENSOR_ACS712
#define MODULE_ANALOG_INPUT 1
// Enable this module to use one of the following sensors: SENSOR_DIGITAL_INPUT
#define MODULE_DIGITAL_INPUT 1
...
...
@@ -97,6 +165,12 @@ Those NodeManager's directives in the `config.h` file control which module/libra
#define MODULE_MLX90614 0
// Enable this module to use one of the following sensors: SENSOR_BME280
#define MODULE_BME280 0
// Enable this module to use one of the following sensors: SENSOR_SONOFF
#define MODULE_SONOFF 0
// Enable this module to use one of the following sensors: SENSOR_BMP085
#define MODULE_BMP085 0
// Enable this module to use one of the following sensors: SENSOR_HCSR04
@@ -137,21 +214,24 @@ Node Manager comes with a reasonable default configuration. If you want/need to
// If true, wake up by an interrupt counts as a valid cycle for battery reports otherwise only uninterrupted sleep cycles would contribute (default: true)
voidsetBatteryReportWithInterrupt(boolvalue);
#endif
#if SLEEP_MANAGER == 1
// define if the board has to sleep every time entering loop (default: IDLE). It can be IDLE (no sleep), SLEEP (sleep at every cycle), WAIT (wait at every cycle
voidsetSleepMode(intvalue);
// define for how long the board will sleep (default: 0)
voidsetSleepTime(intvalue);
// define the unit of SLEEP_TIME. It can be SECONDS, MINUTES, HOURS or DAYS (default: MINUTES)
voidsetSleep(intvalue1,intvalue2,intvalue3);
voidsetSleepUnit(intvalue);
// if enabled, when waking up from the interrupt, the board stops sleeping. Disable it when attaching e.g. a motion sensor (default: true)
voidsetSleepInterruptPin(intvalue);
// define the way the node should behave. It can be IDLE (stay awake withtout executing each sensors' loop), SLEEP (go to sleep for the configured interval), WAIT (wait for the configured interval), ALWAYS_ON (stay awake and execute each sensors' loop)
voidsetSleepMode(intvalue);
voidsetMode(intvalue);
// define for how long the board will sleep (default: 0)
voidsetSleepTime(intvalue);
// define the unit of SLEEP_TIME. It can be SECONDS, MINUTES, HOURS or DAYS (default: MINUTES)
voidsetSleepUnit(intvalue);
// configure the node's behavior, parameters are mode, time and unit
voidsetSleep(intvalue1,intvalue2,intvalue3);
// if enabled, when waking up from the interrupt, the board stops sleeping. Disable it when attaching e.g. a motion sensor (default: true)
voidsetSleepInterruptPin(intvalue);
#endif
// configure the interrupt pin and mode. Mode can be CHANGE, RISING, FALLING (default: MODE_NOT_DEFINED)
voidsetInterrupt(intpin,intmode,intpull=-1);
// optionally sleep interval in milliseconds before sending each message to the radio network (default: 0)
voidsetSleepBetweenSend(intvalue);
// set the interrupt pin the sensor is attached to so its loop() will be executed only upon that interrupt (default: -1)