Compact battery-powered motion + temperature + humidity project


  • Contest Winner

    Very compact battery powered project based on @NeverDie Arduino Pro Mini Shield for RFM69(H)W board (https://www.openhardware.io/view/268/Arduino-Pro-Mini-Shield-for-RFM69HW) with attached a:

    I'd warmly recommend that PIR sensor, it's tiny, it works down to 2.7v (so not requiring any voltage regulator for this 3.3v project especially if the arduino runs at 1Mhz like all my boards), consumes nothing and produces very little false positives.

    Code and pictures down below.

    /**********************************
     * MySensors node configuration
     */
    
    // General settings
    #define SKETCH_NAME "Pir"
    #define SKETCH_VERSION "1.0"
    //#define MY_DEBUG
    #define MY_NODE_ID 6
    
    // RFM69 radio settings
    #define MY_RADIO_RFM69
    //#define MY_RFM69_FREQUENCY RFM69_433MHZ
    #define MY_IS_RFM69HW
    #define MY_RFM69_NEW_DRIVER
    //#define MY_RFM69_ENABLE_ENCRYPTION
    #define MY_RFM69_NETWORKID 110
    //#define MY_DEBUG_VERBOSE_RFM69
    //#define MY_RF69_IRQ_PIN D1
    //#define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN
    //#define MY_RF69_SPI_CS D2
    //#define MY_RFM69_ATC_MODE_DISABLED
    
    // Advanced settings
    #define MY_BAUD_RATE 9600
    //#define MY_SMART_SLEEP_WAIT_DURATION_MS 500
    #define MY_SPLASH_SCREEN_DISABLED
    //#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE
    //#define MY_SIGNAL_REPORT_ENABLED
    
    /***********************************
     * NodeManager modules for supported sensors
     */
    
    #define USE_BATTERY
    #define USE_SIGNAL
    #define USE_CONFIGURATION
    #define USE_SHT21
    #define USE_INTERRUPT
    
    /***********************************
     * NodeManager built-in features
     */
    
    // Enable/disable NodeManager's features
    #define FEATURE_DEBUG ON
    #define FEATURE_POWER_MANAGER ON
    #define FEATURE_INTERRUPTS ON
    #define FEATURE_CONDITIONAL_REPORT OFF
    #define FEATURE_EEPROM OFF
    #define FEATURE_SLEEP ON
    #define FEATURE_RECEIVE ON
    #define FEATURE_TIME OFF
    #define FEATURE_RTC OFF
    #define FEATURE_SD OFF
    #define FEATURE_HOOKING OFF
    
    /***********************************
     * Load NodeManager Library
     */
    
    #include "NodeManagerLibrary.h"
    NodeManager node;
    
    /***********************************
     * Add your sensors below
     */
    
    // built-in sensors
    SensorBattery battery(node);
    SensorConfiguration configuration(node);
    SensorSignal signal(node);
    
    // Attached sensors
    SensorSHT21 sht21(node);
    SensorMotion motion(node,3);
    
    /***********************************
     * Main Sketch
     */
    
    // before
    void before() {
      // setup the serial port baud rate
      Serial.begin(MY_BAUD_RATE);
      /*
      * Configure your sensors below
      */
    
      // battery sensor
      battery.setMinVoltage(1.8);
      battery.setMaxVoltage(3.2);
      
      // pir sensor
      motion.setInterruptMode(RISING);
      motion.setInitialValue(LOW);
    
      // sht21 sensor
      sht21.setReportIntervalMinutes(5);
    
      // node configuration
      node.setSleepMinutes(5);
      
      /*
      * Configure your sensors above
      */
      node.before();
    }
    
    // presentation
    void presentation() {
      // call NodeManager presentation routine
      node.presentation();
    }
    
    // setup
    void setup() {
      // call NodeManager setup routine
      node.setup();
    }
    
    // loop
    void loop() {
      // call NodeManager loop routine
      node.loop();
    }
    
    #if FEATURE_RECEIVE == ON
    // receive
    void receive(const MyMessage &message) {
      // call NodeManager receive routine
      node.receive(message);
    }
    #endif
    
    #if FEATURE_TIME == ON
    // receiveTime
    void receiveTime(unsigned long ts) {
      // call NodeManager receiveTime routine
      node.receiveTime(ts);
    }
    #endif
    

    0_1532192269076_1.png

    0_1532192281955_2.png


Log in to reply
 

Suggested Topics

56
Online

11.4k
Users

11.1k
Topics

112.7k
Posts