Navigation

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

    edweather

    @edweather

    3
    Reputation
    15
    Posts
    1180
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    edweather Follow

    Best posts made by edweather

    • Rebuild of my broken 433mhz Cresta/hideki UV-Sensor

      Hello,

      I just started with arduino and mysensors and I would like to share my first steps (re)building my broken uv-sensor.
      I bought the orignal TS704 UV sensor about two years ago. A few weeks ago it stopped sending acurate UV readings. On lots of placesa on the internet there are complaints abouts this sensor and the relative short lifetime. Main reason I think is water leakage in the sensor. I didn't want to buy a new one because the problem would be back within 2 years and they are realy expensive at the moment (about €70).
      Then I found the mysensors site in my quest to fix my broken device and my first sensor project was born!
      I ordered the pieces I needed and started to build.
      First the gateway, connected to domoticz which was easy as I connected it directly to the raspberry pi using the pigatewayserial software. Antenna directly connected to the Pi so no Arduino board needed!.
      Changed tty TTY_NAME := /dev/ttyMySensorsGateway to tty
      TTY_NAME := /dev/ttyUSB30 in the makefile because Domoticz cannot use ttyMySensorsGateway.
      After that It was easy to add the serialgateway to Domoticz!

      upload-e224b990-a645-4097-a509-02e4a7273ae3

      my list:
      Arduino pro mini 8mb 3v
      UVM-30a UV sensor
      NRF24L01+ 2.4GHz Wireless Transceiver
      TS704 UV sensor housing including 2xAA batery compartment
      Used the default sketch with pin A0 instead of pin 3 (http://www.mysensors.org/build/uv)

      On my breadboard I had things up and running quite easy but the readings were strange. Even at night there was UV light measured. The problem was a mismatch between the intructions on this website about the out pin to use and the one mentioned in the sketch. Sketch showed pin A0 as OUT but website showed pin 3 as OUT.
      @hek has confirmed that A0 is the correct pin. Website will be updated. (is updated now)
      I was mislead because with nothing connected to pin A0 it still gives you output data.
      It's also possible to use 3V for the UVM-30A instead of only 5volt I found this in the spec sheet.

      So the stepup from 3 to 5v is not needed I think?

      To get things in the housing I had to desolder the main piece from the UV sensor. Things have gone wrong from here because after that the sensor did not work anymore. Probably fried the sensor?! New one is on its way.
      So I must think of another way to get the sensor in place at the top of the housing. There not enough place so I must be creative and not destroying another sensor!

      I also would like to share a short piece of code I found to test the uv sensors output. This way you don't need to attach all the radio wires to see if the sensor is working.

      /*

      This Sample code is for testing the UV Sensor .

      #Connection:
      VCC-5V
      GND-GND
      OUT-Analog pin 0
      */

      void setup()
      {
      Serial.begin(9600);// open serial port, set the baud rate to 9600 bps
      }
      void loop()
      {
      int sensorValue;
      sensorValue = analogRead(0);//connect UV sensors to Analog 0
      Serial.println(sensorValue);//print the value to serial
      delay(200);
      }

      The pieces on the table:
      IMG_0353.JPG

      New sensor arrived and bought a 15W soldering iron.

      Puting things together and make some room for the sensor board

      20150526_190923284_iOS.jpg

      20150529_181320010_iOS.jpg

      20150613_133448340_iOS.jpg

      After everthing was put in place the sensor went outside for testing.
      For reference I also used a nearby UV sensor via Weather Underground.

      20150615_150304000_iOS.png

      At first everything looked fine but it seems that the measurements from my sensor are to low.
      I removed the sensor and did some testing with the above sketch to measure the output voltage on 3.3v and 5v but the results were the samen and to low.
      Does anyone know what can cause this low measurement ? checked the wires. checked the sketch. replaced the arduino board.
      Another broken sensor?

      posted in My Project
      edweather
      edweather
    • Watertank empty notification for sharp air purifiers (Sharp KC-A50EUW & KCA40EUW)

      We have two Sharp air purifiers - KC-A50EUW & KC-A40EUW - with humidifying function.
      6066a6c1-e8c8-4aab-9926-5e21c87e019f-image.png

      They do their job very well but if the watertank runs empty this gives a terrible smell because the humidify filter runs dry.
      Don't know why it smells so bad but must be some kind of biological reaction.

      5bbe510f-7d3b-4564-ae14-4e2d6c2b057d-image.png

      Because of their function of cleaning the air these devices require periodic maintenance. Clean the airfilters, soak the humdifying filter and other parts in citric acid to decalc.
      It's also a great dust collector and that dust also getting inside the appliance at places you can't easily reach.
      So I dicided to take one of the devices apart to clean the inside.

      e84cdb15-8cfc-4344-9d6d-01c46b02cd38-image.png
      As you can see the dust is everywhere.

      Getting inside the device is verry easy, just unscrew the screws and that's it.
      On the inside of both devices there are some familiar parts like the Sharp GP2Y1010AU0F dust sensor.
      40aa1289-3503-4358-aaa9-2626d068dbe5-image.png
      The gas/smell sensor differs in each appliance as I found out when servicing the other device later.

      c26b82ba-51e3-4b91-9219-0fffb6c31d85-image.pngKC-A40EUW

      976a0ab9-1ce7-486d-b645-7fd04cddeed5-image.png KC-A50EUW

      If the watertank runs empty there is a floater with a small magnet that triggers a contact and turns on a notification light on the front of the device.
      5ee9d60f-480c-4c90-962a-12f5bb702c3f-image.png
      1b67adf9-8a14-445c-ab7b-07bb398545f2-image.png

      This started me thinking of an easy hack to just add a contact sensor near the orignal sensor.
      b8e44472-c7e4-4bd0-b723-dbd0c3712c45-image.png
      So that's what I did and it worked instanly. On the kc-a50euw I had to shorten the contact just a little to make it fit.

      I borrowed 5v power from the applicance itself and used the glue gun(no image of that) to cover my solder points.
      3828cc13-a88b-48b9-85c7-86ea6a728b0d-image.png

      On the main board of the device there were some interesting connections but I did not dare to hook them up to a serial monitor.
      Would like to investigate this later with some help of more skilled techies.

      33d64071-001e-4866-86c4-3ac2168351c6-image.png

      After this it was easy to get the appliance show up in my Homeassistant setup.
      52449521-5898-4626-b47a-7547494e065d-image.png
      If the watertank runs empty it shows up in Homeassistant and with an automation setup I will receive a message on my phone to fill the tank.
      Turning the device off is also an option (when youre not home) just add a smart plug in the mix!

      I used the the default contact sensor script from the mysensors website and changed it a little to get it working with homeassistant.

      Because SKETCH_NAME and SKETCH_VERSION were missing it did not work in HA
      also added #define MY_RF24_PA_LEVEL (RF24_PA_MAX) because of reception issues.
      I put the radio to close to the electric parts I think.

      Other changes:
      #define MY_NODE_ID 6
      #define MY_REPEATER_FEATURE

      In HomeAssistant I changed the device class of the entity from 'door' to 'problem'
      6411371b-113a-4b67-891f-42784de84f14-image.png

      I hope you liked my project as much as I do and that it inspires you.

      The code:

      /**
       * 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.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Simple binary switch example 
       * Connect button or door/window reed switch between 
       * digitial I/O pin 3 (BUTTON_PIN below) and GND.
       * http://www.mysensors.org/build/binary
       */
      
      // General settings
      #define SKETCH_NAME "luchtreiniger-woonkamer"
      #define SKETCH_VERSION "1.0"
      #define MY_NODE_ID 6
      
      #define MY_REPEATER_FEATURE
      
      // Enable debug prints to serial monitor
      //#define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      #define MY_RF24_PA_LEVEL (RF24_PA_MAX) //reception issues because the radio is to close to electric parts
      
      #include <MySensors.h>
      #include <Bounce2.h>
      
      #define CHILD_ID 3
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      
      Bounce debouncer = Bounce(); 
      int oldValue=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      void setup()  
      {  
        // Setup the button
        pinMode(BUTTON_PIN,INPUT);
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN,HIGH);
      
        // After setting up the button, setup debouncer
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(5);
      
      }
      
      void presentation() {
        // 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.
        sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
        present(CHILD_ID, S_DOOR);  
      }
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
      
        if (value != oldValue) {
           // Send in the new value
           send(msg.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
      }
      
      posted in My Project
      edweather
      edweather

    Latest posts made by edweather

    • Watertank empty notification for sharp air purifiers (Sharp KC-A50EUW & KCA40EUW)

      We have two Sharp air purifiers - KC-A50EUW & KC-A40EUW - with humidifying function.
      6066a6c1-e8c8-4aab-9926-5e21c87e019f-image.png

      They do their job very well but if the watertank runs empty this gives a terrible smell because the humidify filter runs dry.
      Don't know why it smells so bad but must be some kind of biological reaction.

      5bbe510f-7d3b-4564-ae14-4e2d6c2b057d-image.png

      Because of their function of cleaning the air these devices require periodic maintenance. Clean the airfilters, soak the humdifying filter and other parts in citric acid to decalc.
      It's also a great dust collector and that dust also getting inside the appliance at places you can't easily reach.
      So I dicided to take one of the devices apart to clean the inside.

      e84cdb15-8cfc-4344-9d6d-01c46b02cd38-image.png
      As you can see the dust is everywhere.

      Getting inside the device is verry easy, just unscrew the screws and that's it.
      On the inside of both devices there are some familiar parts like the Sharp GP2Y1010AU0F dust sensor.
      40aa1289-3503-4358-aaa9-2626d068dbe5-image.png
      The gas/smell sensor differs in each appliance as I found out when servicing the other device later.

      c26b82ba-51e3-4b91-9219-0fffb6c31d85-image.pngKC-A40EUW

      976a0ab9-1ce7-486d-b645-7fd04cddeed5-image.png KC-A50EUW

      If the watertank runs empty there is a floater with a small magnet that triggers a contact and turns on a notification light on the front of the device.
      5ee9d60f-480c-4c90-962a-12f5bb702c3f-image.png
      1b67adf9-8a14-445c-ab7b-07bb398545f2-image.png

      This started me thinking of an easy hack to just add a contact sensor near the orignal sensor.
      b8e44472-c7e4-4bd0-b723-dbd0c3712c45-image.png
      So that's what I did and it worked instanly. On the kc-a50euw I had to shorten the contact just a little to make it fit.

      I borrowed 5v power from the applicance itself and used the glue gun(no image of that) to cover my solder points.
      3828cc13-a88b-48b9-85c7-86ea6a728b0d-image.png

      On the main board of the device there were some interesting connections but I did not dare to hook them up to a serial monitor.
      Would like to investigate this later with some help of more skilled techies.

      33d64071-001e-4866-86c4-3ac2168351c6-image.png

      After this it was easy to get the appliance show up in my Homeassistant setup.
      52449521-5898-4626-b47a-7547494e065d-image.png
      If the watertank runs empty it shows up in Homeassistant and with an automation setup I will receive a message on my phone to fill the tank.
      Turning the device off is also an option (when youre not home) just add a smart plug in the mix!

      I used the the default contact sensor script from the mysensors website and changed it a little to get it working with homeassistant.

      Because SKETCH_NAME and SKETCH_VERSION were missing it did not work in HA
      also added #define MY_RF24_PA_LEVEL (RF24_PA_MAX) because of reception issues.
      I put the radio to close to the electric parts I think.

      Other changes:
      #define MY_NODE_ID 6
      #define MY_REPEATER_FEATURE

      In HomeAssistant I changed the device class of the entity from 'door' to 'problem'
      6411371b-113a-4b67-891f-42784de84f14-image.png

      I hope you liked my project as much as I do and that it inspires you.

      The code:

      /**
       * 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.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Simple binary switch example 
       * Connect button or door/window reed switch between 
       * digitial I/O pin 3 (BUTTON_PIN below) and GND.
       * http://www.mysensors.org/build/binary
       */
      
      // General settings
      #define SKETCH_NAME "luchtreiniger-woonkamer"
      #define SKETCH_VERSION "1.0"
      #define MY_NODE_ID 6
      
      #define MY_REPEATER_FEATURE
      
      // Enable debug prints to serial monitor
      //#define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      #define MY_RF24_PA_LEVEL (RF24_PA_MAX) //reception issues because the radio is to close to electric parts
      
      #include <MySensors.h>
      #include <Bounce2.h>
      
      #define CHILD_ID 3
      #define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch
      
      Bounce debouncer = Bounce(); 
      int oldValue=-1;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage msg(CHILD_ID,V_TRIPPED);
      
      void setup()  
      {  
        // Setup the button
        pinMode(BUTTON_PIN,INPUT);
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN,HIGH);
      
        // After setting up the button, setup debouncer
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(5);
      
      }
      
      void presentation() {
        // 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.
        sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
        present(CHILD_ID, S_DOOR);  
      }
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
      
        if (value != oldValue) {
           // Send in the new value
           send(msg.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
      }
      
      posted in My Project
      edweather
      edweather
    • RE: error: 'class Child' has no member named 'setPulseFactor'; did you mean 'setPresentation'?

      @BearWithBeard said in error: 'class Child' has no member named 'setPulseFactor'; did you mean 'setPresentation'?:

      rainGauge.setPulseFactor(0.36);

      Up and running!
      Thanks a lot @BearWithBeard for the clear explanation. Now I understand why it did not work!.

      0b1d0654-02d3-4b42-a99a-e74065bb39ed-image.png

      posted in NodeManager
      edweather
      edweather
    • error: 'class Child' has no member named 'setPulseFactor'; did you mean 'setPresentation'?

      Hello MySensors friends,

      I'm trying to get my raingauge working with nodemanager but I am stuck on setting the pulsefactor and other settingsgiving me errors I can't resolve by myself.
      I am using the easypcb from @sundberg84 (rfm69 version) with mysensor version 2.3.0

      I allready figured out how to use these settings for my temperature and hunidity sensors.
      like htu21.children.get(1)->setValueDelta(0.5); //temp

      But using the same approach for my rainsensors does not work.
      rainGauge.children.get(1)->setPulseFactor(0.36); //pulsefactor

      Can anyone explain why this does not work for the raingauge?

      Thanks in advance!

      My code:

      /*
      * 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-2017 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.
      */
      
      /**************************
      Template
      
      This sketch can be used as a template since containing the most relevant MySensors library configuration settings, 
      NodeManager's settings, all its the supported sensors commented out and a sketch structure fully functional to operate with
      NodeManager. Just uncomment the settings you need and the sensors you want to add and configure the sensors in before()
      */
      
      /**********************************
       * MySensors node configuration
       */
      
      // General settings
      #define SKETCH_NAME "Rain Gauge"                // Change to a fancy name you like
      #define SKETCH_VERSION "1.2"                    // Your version
      #define MY_DEBUG
      #define MY_NODE_ID 4
      
      // RFM69 radio settings
      #define MY_RADIO_RFM69
      #define MY_IS_RFM69HW
      #define MY_RFM69_NEW_DRIVER
      
      
      // Advanced settings
      #define MY_BAUD_RATE 9600
      //#define MY_SMART_SLEEP_WAIT_DURATION_MS 500
      #define MY_SPLASH_SCREEN_DISABLED
      //#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE
      //#define MY_SIGNAL_REPORT_ENABLED
      
      /***********************************
       * NodeManager configuration
       */
      
      #define NODEMANAGER_DEBUG ON
      #define NODEMANAGER_INTERRUPTS ON
      #define NODEMANAGER_SLEEP ON
      #define NODEMANAGER_RECEIVE ON
      #define NODEMANAGER_DEBUG_VERBOSE OFF
      #define NODEMANAGER_POWER_MANAGER OFF
      #define NODEMANAGER_CONDITIONAL_REPORT OFF
      #define NODEMANAGER_EEPROM OFF
      #define NODEMANAGER_TIME OFF
      #define NODEMANAGER_RTC OFF
      #define NODEMANAGER_SD OFF
      #define NODEMANAGER_HOOKING OFF
      #define NODEMANAGER_OTA_CONFIGURATION OFF
      #define NODEMANAGER_SERIAL_INPUT OFF
      
      // import NodeManager library (a nodeManager object will be then made available)
      #include <MySensors_NodeManager.h>
      
      /***********************************
       * Add your sensors
       */
      
      //PowerManager power(5,6);
       
      #include <sensors/SensorBattery.h>
      SensorBattery battery;
      
      #include <sensors/SensorRainGauge.h>
      SensorRainGauge rainGauge(3);
      
      
      /***********************************
       * Main Sketch
       */
      
      // before
      void before() {
      	
        /***********************************
         * Configure your sensors
         */
         
        // EXAMPLES:
        // report measures of every attached sensors every 10 seconds
        //nodeManager.setReportIntervalSeconds(10);
       
        // report measures of every attached sensors every 60 minutes
        nodeManager.setReportIntervalMinutes(60);
        
        // set the node to sleep in 60 minutes cycles
        nodeManager.setSleepMinutes(60);
       
        // report battery level every 60 minutes
        battery.setReportIntervalMinutes(60);
      
       
       //Raingauge
       rainGauge.children.get(1)->setPulseFactor(0.36); //pulsefactor
      
       // [19] if enabled, when waking up from the interrupt, the board stops sleeping. Disable it when attaching e.g.
       rainGauge.children.get()->setSleepInterruptPin(3); //Sleep interupt pin
       // [28] ignore two consecutive interrupts if happening within this timeframe in milliseconds (default: 100)
       rainGauge.children.get()->setInterruptDebounce(500); //debounce
       
       
        // call NodeManager before routine
        nodeManager.before();
      }
      
      // presentation
      void presentation() {
        // call NodeManager presentation routine
        nodeManager.presentation();
      }
      
      // setup
      void setup() {
        // call NodeManager setup routine
        nodeManager.setup();
      }
      
      // loop
      void loop() {
        // call NodeManager loop routine
        nodeManager.loop();
      }
      
      #if NODEMANAGER_RECEIVE == ON
      // receive
      void receive(const MyMessage &message) {
        // call NodeManager receive routine
        nodeManager.receive(message);
      }
      #endif
      
      #if NODEMANAGER_TIME == ON
      // receiveTime
      void receiveTime(unsigned long ts) {
        // call NodeManager receiveTime routine
        nodeManager.receiveTime(ts);
      }
      #endif
      
      posted in NodeManager
      edweather
      edweather
    • RE: Irrigation Controller (up to 16 valves with Shift Registers)

      @dbemowsk Thank you!

      posted in My Project
      edweather
      edweather
    • RE: Irrigation Controller (up to 16 valves with Shift Registers)

      Hello,

      I have build the irrigation controler this weekend and just found out that there are some issues using this with domoticz.
      Is there someone willing to share his customized code to get these zone and time variables working ?

      Thanks in advance,

      Edwin

      posted in My Project
      edweather
      edweather
    • RE: Please share your raingauge sketch that works with Domoticz

      @sundberg84 Thanks, tried but I keep getting false rain tips.

      posted in Development
      edweather
      edweather
    • RE: Please share your raingauge sketch that works with Domoticz

      @mfalkvidd thanks, I will look at that thread.

      posted in Development
      edweather
      edweather
    • RE: Please share your raingauge sketch that works with Domoticz

      After one night with not a drop of rain ? False tips?

      0_1495357517670_upload-ae462a54-28c5-445f-885d-8b13d250979c

      posted in Development
      edweather
      edweather
    • RE: Please share your raingauge sketch that works with Domoticz

      @flopp thanks for the quick reply.
      The debug output gives:

      28004 TSF:MSG:SEND,33-33-0-0,s=1,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:	Sent Message
      Sender: 33
      Last Node: 33
      Next Node: 0
      Destination: 0
      Sensor Id: 1
      Command: REQ
      Message Type:V_VAR1
      Payload Type: P_STRING
      Payload Length: 0
      Signing: 0
      Failed uplink counter: 0
      Status: OK (OK=success, NACK=no radio ACK received)
      Payload:
      28499 TSF:MSG:READ,0-0-33,s=1,c=2,t=24,pt=0,l=0,sg=0:	Received Message
      Sender: 0
      Last Node: 0
      Destination: 33
      Sensor Id: 1
      Command: REQ
      Message Type: V_VAR1
      Payload Type: P_STRING
      Payload Length: 0
      Signing: 0
      Payload:
      

      I tried it with your sketch but this gives me a pulse count every time the sensor starts up.
      Normaly you do this only once but I think it will do this every hour when synching the time.
      I uploaded your sketch 5 minutes ago so I can't confirm this now.

      Getting pulse count
      .
      Received last pulse count from gw: 1
      Getting Time
      .
      Time received...
      16:14
      Tipped 2 times.
      Rain fall is 0.6 mm.
      Getting pulse count
      .
      Received last pulse count from gw: 2
      Getting Time
      .
      Time received...
      16:14
      Tipped 3 times.
      Rain fall is 0.9 mm.

      Getting pulse count
      .
      Received last pulse count from gw: 3
      Getting Time
      .
      Time received...
      16:16
      Tipped 4 times.
      Rain fall is 1.2 mm.
      Getting pulse count
      .
      Received last pulse count from gw: 4
      Getting Time
      .
      Time received...
      16:17
      Tipped 5 times.
      Rain fall is 1.5 mm.
      Getting pulse count
      .
      Received last pulse count from gw: 5
      Getting Time
      .
      Time received...
      16:17
      Tipped 6 times.
      Rain fall is 1.8 mm.

      The sketch with extra sensors removed:

      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      
      /*
        Include libraries used by the sketch
      */
      
      #include <Time.h>
      #include <TimeLib.h>
      #include <MySensors.h>
      #include <Wire.h>
      
      #define BUCKET_PIN 3                  // The Arduino pin to which the bucket is attached. We need an interrupt pin (2 or 3 on the Uno and the Pro Mini) 
      #define SKETCH_INFO "Rain Gauge" // The name of the sketch as presented to the gateway
      #define SKETCH_VERSION "1.0"          // The version of the sketch as presented to the gateway
      #define CHILD_ID_RAIN_LOG 4           // The child id of the rain gauge
      #define MS_WAIT 100                   // short delay used to give the NRF24L01+ antenna some time to recover from the last data sending
      #define bucketSize 0.3                // I've used a MI-SOL Rain Guage which has a bucket size of 0.3 mm
      
      MyMessage msgRain( CHILD_ID_RAIN_LOG, V_RAIN );
      MyMessage lastCounterMsg( CHILD_ID_RAIN_LOG, V_VAR1 );
      
      float hwRainVolume = 0;           // Current rainvolume calculated in hardware.
      unsigned long hwPulseCounter = 0; // Pulsecount recieved from GW
      boolean pcReceived = false;       // If we have recieved the pulscount from GW or not
      unsigned long lastTipTime = millis(); // TS of when the bucket tip has been detected for the last time
      volatile unsigned long wasTippedCounter; // Queue for storing the tipped counter as been set by the interrupt handler.
      byte lastHour;                    // Stores the hour used for checking if time needs to be synchronized
      
      void presentation() {
        // Send the sketch version information to the gateway
        
        sendSketchInfo( SKETCH_INFO, SKETCH_VERSION );
        wait( MS_WAIT );
        
        present( CHILD_ID_RAIN_LOG, S_RAIN, "Rain fall" );
        wait( MS_WAIT );
      
        unsigned long functionTimeout = millis();
        while ( pcReceived == false && millis() - functionTimeout < 30000UL ) {
          request( CHILD_ID_RAIN_LOG, V_VAR1);
          Serial.println(F("Getting pulse count"));
          Serial.println(F("."));
          wait( 1000 );
        }
        attachInterrupt( digitalPinToInterrupt( BUCKET_PIN ), sensorTipped, CHANGE ); //FALLING );  // depending on location of the hall effect sensor may need CHANGE
      }
      
      void setup() {
        Serial.begin( 115200 );
        pinMode( BUCKET_PIN, INPUT_PULLUP );
      
        unsigned long functionTimeout = millis();
        while ( timeStatus() == timeNotSet && millis() - functionTimeout < 30000UL ) {
          requestTime();
          Serial.println(F("Getting Time"));
          Serial.println(F("."));
          wait( 1000 );
        }
      
        lastHour = hour();
      }
      
      /**
        Sends the value of the rain gauge to the Gateway.
      */
      void sendRainVolumeData() {
        float hwRainVolume = hwPulseCounter * bucketSize;
        Serial.print( "Tipped " );
        Serial.print( hwPulseCounter );
        Serial.println( " times." );
        Serial.print( "Rain fall is " );
        Serial.print( hwRainVolume, 1 );
        Serial.println( " mm." );
        send( msgRain.set( (float)hwRainVolume, 1 ) );
        wait( MS_WAIT );
        send( lastCounterMsg.set( hwPulseCounter ) );
        wait( MS_WAIT );
      }
      
      void loop() {
        if ( wasTippedCounter != hwPulseCounter ) {
          hwPulseCounter = wasTippedCounter;
          sendRainVolumeData();
        }
      
        byte currentHour = hour();
        if (currentHour != lastHour) {
          Serial.println( "Resyncing hour" );
          requestTime(); // sync the time every hour
          wait( MS_WAIT );
          lastHour = currentHour;
          sendRainVolumeData(); // Send heart beat
        }
      
      }
      
      void sensorTipped() {
        unsigned long thisTipTime = millis();
        if (thisTipTime - lastTipTime > 100UL) {
          wasTippedCounter++;
        }
        lastTipTime = thisTipTime;
      }
      
      void receiveTime(unsigned long time) {
        Serial.println( F("Time received..."));
        setTime(time);
        char theTime[6];
        sprintf(theTime, "%d:%2d", hour(), minute());
        Serial.println(theTime);
      }
      
      void receive(const MyMessage &message) {
        if ( message.sensor == CHILD_ID_RAIN_LOG && message.type == V_VAR1) { // We only expect pulse count values from the gateway
          hwPulseCounter = message.getULong();
          wasTippedCounter = hwPulseCounter;
          pcReceived = true;
      
          Serial.print("Received last pulse count from gw: ");
          Serial.println(hwPulseCounter);
        }
      }
      
      posted in Development
      edweather
      edweather
    • Please share your raingauge sketch that works with Domoticz

      Can someone please share his Raingauge sketch that works with domoticz and is running from an external powersupply 3v or 5v. Trying to get the 'original' to work but it does not work well. It keeps sending rainfall every hour even if it does not rain ☂
      I tried the example from @sundberg84 and @TheoL but they have added extra sensor or using batteries.
      I am using the latest Mysensors 2.1.1 using esp8266 gateway with domoticz 3.7416.

      Thanks Edwin.

      My last try of the raingauge sketch. This one keeps asking the V_VAR1 value from the gateway.

      // Arduino Tipping Bucket Rain Gauge
      
      
      #define MY_DEBUG // Enable MySensors debug prints to serial monitor
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      
      #include <SPI.h>
      #include <MySensors.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 BATT_CHILD 2
      #define NODE_ID AUTO // or AUTO to let controller assign
      #define SKETCH_NAME "Rain Gauge" // Change to a fancy name you like
      #define SKETCH_VERSION "10" // Your version
      
      
      unsigned long SLEEP_TIME = 180*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.3; // 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);
      
      void setup() 
      { 
        #ifndef MY_DEBUG
        SERIAL_START(115200);  //Start serial if MySensors debugging isn't enabled
        #endif
        
      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
      }
      
      void presentation()  {
      
      delay(500); // Allow time for radio if power used as reset
      
      // 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 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) {
        
      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;
      }
      
      }
      
      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 incomingMessage(const MyMessage &message) {
      if (message.type==V_VAR1) {
      hwPulseCounter = message.getULong();
      hwRainVolume = hwPulseCounter;
      pcReceived = true;
      }
      
      
      //Sends 1 per hour as a heartbeat.
      send(volumeMsg.set((float)hwRainVolume,1));
      send(lastCounterMsg.set(hwPulseCounter));
      }
      
      
      
      posted in Development
      edweather
      edweather