Hi All,
After sucesfully implementing Homeduino I wanted to expand my new hobby
My wife is getting crazy with all the automatic lights…
I build a my sensor Controller (serial gateway) and I started with a simple BinarySwitchSensor.
So far so good.
This site: [http://forum.mysensors.org/topic/350/problems-getting-sensorid/15]
helped me a lot to set the node Id in the Arduino:
Define:
int node_id = X; (X as the node id you have open to assign)
and add
gw.begin(NULL, node_id);
When I use Arduino serial monitor on the gateway I see that that this works, so no problems with that:
0;0;3;0;14;Gateway startup complete.
0;0;3;0;9;read: 12-12-0 s=3,c=1,t=16,pt=2,l=2:0
12;3;1;0;16;0
0;0;3;0;9;read: 12-12-0 s=3,c=1,t=16,pt=2,l=2:1
12;3;1;0;16;1
But… No change in my “doorsensor” in Pimatic.
I dont exacly know were I can find loggings ( only the ones in Pimatic)
What do I wrong
My Configs:
{
"plugin": "mysensors",
"driver": "serialport",
"protocols": "1.4.1",
"driverOptions": {
"//": "'/dev/ttyUSB1' if using serial Gateway",
"serialDevice": "/dev/ttyMySensorsGateway",
"baudrate": 115200
}
},
and
{
"id": "Door",
"name": "Door",
"class": "MySensorsButton",
"nodeid": 12,
"sensorid": 1
},
and the Arduino sketch I modified just a little bit from the original
// Simple binary switch example
// Connect button or door/window reed switch between
// digitial I/O pin 3 (BUTTON_PIN below) and GND.
#include <MySensor.h>
#include <SPI.h>
#include <Bounce2.h>
#define CHILD_ID 3
#define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
MySensor gw;
Bounce debouncer = Bounce();
int oldValue=-1;
int node_id = 12;
// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(CHILD_ID,V_TRIPPED);
void setup()
{
gw.begin(NULL, node_id);
// Setup the button
pinMode(BUTTON_PIN,INPUT);
// Activate internal pull-up
digitalWrite(BUTTON_PIN,HIGH);
// After setting up the button, setup debouncer
debouncer.attach(BUTTON_PIN);
debouncer.interval(5);
// Register binary input sensor to gw (they will be created as child devices)
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
gw.present(CHILD_ID, S_DOOR);
}
// Check if digital input has changed and send in new value
void loop()
{
debouncer.update();
// Get the update value
int value = debouncer.read();
if (value != oldValue) {
// Send in the new value
gw.send(msg.set(value==HIGH ? 1 : 0));
oldValue = value;
}
}