@sweebee
no, not direct, i use the header
hmm… no, i have ~0,8mA in sleep mode, maybe i do something wrong? but following code should do something about 5 seconds after bootup and then go to sleep.
#include <MySensor.h>
#include <SPI.h>
#include <Bounce2.h>
#define CHILD_ID 4
#define BUTTON_PIN 8 // Arduino Digital I/O pin for button/reed switch
MySensor gw;
Bounce debouncer = Bounce();
int oldValue=-1;
// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(CHILD_ID,V_TRIPPED);
void setup()
{
gw.begin();
// Setup the button
pinMode(BUTTON_PIN,INPUT);
pinMode(6, OUTPUT); // Power Pin for A/D Module
// Activate internal pull-up
digitalWrite(BUTTON_PIN,LOW);
// 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()
{
digitalWrite(6, HIGH); // Power on YL-38 A/D Module
delay(2000);
debouncer.update();
// Get the update value
int value = debouncer.read();
if (value != oldValue) {
// Send in the new value
gw.send(msg.set(value==LOW ? 1 : 0));
oldValue = value;
}
delay(2000);
digitalWrite(6, LOW); // Power off YL-38 A/D Module
gw.sleep(3600000); // wait a hour, then reloop
}
btw, the serial output shows me only a ÿ
on 9600 Baud, ²¡¤©¯€©®©´€¦¡©¬Š
on 115200 Baud