You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NodeManagerTemplate/README.md
+110-4Lines changed: 110 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
NodeManager
1
+
Welcome to NodeManager (v1.1)
2
2
3
3
# Introduction
4
4
@@ -66,7 +66,6 @@ Those NodeManager's directives in the `config.h` file control which module/libra
66
66
// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
67
67
#defineBATTERY_SENSOR 1
68
68
69
-
70
69
// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR
71
70
#defineMODULE_ANALOG_INPUT 1
72
71
// 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
90
89
~~~c
91
90
// the pin to connect to the RST pin to reboot the board (default: 4)
92
91
void setRebootPin(int value);
92
+
// send the same service message multiple times (default: 1)
93
+
void setRetries(int value);
93
94
#if BATTERY_MANAGER == 1
94
95
// the expected vcc when the batter is fully discharged, used to calculate the percentage (default: 2.7)
95
96
void setBatteryMin(float value);
@@ -111,6 +112,8 @@ Node Manager comes with a reasonable default configuration. If you want/need to
111
112
#endif
112
113
// configure the interrupt pin and mode. Mode can be CHANGE, RISING, FALLING (default: MODE_NOT_DEFINED)
113
114
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);
114
117
// register a built-in sensor
115
118
int registerSensor(int sensor_type, int pin = -1, int child_id = -1);
116
119
// register a custom sensor
@@ -119,8 +122,12 @@ Node Manager comes with a reasonable default configuration. If you want/need to
119
122
Sensor* get(int sensor_index);
120
123
#if POWER_MANAGER == 1
121
124
// 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
123
129
void powerOn();
130
+
// manually turn the power off
124
131
void powerOff();
125
132
#endif
126
133
~~~
@@ -214,10 +221,16 @@ The following methods are available for all the sensors:
214
221
void setValueType(int value);
215
222
// for float values, set the float precision (default: 2)
216
223
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);
217
226
#if POWER_MANAGER == 1
218
227
// to save battery the sensor can be optionally connected to two pins which will act as vcc and ground and activated on demand
219
228
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
220
232
void powerOn();
233
+
// manually turn the power off
221
234
void powerOff();
222
235
#endif
223
236
~~~
@@ -361,4 +374,97 @@ A NodeManager object must be created and called from within your sketch during `
361
374
* If the destination child id is the configuration node, it will handle the incoming message, otherwise will dispatch the message to the recipient sensor
362
375
363
376
### 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
+
voidbefore() {
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
+
voidbefore() {
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
+
voidbefore() {
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
+
voidbefore() {
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
+
voidbefore() {
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
+
voidbefore() {
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
+
voidbefore() {
439
+
int sensor_ldr = nodeManager.registerSensor(SENSOR_LDR,A1);
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
+
voidbefore() {
449
+
int rain = nodeManager.registerSensor(SENSOR_ANALOG_INPUT,A0);
0 commit comments