Arduino Pro Mini Reed Switch Sleep Mode Issue

Hello everyone,

I am trying to security system for my house. For windows i am trying to make transmitter modules.
In module i am using;
STX882
Arduino Pro Mini 3v3
Reed Sensor (Door Sensor)
And couple resistor and capacitor for voltage divider for measuring battery.

My problem is my arduino pro mini's sleep mode interrupt is not working properly. I changed reed sensors and also arduinos. But couldn't solve problem. The thing is: I want to wake my arduino when door is open. So we knew that we need to catch "edge". For my sensor values closed state value = 1, opened state value = 0. I am trying to catch this changement with FALLING function in interrupt. But arduino is always waking when sensor is closed (0 --> 1). In every action, every changing situation. Even if change the FALLING, RISING AND LOW.

#include <avr/sleep.h>
#include <avr/power.h>

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();

int interruptPin = 2;

int batPin = A0;
int batStatus;
float batVolt;


void pin2Interrupt(void)
{
  /* This will bring us back from sleep. */
  
  /* We detach the interrupt to stop it from 
   * continuously firing while the interrupt pin
   * is low.
   */
//  detachInterrupt(0);
}


void enterSleep(void)
{
  
  /* Setup interruptPin as an interrupt and attach handler. */
  attachInterrupt(0, pin2Interrupt, FALLING);
  delay(100);
  
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  
  sleep_enable();
  
  sleep_mode();
  
  /* The program will continue from here. */
  
  /* First thing to do is disable sleep. */
  sleep_disable();
  detachInterrupt(0);
}

void setup()
{
//  Serial.begin(9600);
  
  mySwitch.enableTransmit(3);
  
  /* Setup the pin direction. */
  pinMode(interruptPin, INPUT);
  
//  Serial.println("Initialization complete.");
}
int state = 0;
void loop()
{ 
    batStatus = analogRead(batPin);
                                                                            
    mySwitch.send(5393, 24);      // 5393 = 1 
//  Serial.println("/**********Woke up************");
                                                                            
  digitalWrite(LED_BUILTIN, HIGH);
  delay(250);
  digitalWrite(LED_BUILTIN, LOW);
//  delay(1000);
//  Serial.println("Going to Sleep");
//  delay(200);

  enterSleep();
}

I changed so many things. I deleted a few delays that improved interrupt. But still arduino can't detect opening. Only interrupint when closing.

Thanks in advance.

Here is the part of the schematic:

Schematic

I solved it. My Vcc connection splitted up. Also now i am working with this code from the website: Atmega Power

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.