@@ -40,7 +40,21 @@ Please note NodeManager cannot be used as an arduino library since requires acce
...
@@ -40,7 +40,21 @@ Please note NodeManager cannot be used as an arduino library since requires acce
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).
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
## 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.
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:
~~~c
//#define MY_DEBUG
#define MY_NODE_ID 100
#define MY_RADIO_NRF24
//#define MY_RF24_ENABLE_ENCRYPTION
//#define MY_RF24_CHANNEL 76
//#define MY_RADIO_RFM69
//#define MY_RFM69_FREQUENCY RF69_868MHZ
//#define MY_IS_RFM69HW
//#define MY_RFM69_ENABLE_ENCRYPTION
//#define MY_RFM69_NETWORKID 100
~~~
## Enable/Disable NodeManager's modules
## Enable/Disable NodeManager's modules
...
@@ -80,8 +94,24 @@ Those NodeManager's directives in the `config.h` file control which module/libra
...
@@ -80,8 +94,24 @@ Those NodeManager's directives in the `config.h` file control which module/libra
#define MODULE_SWITCH 0
#define MODULE_SWITCH 0
// Enable this module to use one of the following sensors: SENSOR_DS18B20
// Enable this module to use one of the following sensors: SENSOR_DS18B20
#define MODULE_DS18B20 0
#define MODULE_DS18B20 0
// Enable this module to use one of the following sensors: SENSOR_BH1750
#define MODULE_BH1750 0
// Enable this module to use one of the following sensors: SENSOR_MLX90614
#define MODULE_MLX90614 0
~~~
~~~
## Installing the dependencies
Some of the modules above rely on third party libraries. Those libraries are not included within NodeManager and have to be installed from the Arduino IDE Library Manager (Sketch -> Include Library -> Manager Libraries). You need to install the library ONLY if the module is enabled:
Node Manager comes with a reasonable default configuration. If you want/need to change its settings, this can be done in your sketch, inside the `before()` function and just before registering your sensors. The following methods are exposed for your convenience:
Node Manager comes with a reasonable default configuration. If you want/need to change its settings, this can be done in your sketch, inside the `before()` function and just before registering your sensors. The following methods are exposed for your convenience:
...
@@ -157,6 +187,9 @@ SENSOR_SWITCH | Generic switch, wake up the board when a pin changes status
...
@@ -157,6 +187,9 @@ SENSOR_SWITCH | Generic switch, wake up the board when a pin changes status
SENSOR_DOOR | Door sensor, wake up the board and report when an attached magnetic sensor has been opened/closed
SENSOR_DOOR | Door sensor, wake up the board and report when an attached magnetic sensor has been opened/closed
SENSOR_MOTION | Motion sensor, wake up the board and report when an attached PIR has triggered
SENSOR_MOTION | Motion sensor, wake up the board and report when an attached PIR has triggered
SENSOR_DS18B20 | DS18B20 sensor, return the temperature based on the attached sensor
SENSOR_DS18B20 | DS18B20 sensor, return the temperature based on the attached sensor
SENSOR_HTU21D | HTU21D sensor, return temperature/humidity based on the attached HTU21D sensor
SENSOR_BH1750 | BH1750 sensor, return light level in lux
SENSOR_MLX90614 | MLX90614 contactless temperature sensor, return ambient and object temperature
To register a sensor simply call the NodeManager instance with the sensory type and the pin the sensor is conncted to. For example:
To register a sensor simply call the NodeManager instance with the sensory type and the pin the sensor is conncted to. For example:
~~~c
~~~c
...
@@ -377,75 +410,61 @@ A NodeManager object must be created and called from within your sketch during `
...
@@ -377,75 +410,61 @@ A NodeManager object must be created and called from within your sketch during `
* Invoke `Sensor::loop()` which will execute the sensor main taks and eventually call `Sensor::onReceive()`
* Invoke `Sensor::loop()` which will execute the sensor main taks and eventually call `Sensor::onReceive()`
# Examples
# Examples
All the examples below takes place within the before() function in the main sketch, just below the "Register below your sensors" comment.
Enable reboot pin, connect pin 4 to RST to enable rebooting the board with the REBOOT message:
Enable reboot pin, connect pin 4 to RST to enable rebooting the board with the REBOOT message:
~~~c
~~~c
voidbefore(){
nodeManager.setRebootPin(4);
nodeManager.setRebootPin(4);
nodeManager.before();
}
~~~
~~~
Set battery minimum and maxium voltage. This will be used to calculate the level percentage:
Set battery minimum and maxium voltage. This will be used to calculate the level percentage:
~~~c
~~~c
voidbefore(){
nodeManager.setBatteryMin(1.8);
nodeManager.setBatteryMin(1.8);
nodeManager.setBatteryMin(3.2);
nodeManager.setBatteryMin(3.2);
nodeManager.before();
}
~~~
~~~
Instruct the board to sleep for 10 minutes at each cycle:
Instruct the board to sleep for 10 minutes at each cycle:
~~~c
~~~c
voidbefore(){
nodeManager.setSleep(SLEEP,10,MINUTES);
nodeManager.setSleep(SLEEP,10,MINUTES);
nodeManager.before();
}
~~~
~~~
Configure a wake up pin. When pin 3 is connected to ground, the board will stop sleeping:
Configure a wake up pin. When pin 3 is connected to ground, the board will stop sleeping:
~~~c
~~~c
voidbefore(){
nodeManager.setSleepInterruptPin(3);
nodeManager.setSleepInterruptPin(3);
nodeManager.before();
}
~~~
~~~
Use the arduino pins to power on and off the attached sensors. All the sensors' vcc and ground are connected to pin 6 (ground) and 7 (vcc). NodeManager will enable the vcc pin every time just before loop() and wait for 100ms for the power to settle before running loop() of each sensor:
Use the arduino pins to power on and off the attached sensors. All the sensors' vcc and ground are connected to pin 6 (ground) and 7 (vcc). NodeManager will enable the vcc pin every time just before loop() and wait for 100ms for the power to settle before running loop() of each sensor:
~~~c
~~~c
voidbefore(){
nodeManager.setPowerPins(6,7,100);
nodeManager.setPowerPins(6,7,100);
nodeManager.before();
}
~~~
~~~
Register a thermistor sensor attached to pin A2. NodeManager will then send the temperature to the controller at the end of each sleeping cycle:
Register a thermistor sensor attached to pin A2. NodeManager will then send the temperature to the controller at the end of each sleeping cycle:
~~~c
~~~c
voidbefore(){
nodeManager.registerSensor(SENSOR_THERMISTOR,A2);
nodeManager.registerSensor(SENSOR_THERMISTOR,A2);
nodeManager.before();
~~~
}
Register a SHT21 temperature/humidity sensor; since using i2c for communicating with the sensor, the pins used are implicit (A4 and A5). NodeManager will then send the temperature and the humidity to the controller at the end of each sleeping cycle:
~~~c
nodeManager.registerSensor(SENSOR_SHT21);
~~~
~~~
Register a LDR sensor attached to pin A1 and send to the gateway the average of 3 samples:
Register a LDR sensor attached to pin A1 and send to the gateway the average of 3 samples: