Skip to content

Commit ae3029a

Browse files
author
DV
committed
Updated documentation
1 parent 63da190 commit ae3029a

File tree

1 file changed

+110
-4
lines changed

1 file changed

+110
-4
lines changed

NodeManagerTemplate/README.md

Lines changed: 110 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NodeManager
1+
Welcome to NodeManager (v1.1)
22

33
# Introduction
44

@@ -66,7 +66,6 @@ Those NodeManager's directives in the `config.h` file control which module/libra
6666
// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
6767
#define BATTERY_SENSOR 1
6868

69-
7069
// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR
7170
#define MODULE_ANALOG_INPUT 1
7271
// Enable this module to use one of the following sensors: SENSOR_DIGITAL_INPUT
@@ -90,6 +89,8 @@ Node Manager comes with a reasonable default configuration. If you want/need to
9089
~~~c
9190
// the pin to connect to the RST pin to reboot the board (default: 4)
9291
void setRebootPin(int value);
92+
// send the same service message multiple times (default: 1)
93+
void setRetries(int value);
9394
#if BATTERY_MANAGER == 1
9495
// the expected vcc when the batter is fully discharged, used to calculate the percentage (default: 2.7)
9596
void setBatteryMin(float value);
@@ -111,6 +112,8 @@ Node Manager comes with a reasonable default configuration. If you want/need to
111112
#endif
112113
// configure the interrupt pin and mode. Mode can be CHANGE, RISING, FALLING (default: MODE_NOT_DEFINED)
113114
void setInterrupt(int pin, int mode, int pull = -1);
115+
// optionally sleep interval in milliseconds before sending each message to the radio network (default: 0)
116+
void setSleepBetweenSend(int value);
114117
// register a built-in sensor
115118
int registerSensor(int sensor_type, int pin = -1, int child_id = -1);
116119
// register a custom sensor
@@ -119,8 +122,12 @@ Node Manager comes with a reasonable default configuration. If you want/need to
119122
Sensor* get(int sensor_index);
120123
#if POWER_MANAGER == 1
121124
// to save battery the sensor can be optionally connected to two pins which will act as vcc and ground and activated on demand
122-
void setPowerPins(int ground_pin, int vcc_pin, long wait = 10);
125+
void setPowerPins(int ground_pin, int vcc_pin, long wait = 0);
126+
// if enabled the pins will be automatically powered on while awake and off during sleeping (default: true)
127+
void setAutoPowerPins(bool value);
128+
// manually turn the power on
123129
void powerOn();
130+
// manually turn the power off
124131
void powerOff();
125132
#endif
126133
~~~
@@ -214,10 +221,16 @@ The following methods are available for all the sensors:
214221
void setValueType(int value);
215222
// for float values, set the float precision (default: 2)
216223
void setFloatPrecision(int value);
224+
// optionally sleep interval in milliseconds before sending each message to the radio network (default: 0)
225+
void setSleepBetweenSend(int value);
217226
#if POWER_MANAGER == 1
218227
// to save battery the sensor can be optionally connected to two pins which will act as vcc and ground and activated on demand
219228
void setPowerPins(int ground_pin, int vcc_pin, long wait = 0);
229+
// if enabled the pins will be automatically powered on while awake and off during sleeping (default: true)
230+
void setAutoPowerPins(bool value);
231+
// manually turn the power on
220232
void powerOn();
233+
// manually turn the power off
221234
void powerOff();
222235
#endif
223236
~~~
@@ -361,4 +374,97 @@ A NodeManager object must be created and called from within your sketch during `
361374
* If the destination child id is the configuration node, it will handle the incoming message, otherwise will dispatch the message to the recipient sensor
362375

363376
### Sensor::receive()
364-
* Invoke `Sensor::loop()` which will execute the sensor main taks and eventually call `Sensor::onReceive()`
377+
* Invoke `Sensor::loop()` which will execute the sensor main taks and eventually call `Sensor::onReceive()`
378+
379+
# Examples
380+
Enable reboot pin, connect pin 4 to RST to enable rebooting the board with the REBOOT message:
381+
382+
~~~c
383+
void before() {
384+
nodeManager.setRebootPin(4);
385+
nodeManager.before();
386+
}
387+
~~~
388+
389+
Set battery minimum and maxium voltage. This will be used to calculate the level percentage:
390+
391+
~~~c
392+
void before() {
393+
nodeManager.setBatteryMin(1.8);
394+
nodeManager.setBatteryMin(3.2);
395+
nodeManager.before();
396+
}
397+
~~~
398+
399+
Instruct the board to sleep for 10 minutes at each cycle:
400+
401+
~~~c
402+
void before() {
403+
nodeManager.setSleep(SLEEP,10,MINUTES);
404+
nodeManager.before();
405+
}
406+
~~~
407+
408+
Configure a wake up pin. When pin 3 is connected to ground, the board will stop sleeping:
409+
410+
~~~c
411+
void before() {
412+
nodeManager.setSleepInterruptPin(3);
413+
nodeManager.before();
414+
}
415+
~~~
416+
417+
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:
418+
419+
~~~c
420+
void before() {
421+
nodeManager.setPowerPins(6,7,100);
422+
nodeManager.before();
423+
}
424+
~~~
425+
426+
Register a thermistor sensor attached to pin A2. NodeManager will then send the temperature to the controller at the end of each sleeping cycle:
427+
428+
~~~c
429+
void before() {
430+
nodeManager.registerSensor(SENSOR_THERMISTOR,A2);
431+
nodeManager.before();
432+
}
433+
~~~
434+
435+
Register a LDR sensor attached to pin A1 and send to the gateway the average of 3 samples:
436+
437+
~~~c
438+
void before() {
439+
int sensor_ldr = nodeManager.registerSensor(SENSOR_LDR,A1);
440+
((SensorLDR*)nodeManager.get(sensor_ldr))->setSamples(3);
441+
nodeManager.before();
442+
}
443+
~~~
444+
445+
Register a rain sensor connected to A0. This will be powered with via pins 4 (ground) and 5 (vcc) just before reading its value at each cycle, it will be presented as S_RAIN. sending V_RAINRATE messages, the output will be a percentage (calculated between 200 and 2014) and the value will be reversed (so that no rain will be 0%):
446+
447+
~~~c
448+
void before() {
449+
int rain = nodeManager.registerSensor(SENSOR_ANALOG_INPUT,A0);
450+
SensorAnalogInput* rainSensor = ((SensorAnalogInput*)nodeManager.get(rain));
451+
rainSensor->setPowerPins(4,5,300);
452+
rainSensor->setPresentation(S_RAIN);
453+
rainSensor->setType(V_RAINRATE);
454+
rainSensor->setOutputPercentage(true);
455+
rainSensor->setRangeMin(200);
456+
rainSensor->setRangeMax(1024);
457+
rainSensor->setReverse(true);
458+
nodeManager.before();
459+
}
460+
~~~
461+
462+
Register a latching relay connecting to pin 6 (set) and pin 7 (unset):
463+
464+
~~~c
465+
void before() {
466+
nodeManager.registerSensor(SENSOR_LATCHING_RELAY,6);
467+
nodeManager.registerSensor(SENSOR_LATCHING_RELAY,7);
468+
nodeManager.before();
469+
}
470+
~~~

0 commit comments

Comments
 (0)