Detect who wake up sensor .. INT0,INT1 or timeout..



  • Hi.
    I tested **Binary Sensor Sleep ** and working ... Is there any way how to check that wake up sensor from Timeout setting value or from INT1 , INT0??
    I want every 1 minutes wake up and send info about sensor (battery , temperature) to serial gateway ..

    regards.


  • Admin

    /**
    	 * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
    	 * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
    	 * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
    	 * @param interrupt Interrupt that should trigger the wakeup
    	 * @param mode RISING, FALLING, CHANGE
    	 * @param ms Number of milliseconds to sleep or 0 to sleep forever
    	 * @return true if wake up was triggered by pin change and false means timer woke it up.
    	 */
    	bool sleep(uint8_t interrupt, uint8_t mode, unsigned long ms=0);
    
    	/**
    	 * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change for two separate interrupts.
    	 * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
    	 * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3
    	 * @param interrupt1 First interrupt that should trigger the wakeup
    	 * @param mode1 Mode for first interrupt (RISING, FALLING, CHANGE)
    	 * @param interrupt2 Second interrupt that should trigger the wakeup
    	 * @param mode2 Mode for second interrupt (RISING, FALLING, CHANGE)
    	 * @param ms Number of milliseconds to sleep or 0 to sleep forever
    	 * @return Interrupt number wake up was triggered by pin change and negative if timer woke it up.
    	 */
    	int8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms=0);
    
    


  • Hi.
    Then in Loop declare new wariable for example : static int8_t wakeup;
    and do this : wakeup=sensor_node.sleep(...); and test if less then 0 then timeout or more then 0 are INT0 or INT1
    is it right??


  • Admin

    yep! đź‘Ť


Log in to reply
 

Suggested Topics

  • 1
  • 2
  • 198
  • 2
  • 2
  • 1

21
Online

11.2k
Users

11.1k
Topics

112.5k
Posts