Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
siodS

siod

@siod
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
143
Topics
27
Shares
0
Groups
0
Followers
1
Following
1

Posts

Recent Best Controversial

  • My Slim 2AA Battery Node
    siodS siod

    just want to mention that I am using successfully the same Bootloader @Komaandy is using for about 2 weeks now. So it seems like my problems with freezing nodes are depending on a bad or too slow bootloader...

    My Project

  • [SOLVED] Node not uisng it´s ID!?
    siodS siod

    damn it, that did the trick!! Just haven´t noticed...

    Thx for your superfast support!!

    Troubleshooting

  • [SOLVED] call of overloaded 'sleep(int, int)' is ambiguous
    siodS siod

    Hi, thanks for your help, that´s the solution!!

    Troubleshooting

  • gw.sleep on battery powered magnet door switch
    siodS siod

    well, as you can see, if you don´t know the libraries exactly you accept things as they are or as they seem to be. I wasn´t aware that you can just set the wakeup function to 0. So this said I would like to thank you @AWI for your patience and your willingness of explaining also the most obvious things! :thumbsup:

    My Project

  • [Tutorial] How to burn 1Mhz & 8Mhz bootloader using Arduino IDE 1.6.5-r5
    siodS siod

    very good work instruction, thank you !! :thumbsup:

    Development

  • can´t upload my sketches anymore!!!
    siodS siod

    I had to re-download and reinstall the complete 1.5 library what solved the issue. Don´t know what happened but that helped! Just the quick and dirty way...

    Troubleshooting

  • My Slim 2AA Battery Node
    siodS siod

    @m26872 First of all: I already got so much help and I am very grateful for that, awesome community!

    I don´t think I will ever find the problem with those sensors and because of the lack of time I have (familiy, work...) I think looking for the problem would take longer than just build a new sensor. And that´s what I will do next: I will just build another node, one step after the other and so I can validate if it maybe is a hardware problem or a code problem. BTW my whole sketch is just a few posts above this one...

    So I will come back after I started over...

    My Project

  • [Tutorial] How to burn 1Mhz & 8Mhz bootloader using Arduino IDE 1.6.5-r5
    siodS siod

    thx for the tutorial. I perfomred every step you described, but I get errors when trying to upload a sketch:

    And I also get this error message:

    I tried to upload the 1MHz version

    edit:

    some more info form verbose mode output:

    edit2:

    Another problem: I could burn the bootloader on to one of my ATMega328 MCU´s but I needed to use a 16MHz Crystal when uploading for the first time. Now I can just burn and burn the bootloader again. Here ist the output:

    But it is the only MCU that works, all the other give the "Yikes" error, also when 16MHz Crystal is connected:

    Any explanation?

    - bootloader burning problem solved by rebuilding the wiring.

    - for some reason I could upload the sketch now, don´t ask me why. In the end I just reuploaded again and again...I hope I will be able to upload sketches to the next MCU´s as well

    Sorry for asking so many questions, but after spending hours and hours of setting up a raspberry pi with openhab, MQTT Broker and MQTT Gateway I am so close to finishing my first standalone sensor and it´s not going any further, I could cry :cry:

    Development

  • How To Debug
    siodS siod

    Ok guys, thanks for your quick replies and please excuse my late reply...

    Troubleshooting

  • Slim Node as a Mini 2AA Battery PIR Motion Sensor
    siodS siod

    Nope, 2.2 is giving me the same fail trip messages.
    When using IDE 1.6.5 with 1.5.4 I don´t even get it compiled, Arduino is automatically using 2.2.0 library from 1.8.2 version which is, of course, still installed on my system and I don´t want to uninstall it...

    edit: Ok, the way @komaandy proposed is working, though I like the other sketch more...

    edit2: Well, seems like it has sth. to do with the battery sensing: when removing this part from void loop() it works as it is supposed to (see what I commented out between /* and */):

    void loop() 
    {
        //Batterysensor
      // get the battery Voltage
       /*int sensorValue = analogRead(BATTERY_SENSE_PIN);
       #ifdef DEBUG
       #endif
       
       int batteryPcnt = sensorValue / 10;
         
         gw.sendBatteryLevel(batteryPcnt);
         gw.wait(500);
         gw.send(msgbatt.set(batteryPcnt));
         gw.wait(500);
      */
      if (interruptReturn) {  // Woke up by rising pin
      gw.send(msg.set("1"));  // Just send trip (set) commands to controller. (Let controller reset and decide what to do with it.)
      irtCounter++;
    
      }
      
      gw.sleep(3000);  // Make sure everything is stable before start to sleep with interrupts. (don't use "gw.wait()" here). Tests shows false trip ~2s after battery report otherwise.
    
      // Sleep until interrupt comes in on motion sensor or sleep time passed.
      interruptReturn = gw.sleep(MOTION_INPUT_PIN-2,CHANGE, ONE_DAY_SLEEP_TIME);
      // DEBUG_PRINT("interruptReturn: ");DEBUG_PRINTLN(interruptReturn);
    
    } 
    

    edit3: I obviously mixed up things, now it seems like it´s working... I will report back after some time of testing, but this should be my working code:

    /**
     * EgSlimReed2
     * Sketch for Slim Node and HC-SR505 based motion sensor. 
     * Inspired by:
     * - MySensors motion sensor example: http://www.mysensors.org/build/motion
     * - AWI's CR123A based Slim Node motion sensor: http://forum.mysensors.org/topic/2478/slim-cr123a-2aa-battery-node
     *
     * Created by m26872
     * Documentation: http://forum.mysensors.org...
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Test to if node can operate in some way dealing with the Pir extreme sensitivity to noise on Vcc.
     * Version 2.0 - First "production node". "Inactivity day counter" introduced.
     * 
     * DESCRIPTION
     * This sketch will only send trips as "1" to the controller. It's up to the controller to deal with the info. 
     * The motion node will not notify controller when resets back to low state and is ready for a new trip. In reality 
     * this is ~10s. And EVEN IF motion is detected continuously, there will be no new trip until motion has stopped for ~10s.  
     * The HC-SR505 is very noise sensitive and will trigger spuriously for almost any activity 
     * on Vcc (test thoroughly). To run the HC-505 at low voltages (tested flawlessly down to 1.6V), 
     * the 7133-reg and diode are removed (and possibly increase the sensitivity even further). 
     * Solution is to deal with it by interrupt type, check which source, block by sleep time etc.
     * 
     * HC-505 output connects to MOTION_INPUT_PIN (here D3) without any supporting component. Input pull-up disabled.
     * Every 24 hrs without trip, increments a counter and after "BATTERY_REPORT_DAY" counts a battery report will be sent as a heartbeat signal.
     * Else a battery report will be sent after every "BATTERY_REPORT_BY_IRT_CYCLE" motion trips.
     *
     */
    
     #define MY_RADIO_NRF24 //MySensor Library auf NRF24 Funkmodul einstellen, muss vor MySensor.h Initialisierung geschehen
    // Define Node ID
    #define MY_NODE_ID 21
    #define MY_PARENT_NODE_ID 0 //Repeater Node 1=50 / Gateway=0!
    #define MY_PARENT_NODE_IS_STATIC
    
    //Batterysensor
    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    int oldBatteryPcnt = 0;
    #define CHILD_ID_BATT 7
     
    #include <MySensor.h>
    #include <SPI.h>
    #include <Vcc.h>
    
    //#define DEBUG
    
    #define SKETCH_NAME "Motion PIR Keller_1"
    #define SKETCH_VERSION "2.0"
    #define CHILD_ID 1
    #define MOTION_INPUT_PIN 3
    #define BATTERY_REPORT_DAY 2   // Desired heartbeat(battery report) interval when inactive. 
    #define BATTERY_REPORT_BY_IRT_CYCLE 10  // Make a battery report after this many trips. Maximum report interval will also be equal to this number of days.
    #define ONE_DAY_SLEEP_TIME 86400000
    #define VCC_MIN 1.9
    #define VCC_MAX 3.3
    
    
    #ifdef DEBUG
    #define DEBUG_SERIAL(x) Serial.begin(x)
    #define DEBUG_PRINT(x) Serial.print(x)
    #define DEBUG_PRINTLN(x) Serial.println(x)
    #else
    #define DEBUG_SERIAL(x)
    #define DEBUG_PRINT(x) 
    #define DEBUG_PRINTLN(x) 
    #endif
    
    int dayCounter = BATTERY_REPORT_DAY;
    int irtCounter = 0;
    
    
    bool interruptReturn = false; // "false" will make the first loop disregard high output from HV-505 (from start-up) and make a battery report instead.
     
    Vcc vcc;
    MySensor gw;
    MyMessage msg(CHILD_ID, V_TRIPPED);
    //Battery
    MyMessage msgbatt(CHILD_ID_BATT,V_VOLTAGE);
    
    void setup()  
    {  
          //Batterysensor
         // use the 1.1 V internal reference
    #if defined(__AVR_ATmega2560__)
       analogReference(INTERNAL1V1);
    #else
       analogReference(INTERNAL);
    #endif
    
      DEBUG_SERIAL(9600);
      DEBUG_PRINTLN(("Serial started"));
      delay(100); // to settle power for radio
      gw.begin(NULL,MY_NODE_ID);
      pinMode(MOTION_INPUT_PIN, INPUT);
      digitalWrite(MOTION_INPUT_PIN, LOW);    // Disable internal pull-ups
      gw.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
      gw.present(CHILD_ID, S_MOTION);
      DEBUG_PRINTLN("Warming and blocking PIR trip for 20s.");
      gw.sleep(20000); // Wait until HC-505 warmed-up and output returned low.
    }
    void presentation()
    {
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Motion Sensor Keller_1", "1.0");
    
        // Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID, S_MOTION);
        
        //Battery
        gw.present(CHILD_ID_BATT,V_VOLTAGE);
    }
    
    void loop() 
    {
        //Batterysensor
      // get the battery Voltage
       /*int sensorValue = analogRead(BATTERY_SENSE_PIN);
       #ifdef DEBUG
       #endif
       
       int batteryPcnt = sensorValue / 10;
         
         gw.sendBatteryLevel(batteryPcnt);
         gw.wait(500);
         gw.send(msgbatt.set(batteryPcnt));
         gw.wait(500);
      */
      if (interruptReturn) {  // Woke up by rising pin
      gw.send(msg.set("1"));  // Just send trip (set) commands to controller. (Let controller reset and decide what to do with it.)
        irtCounter++;
      if (irtCounter>=BATTERY_REPORT_BY_IRT_CYCLE) {
        irtCounter=0;
        sendBatteryReport();
      }
      }
      else { // Woke up by timer  (or it's the first run)
      dayCounter++; 
      if (dayCounter >= BATTERY_REPORT_DAY) {
          dayCounter = 0;
          sendBatteryReport();
      }
      }
    
      
      
      gw.sleep(3000);  // Make sure everything is stable before start to sleep with interrupts. (don't use "gw.wait()" here). Tests shows false trip ~2s after battery report otherwise.
    
      // Sleep until interrupt comes in on motion sensor or sleep time passed.
      interruptReturn = gw.sleep(MOTION_INPUT_PIN-2,CHANGE, ONE_DAY_SLEEP_TIME);
      // DEBUG_PRINT("interruptReturn: ");DEBUG_PRINTLN(interruptReturn);
    
    } 
    
    void sendBatteryReport() {
          float p = vcc.Read_Perc(VCC_MIN, VCC_MAX, true);
          int batteryPcnt = static_cast<int>(p);
          gw.sendBatteryLevel(batteryPcnt);
    }
    

    edit4: ok, with my edited code this sketch is also working fine now with IDE 1.8.2 and lib 2.2.0 beta. So now everythings works fine!

    /**
     * EgSlimReed2
     * Sketch for Slim Node and HC-SR505 based motion sensor. 
     * Inspired by:
     * - MySensors motion sensor example: http://www.mysensors.org/build/motion
     * - AWI's CR123A based Slim Node motion sensor: http://forum.mysensors.org/topic/2478/slim-cr123a-2aa-battery-node
     *
     * Created by m26872
     * Documentation: http://forum.mysensors.org...
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Test to if node can operate in some way dealing with the Pir extreme sensitivity to noise on Vcc.
     * Version 2.0 - First "production node". "Inactivity day counter" introduced.
     * 
     * DESCRIPTION
     * This sketch will only send trips as "1" to the controller. It's up to the controller to deal with the info. 
     * The motion node will not notify controller when resets back to low state and is ready for a new trip. In reality 
     * this is ~10s. And EVEN IF motion is detected continuously, there will be no new trip until motion has stopped for ~10s.  
     * The HC-SR505 is very noise sensitive and will trigger spuriously for almost any activity 
     * on Vcc (test thoroughly). To run the HC-505 at low voltages (tested flawlessly down to 1.6V), 
     * the 7133-reg and diode are removed (and possibly increase the sensitivity even further). 
     * Solution is to deal with it by interrupt type, check which source, block by sleep time etc.
     * 
     * HC-505 output connects to MOTION_INPUT_PIN (here D3) without any supporting component. Input pull-up disabled.
     * Every 24 hrs without trip, increments a counter and after "BATTERY_REPORT_DAY" counts a battery report will be sent as a heartbeat signal.
     * Else a battery report will be sent after every "BATTERY_REPORT_BY_IRT_CYCLE" motion trips.
     *
     */
    
     //Sensor 21, erster PIR Sensor
    
    #define MY_RADIO_NRF24 //MySensor Library auf NRF24 Funkmodul einstellen, muss vor MySensor.h Initialisierung geschehen
    // Define Node ID
    #define MY_NODE_ID 21
    #define MY_PARENT_NODE_ID 50 //Repeater Node 1!
    #define MY_PARENT_NODE_IS_STATIC
    
    //Batterysensor
    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    int oldBatteryPcnt = 0;
    #define CHILD_ID_BATT 7
     
    #include <MySensors.h>
    #include <SPI.h>
    #include <Vcc.h>
    
    
    unsigned long SLEEP_TIME = 86400000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 1   // Id of the sensor child
    #define BATTERY_REPORT_DAY 2   // Desired heartbeat(battery report) interval when inactive. 
    #define BATTERY_REPORT_BY_IRT_CYCLE 10  // Make a battery report after this many trips. Maximum report interval will also be equal to this number of days.
    #define ONE_DAY_SLEEP_TIME 86400000
    #define VCC_MIN 1.9
    #define VCC_MAX 3.3
    
    int dayCounter = BATTERY_REPORT_DAY;
    int irtCounter = 0;
    bool interruptReturn = false; // "false" will make the first loop disregard high output from HV-505 (from start-up) and make a battery report instead.
    Vcc vcc;
    
    //Battery
    MyMessage msgbatt(CHILD_ID_BATT,V_VOLTAGE);
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()
    {
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
    
        //Batterysensor
         // use the 1.1 V internal reference
    #if defined(__AVR_ATmega2560__)
       analogReference(INTERNAL1V1);
    #else
       analogReference(INTERNAL);
    #endif
    }
    
    void presentation()
    {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Motion Sensor Keller_1", "1.0");
    
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_MOTION);
        
        //Battery
        present(CHILD_ID_BATT,V_VOLTAGE);
    }
    
    void loop()
    {
        //Batterysensor
      // get the battery Voltage
       /*int sensorValue = analogRead(BATTERY_SENSE_PIN);
       #ifdef DEBUG
       #endif
       
       // 1M, 470K divider across battery and using internal ADC ref of 1.1V
       // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
       // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
       // 3.44/1023 = Volts per bit = 0.003363075
       //float batteryV  = sensorValue * 0.003363075;
       int batteryPcnt = sensorValue / 10;
         
         sendBatteryLevel(batteryPcnt);
         wait(500);
         send(msgbatt.set(batteryPcnt));
         wait(500);
        */
        // Read digital motion value
        bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
    
        Serial.println(tripped);
        send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
    
            irtCounter++;
      if (irtCounter>=BATTERY_REPORT_BY_IRT_CYCLE) {
        irtCounter=0;
        sendBatteryReport();
      }
      else { // Woke up by timer  (or it's the first run)
      dayCounter++; 
      if (dayCounter >= BATTERY_REPORT_DAY) {
          dayCounter = 0;
          sendBatteryReport();
      }
      }
    
        sleep(3000);  // Sleep 3s to make sure everything is stable before we start to sleep with interrupts.
    
        // Sleep until interrupt comes in on motion sensor. Send update every 24 hours.
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    }
    void sendBatteryReport() {
          float p = vcc.Read_Perc(VCC_MIN, VCC_MAX, true);
          int batteryPcnt = static_cast<int>(p);
          sendBatteryLevel(batteryPcnt);
    }
    
    My Project

  • cannot compile new MQTT GW sketch
    siodS siod

    Mmh, thx, I just copied and pasted it from the instructions from the main page... So it must get corrected there as well...

    Thank you, I will try it later!

    edit:

    For the sake of completeness, I want to mention, that @Ernst79 already gave the hint in the comments section of "Building a MQTT Gateway" Install-Instruction on the mainpage. I just did not see it, but I would love to see @tbowmo to add this line to the code. Thank you!

    Troubleshooting

  • Repeater Node Question
    siodS siod

    @mfalkvidd great, thanks for your quick and short answer! :thumbsup:

    Troubleshooting
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular