Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. siod
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    siod

    @siod

    15
    Reputation
    143
    Posts
    1286
    Profile views
    1
    Followers
    1
    Following
    Joined Last Online
    Location Duisburg, Germany

    siod Follow

    Best posts made by siod

    • RE: My Slim 2AA Battery Node

      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...

      posted in My Project
      siod
      siod
    • RE: [SOLVED] Node not uisng it´s ID!?

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

      Thx for your superfast support!!

      posted in Troubleshooting
      siod
      siod
    • RE: [SOLVED] call of overloaded 'sleep(int, int)' is ambiguous

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

      posted in Troubleshooting
      siod
      siod
    • RE: gw.sleep on battery powered magnet door switch

      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! 👍

      posted in My Project
      siod
      siod
    • RE: [Tutorial] How to burn 1Mhz & 8Mhz bootloader using Arduino IDE 1.6.5-r5

      very good work instruction, thank you !! 👍

      posted in Development
      siod
      siod
    • RE: can´t upload my sketches anymore!!!

      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...

      posted in Troubleshooting
      siod
      siod
    • RE: My Slim 2AA Battery Node

      @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...

      posted in My Project
      siod
      siod
    • RE: [Tutorial] How to burn 1Mhz & 8Mhz bootloader using Arduino IDE 1.6.5-r5

      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 😢

      posted in Development
      siod
      siod
    • RE: How To Debug

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

      posted in Troubleshooting
      siod
      siod
    • RE: Slim Node as a Mini 2AA Battery PIR Motion Sensor

      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);
      }
      
      posted in My Project
      siod
      siod

    Latest posts made by siod

    • RE: [SOLVED] call of overloaded 'sleep(int, int)' is ambiguous

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

      posted in Troubleshooting
      siod
      siod
    • RE: [SOLVED] Node not uisng it´s ID!?

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

      Thx for your superfast support!!

      posted in Troubleshooting
      siod
      siod
    • [SOLVED] Node not uisng it´s ID!?

      I have a problem with one of my nodes. I assigned Node ID 10 to it, but it seems like it´s requesting an ID from the gateway!? This is my gateway output when I power on the Node:

      0;255;3;0;9;3513128927 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
      0;255;3;0;9;3513128933 TSF:MSG:BC
      0;255;3;0;9;3513128936 TSF:MSG:FPAR REQ,ID=255
      0;255;3;0;9;3513128941 TSF:PNG:SEND,TO=0
      0;255;3;0;9;3513128944 TSF:CKU:OK
      0;255;3;0;9;3513128947 TSF:MSG:GWL OK
      0;255;3;0;9;3513130002 TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
      0;255;3;0;9;3513130893 TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
      0;255;3;0;9;3513130900 Sending message on topic: mygateway1-out/255/255/3/0/3
      0;255;3;0;9;3513132862 TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
      0;255;3;0;9;3513132869 Sending message on topic: mygateway1-out/255/255/3/0/3
      0;255;3;0;9;3513134829 TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
      0;255;3;0;9;3513134836 Sending message on topic: mygateway1-out/255/255/3/0/3
      0;255;3;0;9;3513136797 TSF:MSG:READ,255-255-0,s=255,c=3,t=3,pt=0,l=0,sg=0:
      0;255;3;0;9;3513136804 Sending message on topic: mygateway1-out/255/255/3/0/3
      0;255;3;0;9;3513148605 TSF:MSG:READ,255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
      0;255;3;0;9;3513148612 TSF:MSG:BC
      0;255;3;0;9;3513148615 TSF:MSG:FPAR REQ,ID=255
      0;255;3;0;9;3513148619 TSF:PNG:SEND,TO=0
      0;255;3;0;9;3513148623 TSF:CKU:OK
      

      and this is my Node´s sketch:

      
      #define MY_RADIO_NRF24
      
      #include <MySensors.h>
      #include <SPI.h>
      
      
      // Define Node ID
      #define MY_NODE_ID 10
      #define MY_PARENT_NODE_ID 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
      
      //Kontaktschalter
      #define CHILD_ID 1
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      
      
      //MySensor gw;
      
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);
      MyMessage msgbatt(CHILD_ID_BATT,V_VOLTAGE);
      
      void setup()  
      {  
        int  buzzer = 7;  //Buzzer Anschlusspin
        pinMode(buzzer, OUTPUT); 
        pinMode(13,OUTPUT);
        digitalWrite(13,HIGH); 
        digitalWrite(buzzer, HIGH);
        wait(50);
        digitalWrite(buzzer, LOW);
        wait(50);
        digitalWrite(buzzer, HIGH);
        wait(50);
        digitalWrite(buzzer, LOW);
        wait(50);
        digitalWrite(buzzer, HIGH);
        wait(50);
        digitalWrite(buzzer, LOW);
        //gw.begin(NULL, MY_NODE_ID, true);
      
       // Setup the button
        pinMode(BUTTON_PIN,INPUT);
      
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN,HIGH);
      
      
      
          //Batterysensor
           // use the 1.1 V internal reference
      #if defined(__AVR_ATmega2560__)
         analogReference(INTERNAL1V1);
      #else
         analogReference(INTERNAL);
      #endif
         // Send the sketch version information to the gateway and Controller
      }
        // 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.
        void presentation()
      {
          sendSketchInfo("Wohunungstuer Alarm", "1.0");
          wait(500);
          present(CHILD_ID, S_DOOR);
          wait(500);
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
           //Türkontakt prüfen:
        uint8_t value;
        static uint8_t sentValue = 2;
        
         value = digitalRead(BUTTON_PIN);
      
        if (value==HIGH){
               //Buzzer wird ausgelöst
             int  buzzer = 7;  //Buzzer Anschlusspin
        pinMode(buzzer, OUTPUT);
        digitalWrite(buzzer, HIGH);
        wait(500);
        digitalWrite(buzzer, LOW);
        wait(500);
        digitalWrite(buzzer, HIGH);
        wait(500);
        digitalWrite(buzzer, LOW);
        wait(500);
        digitalWrite(buzzer, HIGH);
        wait(500);
        digitalWrite(buzzer, LOW);
        wait(2000);
        digitalWrite(buzzer, HIGH);
        wait(500);
        digitalWrite(buzzer, LOW);
        wait(500);
        digitalWrite(buzzer, HIGH);
        wait(500);
        digitalWrite(buzzer, LOW);
        wait(500);
        digitalWrite(buzzer, HIGH);
        wait(500);
        digitalWrite(buzzer, LOW);  
        }
      
      
        // Short wait to allow buttons to properly settle
        wait(5);
      
        //Batterysensor
        // get the battery Voltage
         int sensorValue = analogRead(BATTERY_SENSE_PIN);
         #ifdef DEBUG
         Serial.println(sensorValue);
         #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;
      
         #ifdef DEBUG
         Serial.print("Battery Voltage: ");
         Serial.print(batteryV);
         Serial.println(" V");
      
         Serial.print("Battery percent: ");
         Serial.print(batteryPcnt);
         Serial.println(" %");
         #endif
      
         if (oldBatteryPcnt != batteryPcnt) {
           // Power up radio after sleep
           sendBatteryLevel(batteryPcnt);
           wait(500);
           send(msgbatt.set(batteryPcnt),true);
           wait(500);
           oldBatteryPcnt = batteryPcnt;
         }
      
      
      
      
        if (value != sentValue) {
          // Value has changed from last transmission, send the updated value
          send(msg.set(value == HIGH ? 1 : 0),true);
          wait(500);
          sentValue = value;
        }
      
        // Sleep until something happens with the sensor
        digitalWrite(13,LOW);
        Serial.println("Sleep");
        sleep(BUTTON_PIN - 2, CHANGE);// changing Secondary button to correct pin (-3) does not work. So keep it on (-2)
       }
      

      What is wrong here?

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

      Hi,

      I have an older sketch which I modified and want to upload again now to my Arduino. I am using Lib 2.2.0 now, but I am getting this error at this line:

      sleep(BUTTON_PIN - 2, CHANGE);
      
      call of overloaded 'sleep(int, int)' is ambiguous
      

      The code worked very well in the past, so whats wrong here now?

      edit: I´m using Arduino IDE 1.8.5
      edit2: I can compile using lib 2.0.0. So there must have been a change in the meantime.

      posted in Troubleshooting
      siod
      siod
    • Sonoff Pow with Tasmota: HowTo MQTT?

      Hi,

      I´ve successfully flashed Tasmota to my Sonoff Pow and I see it´s connected to my MQTT Broker, but I haven´t understood how to send commands to the Pow over MQTT.

      e.g. in the docs they are saying this:

      *To execute these, issue (publish) these MQTT requests

      MQTT topic MQTT payload
      cmnd/my_device/power <empty>
      cmnd/my_device/power on
      cmnd/my_device/power off*

      But actually the device is not turning off or on. One imortant thing is I don´t know what is "my_device".
      Finally I need to know how I could best combine this device with my Openhab2 and Mysesnsors setup.

      Any help is appreciated, thanks in advance!

      posted in Hardware
      siod
      siod
    • RE: Need help with ESP8266 Node in MQTT Network

      Hi guys,

      thanks to both of you! Thanks @TimO for the general information and thanks to @kimot for finding the exact solution for what I was looking for. Awesome!!

      I will give it a try as soon as possible...

      posted in Development
      siod
      siod
    • RE: Need help with ESP8266 Node in MQTT Network

      well, this looks quiet interesting, but I think I´m quicker if I just use my actual Arduino IDE setup and some lines of code to achieve my goal because I feel more comfortable wit this IDE...

      But I will have a look at ESPEasy anyway, thanks for that!!

      edit: Do I have to upload the ESP8266 Gateway Code to every ESP8266 Node?

      What I actually want to achieve is to build a IR Sender which sends IR commands to my TV or other IR devices that where sent by openhab.

      posted in Development
      siod
      siod
    • Need help with ESP8266 Node in MQTT Network

      Hi guys,

      I would like to add an ESP8266 WIFI Node to my existing NRF24 MQTT Network. I´ve set up a Mosquitto broker on my LAN connected Raspberry pi with openhab2 running on it acting as the controller.
      Unfortunately I have no idea where to start to include the new WIFI node to talk to my controller. Does someone know a tutorial could give me some code examples of where to start?

      Thanks in advance!

      posted in Development
      siod
      siod
    • What settings for ESP8266 Node?

      Hi,

      I would like to convert the below sketch to a ESP8266 /WeMos D1 Mini compatible sketch. Do I have to change MY RADIO NRF24 to ESP8266 or sth like that? PS I am using MQTT and Openhab 2...

      /*
       * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
       * An IR LED must be connected to Arduino PWM pin 3.
       * Version 0.1 July, 2009
       * Copyright 2009 Ken Shirriff
       * http://arcfn.com
       */
      
      #define MY_RADIO_NRF24 
      // Define Node ID
      #define MY_NODE_ID 5
      //#define MY_PARENT_NODE_ID 50 //Repeater Node 1!
      //#define MY_PARENT_NODE_IS_STATIC
      
      #include <MySensors.h>
      #include <SPI.h>
      #include <IRremote.h>
      
      #define CHILD_ID 1   // Id of the sensor child
      
      IRsend irsend;
      
      // Initialize message
      MyMessage msg(CHILD_ID, V_IR_SEND);
      
      void setup()
      {
        Serial.begin(9600);
      }
      
      void presentation()
      {
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo("LED Licht TV Steuerung", "1.0");
      
          // Register all sensors to gw (they will be created as child devices)
          present(CHILD_ID, S_IR);
      }
      
      void loop() {
      
      
      }
      
      void receive(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
         Serial.println(F("Incoming Message:"));
         Serial.println(message.getString());
        if (message.type == V_IR_RECEIVE) {
          // Send command to Turn LEDs On
          if (message.getString("anaus")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFF02FD, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          } 
              // Send command to Turn LEDs Red
          else if (message.getString("rot")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFF1AE5, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
              // Send command to Turn LEDs green
          else if (message.getString("gruen")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFF9A65, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
                  // Send command to Turn LEDs blue
          else if (message.getString("blau")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFFA25D, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
                      // Send command to Turn LEDs white
          else if (message.getString("weiss")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFF22DD, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
                          // Send command to Turn LEDs faster
          else if (message.getString("schneller")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFFE817, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
                              // Send command to Turn LEDs slower
          else if (message.getString("langsamer")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFFC837, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
                     // Send command to Turn LEDs brighter
          else if (message.getString("heller")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFF3AC5, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
              // Send command to Turn LEDs darker
          else if (message.getString("dunkler")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFFBA45, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
                  // Send command to Turn LEDs Fade7
          else if (message.getString("fade7")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFFE01F, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
                      // Send command to Turn LEDs flash
          else if (message.getString("flash")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFFD02F, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
          // Send command to Turn LEDs Jump7
          else if (message.getString("jump")) { 
          for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFFA05F, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
          else{ 
            // if nothing else matches, do the default
            // default is optional
            Serial.println("Nicht belegt");
            }
         }
       }
      
      posted in Troubleshooting
      siod
      siod
    • RE: How to send MQTT message from controller to Node?

      This the code I got so far, which does not work 😞

      #define MY_RADIO_NRF24 //MySensor Library auf NRF24 Funkmodul einstellen, muss vor MySensor.h Initialisierung geschehen
      // Define Node ID
      #define MY_NODE_ID 5
      //#define MY_PARENT_NODE_ID 50 //Repeater Node 1!
      //#define MY_PARENT_NODE_IS_STATIC
      
      #include <MySensors.h>
      #include <SPI.h>
      #include <IRremote.h>
      
      #define CHILD_ID 1   // Id of the sensor child
      
      IRsend irsend;
      
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_IR_SEND);
      
      void setup()
      {
        Serial.begin(9600);
      }
      
      void presentation()
      {
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo("LED Licht TV Steuerung", "1.0");
      
          // Register all sensors to gw (they will be created as child devices)
          present(CHILD_ID, S_IR);
      }
      
      void loop() {
      
      
      }
      
      void receive(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type == V_IR_SEND) {
          // Send command to Turn LEDs On
          if (message.getString() == "FF02FD") { // ???
            for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFF02FD, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
        }
      }
      

      edit: from the serial monitor I see that the node receives the "FF02FD" String, but it does not enter this part

          if (message.getString() == "FF02FD") { // ???
            for (int i = 0; i < 3; i++) {
              irsend.sendNEC(0xFF02FD, 32);
              Serial.println(message.getString());
              Serial.println("Message sent");
              delay(40);
            }
          }
      

      edit2:

      This is what I am sending from openhab over MQTT:

      mygateway1-in/5/1/1/0/32
      

      edit3:

      Ok, now I see where it fails:

      message.getString()
      

      contains FF02FD

      but when I say

      if (message.getString() == "FF02FD")
      

      it does not recognise the FF02FD. But I don´t understand why

      edit4:

      Ok, I got it, finally...:

      message.getString("FF02FD");
      

      😲 👊

      posted in Troubleshooting
      siod
      siod