Skip to content
  • MySensors
  • 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
  1. Home
  2. Controllers
  3. Domoticz
  4. Domotiocz + Rain gauge

Domotiocz + Rain gauge

Scheduled Pinned Locked Moved Domoticz
61 Posts 12 Posters 31.1k Views 12 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sundberg84S Offline
    sundberg84S Offline
    sundberg84
    Hardware Contributor
    wrote on last edited by
    #1

    Hi!

    Has anyone a sketch with a tipping bucket posting to domoticz?
    I have tried MySensors tippingbucket and also Water pulse meter sketch but cant figure it out...

    Thanx
    Andreas

    Controller: Proxmox VM - Home Assistant
    MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
    MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
    RFLink GW - Arduino Mega + RFLink Shield, 433mhz

    1 Reply Last reply
    0
    • sundberg84S Offline
      sundberg84S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by sundberg84
      #2

      This is my rainsensor/tipping bucket for MySensors that works with Domoticz.

      It uses 2xAA as power source, a Pro Mini 3.3v with a 0.9 to 3.3 booster.
      The bucket has a magnet which triggeras a reed switch which triggers an interrupt pin.
      I also use battery sensing with voltage divider.

      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      #define MY_RADIO_NRF24
      #define MY_NODE_ID 7
      
      #include <SPI.h>
      #include <MySensor.h>  
      
      // Running this in Domoticz stable version 2.5 will not work - upgrade to beta.
      
      #define DIGITAL_INPUT_SENSOR 3                  // The reed switch you attached.  (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
      #define SKETCH_NAME "Rain Gauge"                // Change to a fancy name you like
      #define SKETCH_VERSION "1.1"                    // Your version
      
      unsigned long SLEEP_TIME = 18*60000;            // Sleep time (in milliseconds).
      //unsigned long SLEEP_TIME = 20000;             // use this instead for debug
      
      float hwRainVolume = 0;                         // Current rainvolume calculated in hardware.
      int hwPulseCounter = 0;                         // Pulsecount recieved from GW
      float fullCounter = 0;                           // Counts when to send counter
      float bucketSize = 0.5;                           // Bucketsize mm, needs to be 1, 0.5, 0.25, 0.2 or 0.1
      boolean pcReceived = false;                     // If we have recieved the pulscount from GW or not 
      boolean reedState;                              // Current state the reedswitch is in
      boolean oldReedState;                           // Old state (last state) of the reedswitch
      unsigned long lastSend =0;                      // Time we last tried to fetch counter.
      
      MyMessage volumeMsg(CHILD_ID,V_RAIN);
      MyMessage lastCounterMsg(CHILD_ID,V_VAR1);
      
      //=========================
      // BATTERY VOLTAGE DIVIDER SETUP
      // 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
      #define VBAT_PER_BITS 0.003363075  
      #define VMIN 1.9                                  //  Vmin (radio Min Volt)=1.9V (564v)
      #define VMAX 3.0                                  //  Vmax = (2xAA bat)=3.0V (892v)
      int batteryPcnt = 0;                              // Calc value for battery %
      int batLoop = 0;                                  // Loop to help calc average
      int batArray[3];                                  // Array to store value for average calc.
      int BATTERY_SENSE_PIN = A0;                       // select the input pin for the battery sense point
      //=========================
      
      void presentation() {
      
        // Send the Sketch Version Information to the Gateway
        sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
      
        // Register this device as Rain sensor (will not show in Domoticz until first value arrives)
        present(CHILD_ID, S_RAIN);       
      }
      
      
      void setup()  
      {  
        // use the 1.1 V internal reference
        analogReference(INTERNAL);             // For battery sensing
        
        pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP);  // sets the reed sensor digital pin as input
      
        reedState = digitalRead(DIGITAL_INPUT_SENSOR); // Read what state the reedswitch is in
        oldReedState = reedState; // Set startup position for reedswitch 
        
        Serial.println("Startup completed");
      }
      
      void loop()     
      { 
      unsigned long currentTime = millis();
      
          //See if we have the counter/pulse from Domoticz - and ask for it if we dont.
          if (!pcReceived && (currentTime - lastSend > 5000)) {      
            request(CHILD_ID, V_VAR1);
            lastSend=currentTime;
            return;
          }
          if (!pcReceived) {
            return;
          }
          
      //Read if the bucket tipped over
      reedState = digitalRead(DIGITAL_INPUT_SENSOR);
      boolean tipped = oldReedState != reedState; 
      
          //BUCKET TIPS!
          if (tipped==true) {
          Serial.println("The bucket has tipped over...");
          oldReedState = reedState;
          hwRainVolume = hwRainVolume + bucketSize;
          send(volumeMsg.set((float)hwRainVolume,1));
          wait(1000);
          fullCounter = fullCounter + bucketSize;
      
            //Count so we send the counter for every 1mm
            if(fullCounter >= 1){
            hwPulseCounter++;
            send(lastCounterMsg.set(hwPulseCounter));
            wait(1000);
            fullCounter = 0;
            }
            
          }
          
          if (tipped==false) {
      
           //No bucket tipped over last sleep-period, check battery then...
           batM(); 
          }
      
      lastSend=currentTime;
      sleep(INTERRUPT, CHANGE, SLEEP_TIME); 
      //The interupt can be CHANGE or FALLING depending on how you wired the hardware.
      }
      
      //Read if we have a incoming message.
      void receive(const MyMessage &msg) {
          if (msg.type==V_VAR1) {
          hwPulseCounter = msg.getULong();
          hwRainVolume = hwPulseCounter;
          pcReceived = true;
          Serial.print("Received last pulse count from gw: ");
          Serial.println(hwPulseCounter);   
          }
      }
      
      void batM(){  //The battery calculations
        
         delay(500);
         // Battery monitoring reading
         int sensorValue = analogRead(BATTERY_SENSE_PIN);    
         delay(500);
         
         // Calculate the battery in %
         float Vbat  = sensorValue * VBAT_PER_BITS;
         int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
         Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");  
         
         // Add it to array so we get an average of 3 (3x20min)
         batArray[batLoop] = batteryPcnt;
        
         if (batLoop > 1) {  
           batteryPcnt = (batArray[0] + batArray[1] + batArray[2]);
           batteryPcnt = batteryPcnt / 3;
       
         if (batteryPcnt > 100) {
           batteryPcnt=100;
       }
       
           Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
             sendBatteryLevel(batteryPcnt);
             batLoop = 0;
             
           //Sends 1 per hour as a heartbeat.
           send(volumeMsg.set((float)hwRainVolume,1));   
           send(lastCounterMsg.set(hwPulseCounter));
           }
           else 
           {
           batLoop++;
           }
      }
      

      Controller: Proxmox VM - Home Assistant
      MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
      MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
      RFLink GW - Arduino Mega + RFLink Shield, 433mhz

      M 1 Reply Last reply
      4
      • sundberg84S Offline
        sundberg84S Offline
        sundberg84
        Hardware Contributor
        wrote on last edited by sundberg84
        #3

        This is great!
        1 year - times fly by, but my rainsensor is going strong!

        I just wanted to celebrate 1 year for my Rainsensor on batteries, reporting every hour (or less when it rains). Still going strong and 81% battery left! Except for some range issues in the beginning you can see its working as it should:

        Also It will be my (almost) 1000th post so thank you all for making MySensors such a great community. I just love every minute here!

        0_1474871808445_1.jpg

        Controller: Proxmox VM - Home Assistant
        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

        mrwombleM F 2 Replies Last reply
        2
        • sundberg84S sundberg84

          This is great!
          1 year - times fly by, but my rainsensor is going strong!

          I just wanted to celebrate 1 year for my Rainsensor on batteries, reporting every hour (or less when it rains). Still going strong and 81% battery left! Except for some range issues in the beginning you can see its working as it should:

          Also It will be my (almost) 1000th post so thank you all for making MySensors such a great community. I just love every minute here!

          0_1474871808445_1.jpg

          mrwombleM Offline
          mrwombleM Offline
          mrwomble
          wrote on last edited by
          #4

          @sundberg84 Wow, that is impressive! What type of batteries are you using?

          I'm waiting for parts to come in to start building some battery powered and external sensors.

          sundberg84S 1 Reply Last reply
          0
          • mrwombleM mrwomble

            @sundberg84 Wow, that is impressive! What type of batteries are you using?

            I'm waiting for parts to come in to start building some battery powered and external sensors.

            sundberg84S Offline
            sundberg84S Offline
            sundberg84
            Hardware Contributor
            wrote on last edited by
            #5

            @mrwomble - 2xAA

            Controller: Proxmox VM - Home Assistant
            MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
            MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
            RFLink GW - Arduino Mega + RFLink Shield, 433mhz

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              Qu3Uk
              wrote on last edited by
              #6

              Thats impressive, out of interest are you doing anything with this data in domotiocz?

              sundberg84S 1 Reply Last reply
              0
              • Q Qu3Uk

                Thats impressive, out of interest are you doing anything with this data in domotiocz?

                sundberg84S Offline
                sundberg84S Offline
                sundberg84
                Hardware Contributor
                wrote on last edited by
                #7

                @Qu3Uk nope, just monitoring. I could probably use it for watering if I made some actuators... but not that garden interested.

                Controller: Proxmox VM - Home Assistant
                MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                1 Reply Last reply
                0
                • sinczeS Offline
                  sinczeS Offline
                  sincze
                  MySensors Evangelist
                  wrote on last edited by
                  #8

                  @sundberg84 , very nice. I would say.. I want that as well ;-)
                  any suggestions for a shopping and modification list?
                  As I don't have a 3D printer to print the thing myself.

                  sundberg84S TheoLT 2 Replies Last reply
                  0
                  • sinczeS sincze

                    @sundberg84 , very nice. I would say.. I want that as well ;-)
                    any suggestions for a shopping and modification list?
                    As I don't have a 3D printer to print the thing myself.

                    sundberg84S Offline
                    sundberg84S Offline
                    sundberg84
                    Hardware Contributor
                    wrote on last edited by
                    #9

                    @sincze - its not a 3d printed box, its an old 433mhz tip sensor.
                    There is something similar on mysensors shop :http://www.ebay.com/itm/misol-Spare-part-for-weather-station-to-measure-the-rain-volume-for-rain-meter-/271862662076?hash=item3f4c4703bc:g:IGsAAOSwq7JT8vJY&rmvSB=true

                    Controller: Proxmox VM - Home Assistant
                    MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                    MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                    RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                    TheoLT 1 Reply Last reply
                    1
                    • sundberg84S sundberg84

                      @sincze - its not a 3d printed box, its an old 433mhz tip sensor.
                      There is something similar on mysensors shop :http://www.ebay.com/itm/misol-Spare-part-for-weather-station-to-measure-the-rain-volume-for-rain-meter-/271862662076?hash=item3f4c4703bc:g:IGsAAOSwq7JT8vJY&rmvSB=true

                      TheoLT Offline
                      TheoLT Offline
                      TheoL
                      Contest Winner
                      wrote on last edited by
                      #10

                      @sundberg84 Just playing with your sketch, because it's easier for my to understand than the one one the build page. I'm curious about how domoticz handles these values. I don't see you reset the hwRainVolume variable. So does this mean that this is an ever increasing value that must be send to Domoticz?

                      sundberg84S 1 Reply Last reply
                      0
                      • TheoLT TheoL

                        @sundberg84 Just playing with your sketch, because it's easier for my to understand than the one one the build page. I'm curious about how domoticz handles these values. I don't see you reset the hwRainVolume variable. So does this mean that this is an ever increasing value that must be send to Domoticz?

                        sundberg84S Offline
                        sundberg84S Offline
                        sundberg84
                        Hardware Contributor
                        wrote on last edited by
                        #11

                        @TheoL - Correct.
                        There is a countervalue and Domoticz calculates the value from midnight each night.

                        Controller: Proxmox VM - Home Assistant
                        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                        TheoLT 1 Reply Last reply
                        0
                        • sundberg84S sundberg84

                          @TheoL - Correct.
                          There is a countervalue and Domoticz calculates the value from midnight each night.

                          TheoLT Offline
                          TheoLT Offline
                          TheoL
                          Contest Winner
                          wrote on last edited by
                          #12

                          @sundberg84 Thanx for your fast reply. So what happens when the float resets to 0?

                          sundberg84S 1 Reply Last reply
                          0
                          • sinczeS sincze

                            @sundberg84 , very nice. I would say.. I want that as well ;-)
                            any suggestions for a shopping and modification list?
                            As I don't have a 3D printer to print the thing myself.

                            TheoLT Offline
                            TheoLT Offline
                            TheoL
                            Contest Winner
                            wrote on last edited by
                            #13

                            @sincze Hello my friend, just curious how many sensors you've got hooked up at the moment?

                            1 Reply Last reply
                            0
                            • TheoLT TheoL

                              @sundberg84 Thanx for your fast reply. So what happens when the float resets to 0?

                              sundberg84S Offline
                              sundberg84S Offline
                              sundberg84
                              Hardware Contributor
                              wrote on last edited by
                              #14

                              @TheoL - Just to add what we discussed in chat for future questions - If float would hit the maximum value (which is hugh so lets hope its not a problem) im not sure what will happen...

                              Controller: Proxmox VM - Home Assistant
                              MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                              MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                              RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                              TheoLT 1 Reply Last reply
                              0
                              • sundberg84S sundberg84

                                @TheoL - Just to add what we discussed in chat for future questions - If float would hit the maximum value (which is hugh so lets hope its not a problem) im not sure what will happen...

                                TheoLT Offline
                                TheoLT Offline
                                TheoL
                                Contest Winner
                                wrote on last edited by
                                #15

                                @sundberg84 It's also not a concern of the MySensors node. This should be handled by Domoticz. I really like your sketch, it works like a charm. I modified it to my needs so that I can run the node without the sleep. Still need to think of an hourly heart beat. But almost there.

                                sundberg84S 1 Reply Last reply
                                0
                                • TheoLT TheoL

                                  @sundberg84 It's also not a concern of the MySensors node. This should be handled by Domoticz. I really like your sketch, it works like a charm. I modified it to my needs so that I can run the node without the sleep. Still need to think of an hourly heart beat. But almost there.

                                  sundberg84S Offline
                                  sundberg84S Offline
                                  sundberg84
                                  Hardware Contributor
                                  wrote on last edited by
                                  #16

                                  @TheoL - If you modify the sketch with a heartbeat() please post it :) Im interested as well!

                                  Controller: Proxmox VM - Home Assistant
                                  MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                                  MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                                  RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                                  TheoLT 1 Reply Last reply
                                  0
                                  • TheoLT Offline
                                    TheoLT Offline
                                    TheoL
                                    Contest Winner
                                    wrote on last edited by
                                    #17

                                    @AWI do you happen to know if the pulse counter in Domoticz is a 1mm pulse counter? Or is it a real tip pulse counter? Right know where checking whenever the rain fall exceeds 1mm and send a pulse ++ in that case. Meaning we miss some pulse counts when we reset the node.

                                    AWIA 1 Reply Last reply
                                    0
                                    • TheoLT TheoL

                                      @AWI do you happen to know if the pulse counter in Domoticz is a 1mm pulse counter? Or is it a real tip pulse counter? Right know where checking whenever the rain fall exceeds 1mm and send a pulse ++ in that case. Meaning we miss some pulse counts when we reset the node.

                                      AWIA Offline
                                      AWIA Offline
                                      AWI
                                      Hero Member
                                      wrote on last edited by
                                      #18

                                      @TheoL My rain meter counts in 1 mm resolution but I am sending actual total (in mm) from the start of sensor and keep totals in EEPROM.

                                      TheoLT 1 Reply Last reply
                                      0
                                      • AWIA AWI

                                        @TheoL My rain meter counts in 1 mm resolution but I am sending actual total (in mm) from the start of sensor and keep totals in EEPROM.

                                        TheoLT Offline
                                        TheoLT Offline
                                        TheoL
                                        Contest Winner
                                        wrote on last edited by
                                        #19

                                        @AWI (Glad that your back, hope you're doing allright) So, if I understand your setup correctly you don't send the pulse count to Domoticz? I kind of like it, because that way I can reset the rain sensor many times and still keep the rain fall log in sync, without using the EPROM.

                                        And my rain sensor did reset a couple of times. I had to put a diode (Dutch name is blus diode) between the two wires coming out from the rain gauge to prevent this.

                                        AWIA 1 Reply Last reply
                                        0
                                        • TheoLT TheoL

                                          @AWI (Glad that your back, hope you're doing allright) So, if I understand your setup correctly you don't send the pulse count to Domoticz? I kind of like it, because that way I can reset the rain sensor many times and still keep the rain fall log in sync, without using the EPROM.

                                          And my rain sensor did reset a couple of times. I had to put a diode (Dutch name is blus diode) between the two wires coming out from the rain gauge to prevent this.

                                          AWIA Offline
                                          AWIA Offline
                                          AWI
                                          Hero Member
                                          wrote on last edited by
                                          #20

                                          @TheoL (i'm fine, thank you) That is what i'm doing. The only thing what I need to do after a reset is delete the miscalculation in Domoticz (easy). My sensor (oregon) uses a 'reed' switch (no induction). I MySensoriz'ed it without losing the original circuitry and function. (so in parallel).

                                          0_1475422212074_upload-82d166bf-a999-4d76-b3e3-8c010fa5f427

                                          TheoLT 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          15

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

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