@user2684 said in NodeManager: plugin for a rapid development of battery-powered sensors:
I have a couple of AM312 sensors around here and they are working ok without any debounce or trigger time, I guess I've been just lucky The only issue I had has been a lot of false positives when placed outside and the light changing (e.g. the sun shines over them) but I think this is somehow expected.
@mar.conte in your example you are creating a switch object, adjusting its settings but then NOT using it since when yo call register sensor it will create and register a new object
Either you call register sensor and then retrive the object in this way:
nodeManager.setSleep(SLEEP,60,MINUTES);
sensor_id = nodeManager.registerSensor(SENSOR_MOTION,3);
SensorMotion* sensorMotion = ((SensorMotion*)nodeManager.getSensor(sensor_id));
sensorMotion->setDebounce(50);
sensorMotion->setTriggerTime(4000);
Or you create your own sensor, adjust the settings and register it by passing the object's instance but then you also need to setup the interrupt manually so I'd recommend the option just above. In your example (if this is what you are using) you basically have a standard sensor with neither debounce nor triggertime set
I appreciate the help.
Ive tried adding your code to my sketch but I get this error.
Arduino: 1.8.1 (Windows 10), Board: "Arduino Nano, ATmega328"
In file included from C:\Users\Daniel\Documents\NodeManager_testing_motion\NodeManager_testing_motion.ino:24:0:
sketch\NodeManager.h:388:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
char* _description = "";
^
sketch\NodeManager.h:400:28: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
char * _value_string = "";
^
sketch\NodeManager.h:403:33: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
char * _last_value_string = "";
^
C:\Users\Daniel\Documents\NodeManager_testing_motion\NodeManager_testing_motion.ino: In function 'void before()':
NodeManager_testing_motion:36: error: 'sensor_id' was not declared in this scope
sensor_id = nodeManager.registerSensor(SENSOR_MOTION,3);
^
exit status 1
'sensor_id' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
'sensor_id' was not declared in this scope..
Is the error that stops it from compiling, I always get the other errors when compiling but the sensor still works, tested on dht sensor (but this may be the problem)
I'm guessing i'm missing something in the sketch.
I'm really sorry for the pathetic questions.
With this basic sketch:
/*
NodeManager is intended to take care on your behalf of all those common tasks a MySensors node has to accomplish, speeding up the development cycle of your projects.
NodeManager includes the following main components:
- Sleep manager: allows managing automatically the complexity behind battery-powered sensors spending most of their time sleeping
- Power manager: allows powering on your sensors only while the node is awake
- Battery manager: provides common functionalities to read and report the battery level
- Remote configuration: allows configuring remotely the node without the need to have physical access to it
- Built-in personalities: for the most common sensors, provide embedded code so to allow their configuration with a single line
Documentation available on: https://github.com/mysensors/NodeManager
*/
// load user settings
#include "config.h"
// include supporting libraries
#ifdef MY_GATEWAY_ESP8266
#include <ESP8266WiFi.h>
#endif
// load MySensors library
#include <MySensors.h>
// load NodeManager library
#include "NodeManager.h"
// create a NodeManager instance
NodeManager nodeManager;
// before
void before() {
// setup the serial port baud rate
Serial.begin(MY_BAUD_RATE);
/*
* Register below your sensors
*/
nodeManager.setSleep(SLEEP,1,MINUTES);
sensor_id = nodeManager.registerSensor(SENSOR_MOTION,3);
SensorMotion* sensorMotion = ((SensorMotion*)nodeManager.getSensor(sensor_id));
sensorMotion->setDebounce(50);
sensorMotion->setTriggerTime(4000);
/*
* Register above your sensors
*/
nodeManager.before();
}
// presentation
void presentation() {
// call NodeManager presentation routine
nodeManager.presentation();
}
// setup
void setup() {
// call NodeManager setup routine
nodeManager.setup();
}
// loop
void loop() {
// call NodeManager loop routine
nodeManager.loop();
}
// receive
void receive(const MyMessage &message) {
// call NodeManager receive routine
nodeManager.receive(message);
}
// receiveTime
void receiveTime(unsigned long ts) {
// call NodeManager receiveTime routine
nodeManager.receiveTime(ts);
}
I get this node log on serial:
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 MCO:BGN:BFR
REG I=1 P=2 P=1 T=16
NodeManager v1.5
INT1 M=255
INT2 M=3
6 TSM:INIT
10 TSF:WUR:MS=0
17 TSM:INIT:TSP OK
19 TSF:SID:OK,ID=1
21 TSM:FPAR
57 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
1125 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
1130 !TSF:MSG:PONG RECV,INACTIVE
2064 !TSM:FPAR:NO REPLY
2066 TSM:FPAR
2102 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2120 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
2125 TSF:MSG:FPAR OK,ID=0,D=1
3100 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
4110 TSM:FPAR:OK
4111 TSM:ID
4112 TSM:ID:OK
4114 TSM:UPL
4117 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
6124 TSM:UPL
6126 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
6458 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
6463 TSF:MSG:PONG RECV,HP=1
6465 TSM:UPL:OK
6467 TSM:READY:ID=1,PAR=0,DIS=1
6471 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
6478 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
6483 !TSF:MSG:PONG RECV,INACTIVE
6490 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
6497 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
6505 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
RADIO OK
8513 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=11,sg=0,ft=0,st=OK:NodeManager
8522 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
PRES I=200, T=23
8563 !TSF:MSG:SEND,1-1-0-0,s=200,c=0,t=23,pt=0,l=0,sg=0,ft=0,st=NACK:
PRES I=201, T=30
8605 !TSF:MSG:SEND,1-1-0-0,s=201,c=0,t=30,pt=0,l=0,sg=0,ft=1,st=NACK:
BATT V=4.57 P=100
SEND D=0 I=201 C=0 T=38 S= I=0 F=4.57
8683 !MCO:SND:NODE NOT REG
8725 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=2,st=NACK:100
PRES I=1 T=1
8767 !TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=1,pt=0,l=0,sg=0,ft=3,st=NACK:
READY
8773 MCO:REG:REQ
8811 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=4,st=NACK:2
10818 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=5,st=OK:2
12825 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
13209 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
13214 MCO:PIM:NODE REG=1
13216 MCO:BGN:STP
MY I=1 M=1
13218 MCO:BGN:INIT OK,TSP=1
SLEEP 60s
13222 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
13230 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:12
13236 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
13241 MCO:PIM:NODE REG=1
13736 MCO:SLP:TPD
13737 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
13741 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
13748 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:530
14254 MCO:SLP:TPD
14255 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
14258 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
14265 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:1047
14772 MCO:SLP:TPD
14773 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
14776 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
14783 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:1565
15290 MCO:SLP:TPD
15291 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
15294 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
15337 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=NACK:2083
15843 MCO:SLP:TPD
15844 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
15847 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
15890 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=1,st=NACK:2636
16396 MCO:SLP:TPD
16397 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
16400 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
16443 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=2,st=NACK:3189
16949 MCO:SLP:TPD
16950 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
16953 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
16960 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=3,st=OK:3742
17467 MCO:SLP:TPD
17468 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
17471 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
17478 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:4260
17985 MCO:SLP:TPD
17986 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
17989 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
17996 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:4778
18503 MCO:SLP:TPD
18504 MCO:SLP:WUP=-2
AWAKE
BATT V=4.61 P=100
SEND D=0 I=201 C=0 T=38 S= I=0 F=4.61
18615 !TSF:MSG:SEND,1-1-0-0,s=201,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=NACK:4.61
18658 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=1,st=NACK:100
SLEEP 60s
18665 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
18707 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=2,st=NACK:5454
19214 MCO:SLP:TPD
19215 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
19218 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
19261 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=3,st=NACK:6007
19767 MCO:SLP:TPD
19768 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
19771 MCO:SLP:MS=60000,SMS=1,I1=255,M1=255,I2=0,M2=3
19814 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=4,st=NACK:6560
20320 MCO:SLP:TPD
20321 MCO:SLP:WUP=-2
AWAKE
SLEEP 60s
I know I'm loosing a lot of communication but, I'm just trying to test at the moment.
Oh and I don't have any sensors connected to this node at the moment, so there is no PIR sending pin high.
the voltage between ground and pin 2 is 0.28v
I'm really struggling with this.
If I run the mysensors example it works as expected.
any help would be much appreciated