@BulldogLowell said:
and you cn try this:
/*
this is set up for a 4 pin recv unit GND DATA DATA VCC
plug GND into D2, DATA into D3 and D4, and VCC into D5
*/
#include <MySensor.h>
#include <SPI.h>
#include <Bounce2.h>
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
#define CHILD_ID 3
#define VCC_PIN 5 // source 5V up to 40mA from this pin
#define GND_PIN 2 // sink up to 40mA on this pin
#define DATA_PIN 3 // external int 1 on Uno
MySensor gw;
const int bell = -251; // This is the value that my 433mhz doorbell sends out when button is pushed
boolean tripped = false;
unsigned long timerStart;
// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(CHILD_ID, V_TRIPPED);
void setup()
{
gw.begin();
// 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);
// 433mhz Part
pinMode(DATA_PIN, INPUT);
// just leave D4 tristated
pinMode(GND_PIN, OUTPUT);
digitalWrite(GND_PIN, LOW);
pinMode(VCC_PIN, OUTPUT);
digitalWrite(VCC_PIN, HIGH);
mySwitch.enableReceive(1); // Receiver on interrupt 1 => that is pin D3
}
void loop()
{
if (mySwitch.available())
{
tripped = (mySwitch.getReceivedValue() == bell);
if (tripped)
{
gw.send(msg.set(true));
timerStart = millis();
Serial.println(F("Ding Dong!!"));
}
mySwitch.resetAvailable(); //<<<<<<<<<< I think you want this here... I looked at the library on GitHub
}
if (tripped && millis() - timerStart > 5000UL)
{
gw.send(msg.set(false));
Serial.println(F("no activity"));
tripped = false;
}
}
Hmm, still nothing. It seems to be the 433mhz reciver part that is not working.