Navigation

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

    insomnia

    @insomnia

    0
    Reputation
    8
    Posts
    468
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    insomnia Follow

    Best posts made by insomnia

    This user hasn't posted anything yet.

    Latest posts made by insomnia

    • RE: Gas meter monitoring with optical sensor

      @rubyan

      Thanks, i have some trouble with adjusting it. I set the trct5000 when the 6 comes by the led goes on. When i use this sketch from the forum

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: 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 - Mark Verstappen
       * 
       * DESCRIPTION
       * Use this sensor to measure volume and flow of your house gasmeter.
       * You need to set the correct pulsefactor of your meter (pulses per m3).
       * The sensor starts by fetching current volume reading from gateway (VAR 1).
       * Reports both volume and flow back to gateway.
       *
       * Unfortunately millis() won't increment when the Arduino is in 
       * sleepmode. So we cannot make this sensor sleep if we also want  
       * to calculate/report flow.
       * http://www.mysensors.org/build/pulse_water
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      #include <Time.h>
      #include <TimeLib.h>
      
      #include <SPI.h>
      #include <MySensor.h>  
      
      #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
      #define SENSOR_INTERRUPT DIGITAL_INPUT_SENSOR-2        // Usually the interrupt = pin -2 (on uno/nano anyway)
      
      #define PULSE_FACTOR 100                       // Nummber of blinks per m3 of your meter (One rotation/liter)
      
      #define SLEEP_MODE false                        // flowvalue can only be reported when sleep mode is false.
      
      #define MAX_FLOW 0,1                             // Max flow (l/min) value to report. This filters outliers.
      
      #define CHILD_ID 1                              // Id of the sensor child
      
      unsigned long SEND_FREQUENCY = 30000;           // Minimum time between send (in milliseconds). We don't want to spam the gateway.
      
      MyMessage flowMsg(CHILD_ID,V_FLOW);
      MyMessage volumeMsg(CHILD_ID,V_VOLUME);
      MyMessage lastCounterMsg(CHILD_ID,V_VAR1);
      
      double ppl = ((double)PULSE_FACTOR)/1000;        // Pulses per liter
      
      volatile unsigned long pulseCount = 0;   
      volatile unsigned long lastBlink = 0;
      volatile double flow = 0;  
      boolean pcReceived = false;
      unsigned long oldPulseCount = 0;                 
      unsigned long newBlink = 0;   
      double oldflow = 0;
      double volume =0;                     
      double oldvolume =550.67;                              // Oude meterstand
      unsigned long lastSend =0;
      unsigned long lastPulse =0;
      
      void setup()  
      {  
        // initialize our digital pins internal pullup resistor so one pulse switches from high to low (less distortion) 
        pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP);
        
        pulseCount = oldPulseCount = 0;
      
        // Fetch last known pulse count value from gw
        request(CHILD_ID, V_VAR1);
      
        lastSend = lastPulse = millis();
      
        attachInterrupt(SENSOR_INTERRUPT, onPulse, FALLING);
      }
      
      void presentation()  {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Gas Meter", "1.0");
      
        // Register this device as Gasflow sensor
        present(CHILD_ID, S_GAS);       
      }
      
      void loop()     
      { 
        unsigned long currentTime = millis();
            
        // Only send values at a maximum frequency or woken up from sleep
        if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY))
        {
          lastSend=currentTime;
          
          Serial.println("--------- Debug void loop ------------");
          
          if (!pcReceived) {
            //Last Pulsecount not yet received from controller, request it again
            request(CHILD_ID, V_VAR1);
            return;
          }
      
          if (!SLEEP_MODE && flow != oldflow) {
            oldflow = flow;
      
            Serial.print("m3/min:");
            Serial.println(flow);
      
            // Check that we dont get unresonable large flow value. 
            // could hapen when long wraps or false interrupt triggered
            if (flow<((unsigned long)MAX_FLOW)) {
              send(flowMsg.set(flow, 2));                   // Send flow value to gw
            }  
          }
        
          // No Pulse count received in 2min 
          if(currentTime - lastPulse > 120000){
            flow = 0;
          } 
      
          // Pulse count has changed
          if ((pulseCount != oldPulseCount)||(!SLEEP_MODE)) {
            oldPulseCount = pulseCount;
            
            Serial.println("flow:   ");
            Serial.print(flow);
            
      //      Serial.println(Time.now()); 
            Serial.print("pulsecount:   ");
            Serial.println(pulseCount);
      
            send(lastCounterMsg.set(pulseCount));                  // Send  pulsecount value to gw in VAR1
      
            double volume = ((double)pulseCount/((double)PULSE_FACTOR));     
            if ((volume != oldvolume)||(!SLEEP_MODE)) {
              oldvolume = volume;
      
              Serial.print("volume:   ");
              Serial.println(volume, 3);
              Serial.println("---------------------------------------------------");
              
              send(volumeMsg.set(volume, 3));               // Send volume value to gw
            } 
          }
        }
        if (SLEEP_MODE) {
          sleep(SEND_FREQUENCY);
        }
      }
      
      void receive(const MyMessage &message) {
        if (message.type==V_VAR1) {
          unsigned long gwPulseCount=message.getULong();
          pulseCount += gwPulseCount;
          flow=oldflow=0;
          Serial.println("--------------- Debug void receive ---------------"); 
          Serial.print("Received last pulse count from gw:   ");
          Serial.println(pulseCount);
          Serial.println("---------------------------------------------------");
          pcReceived = true;
        }
      }
      
      void onPulse()     
      {
        if (!SLEEP_MODE)
        {
          unsigned long newBlink = micros();   
          unsigned long interval = newBlink-lastBlink;
          
          Serial.println("--------------- Debug void onPulse ---------------"); 
      //    Serial.println("newblink:   "); 
      //    Serial.print(newBlink);
      //    Serial.println("interval:   "); 
      //    Serial.print(interval);
      //    Serial.println();  
          
          if (interval!=0)
          {
            lastPulse = millis();
            if (interval<500000L) {         
              // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)
              return;   
            }
            flow = (60000000.0 /interval) / ppl;
            Serial.println("flow = (60000000.0 /interval) / ppl");
            Serial.println(flow);
            Serial.println("---------------------------------------------------");
          }
          lastBlink = newBlink;
        }
        pulseCount++; 
      }
      

      The counter goes up but it is still off with the gasmeter. Then i upload you're sketch and the counter doesn't go up and the serial monitor says Stable pin value different!
      Can you help?

      posted in My Project
      insomnia
      insomnia
    • RE: Gas meter monitoring with optical sensor

      Could you place the sketch here? Thanks

      posted in My Project
      insomnia
      insomnia
    • RE: Repeater and motion

      @Dwalt That was what i needed. It works now 🙂

      posted in Troubleshooting
      insomnia
      insomnia
    • Repeater and motion

      The sketch works only it is sending the motion every second. I only want the sensor to send if there is motion. Who can help me with the code?

      #include <MySensor.h>  
      #include <SPI.h>
      
      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 1   // Id of the sensor child
      
      MySensor gw;
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()  
      {  
        // The third argument enables repeater mode.
        gw.begin(NULL, AUTO, true);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Motion Sensor/Repeater", "1.0");
      
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
        // Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID, S_MOTION);
        
      }
      
      void loop()     
      {     
        // By calling process() you route messages in the background
        gw.process();
        
        // Read digital motion value
        boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
              
        Serial.println(tripped);
        gw.send(msg.set(tripped?"1":"0"));  // Send tripped value to gw 
       
      }
      
      posted in Troubleshooting
      insomnia
      insomnia
    • RE: Door switch - sleep

      Like this
      #define INTERRUPT DIGITAL_INPUT_SENSOR-3
      #define INTERRUPT DIGITAL_INPUT_SENSOR-4
      #define INTERRUPT DIGITAL_INPUT_SENSOR-5

      Is this correct?

      posted in Troubleshooting
      insomnia
      insomnia
    • Door switch - sleep

      I use this sketch for a door switch and i wan't to make it battery powered and also wan't to make the arduino go to sleep. Is this possible and how do i do that?
      gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME); Doesn't work with interrupt in this sketch

      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      
      #define CHILD_ID1 3
      #define BUTTON_PIN1  3  // Arduino Digital I/O pin for button/reed switch
      #define CHILD_ID2 4
      #define BUTTON_PIN2  4  // Arduino Digital I/O pin for button/reed switch
      #define CHILD_ID3 5
      #define BUTTON_PIN3  5  // Arduino Digital I/O pin for button/reed switch
      
      
      
      MySensor gw;
      Bounce debouncer1 = Bounce(); 
      Bounce debouncer2 = Bounce(); // debouncer for the second switch
      Bounce debouncer3 = Bounce(); // debouncer for the third switch
      
      int oldValue1=-1;
      int oldValue2=-1; // second switch needs to have it's own old state
      int oldValue3=-1; // second switch needs to have it's own old state
      int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
      unsigned long SLEEP_TIME = 900000; // Sleep time between reports (in milliseconds)
      int oldBatteryPcnt = 0;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg1(CHILD_ID1,V_TRIPPED), msg2(CHILD_ID2,V_TRIPPED),msg3(CHILD_ID3,V_TRIPPED);
      
      
      
      void setup()  
      {  
        gw.begin();
      
         // use the 1.1 V internal reference
      #if defined(__AVR_ATmega2560__)
         analogReference(INTERNAL1V1);
      #else
         analogReference(INTERNAL);
      #endif
       
        gw.begin();
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Door Sensor Battery meter", "1.0");
      
       // Setup the button
        pinMode(BUTTON_PIN1,INPUT_PULLUP ); // You can assign pinmode and use pullup in one statement.
        pinMode(BUTTON_PIN2,INPUT_PULLUP);
        pinMode(BUTTON_PIN3,INPUT_PULLUP);
        
        // Activate internal pull-up
       // digitalWrite(BUTTON_PIN1,HIGH);
      //  digitalWrite(BUTTON_PIN2,HIGH);
      //  digitalWrite(BUTTON_PIN3,HIGH);
        
        // After setting up the button, setup debouncer1
        debouncer1.attach(BUTTON_PIN1);
        debouncer1.interval(5);
        debouncer2.attach(BUTTON_PIN2);
        debouncer2.interval(5);
        debouncer3.attach(BUTTON_PIN3);
        debouncer3.interval(5);
      
        // 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.
        gw.present(CHILD_ID1, S_DOOR);
        gw.present(CHILD_ID2, S_DOOR);
        gw.present(CHILD_ID3, S_DOOR);  
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        // 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
           gw.sendBatteryLevel(batteryPcnt);
           oldBatteryPcnt = batteryPcnt;
         } 
        // Check if the first switch state has changed
        debouncer1.update();
        // Get the update value
        int value = debouncer1.read();
       
        if (value != oldValue1) {
           // Send in the new value
           gw.send(msg1.set(value==HIGH ? 1 : 0));
      //     gw.send(msg2.set(value==HIGH ? 1 : 0)); // this is where you turn the second switch in your controller
      //     gw.send(msg3.set(value==HIGH ? 1 : 0));  // this is where you turn the third switch in your controller
           oldValue1 = value;
        }
        
        // Check if the 2nd switch state has changed
        debouncer2.update();
        // Get the update value
        value = debouncer2.read(); // no need to redeclare it (I removed int)
       
        if (value != oldValue2) {
           // Send in the new value
      //     gw.send(msg1.set(value==HIGH ? 1 : 0));
             gw.send(msg2.set(value==HIGH ? 1 : 0)); // this is where you turn the second switch in your controller
      //     gw.send(msg3.set(value==HIGH ? 1 : 0));  // this is where you turn the third switch in your controller
           oldValue2 = value;
        }
        
        // Check if the third switch state has changed
        debouncer3.update();
        // Get the update value
        value = debouncer3.read(); // no need to redeclare it (I removed int)
       
        if (value != oldValue3) {
           // Send in the new value
      //     gw.send(msg1.set(value==HIGH ? 1 : 0));
      //     gw.send(msg2.set(value==HIGH ? 1 : 0)); // this is where you turn the second switch in your controller
           gw.send(msg3.set(value==HIGH ? 1 : 0));  // this is where you turn the third switch in your controller
           oldValue3 = value;
        }
         // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
        gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
      } ```
      posted in Troubleshooting
      insomnia
      insomnia
    • RE: cc1101 rf433mhz with mysensors

      Maybe you van use this http://blog.gummibaer-tech.de/cul-stick-868433-im-selbstbau/
      I have buildthis one also and use it in fhem (www.fhem.de)

      posted in My Project
      insomnia
      insomnia
    • RE: Mysensored Doorbell

      My setup doesn't work. When i activate the relay directly it works. Pin 3 to ground does nothing. I used the sketch from Moshe. What can i do next?

      posted in My Project
      insomnia
      insomnia