Raindrops Detection under v2



  • Hi,
    I hope someone can help me.
    I used the example of Soil & Moist sensor v1.5.x to read a rain sensor.
    After I upgraded to v2 the setch no longer works. Does anyone have such a sensor already in use and has a sample code for me?
    I'm not so good at programming 😞

    I use such a sensor: http://goo.gl/WywReQ

    Thank you!
    Dave



  • Hi Dave,

    Funny as i had the same problem.
    I tried using the digital pin with i could not get to work so i am using the A0 port now so have more than on and off.

    This is the sketch i am using and i use moisture as output to Domoticz:

    /**
     * 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 - Felix Haverkamp
     * 
     * DESCRIPTION
     * Example sketch sending soil moisture in percentage alarm to controller 
     * 
     */
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached 
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    //#define MY_RS485
    
    #include <SPI.h>
    #include <MySensors.h>  
     
    #define CHILD_ID 0   // Id of the sensor child
     
    int mostureSensor = 0;   // ANALOG Pin for Soil sensor, usally A0
    
    MyMessage msg(CHILD_ID, V_LEVEL);
    int lastSoilValue = -1;
     
    void presentation()  
    { 
      
     
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Regensensor", "1.0");
      // Register all sensors to gw (they will be created as child devices)  
      present(CHILD_ID, S_MOISTURE);
    }
     
    void loop()     
    {     
     
     
      int soilValue = map(analogRead(mostureSensor), 0, 1024, 100, 0);
     
      if (soilValue != lastSoilValue) {
        Serial.println(soilValue);
        send(msg.set(soilValue));
        lastSoilValue = soilValue;
      }
    sleep(3000);
    }
    


  • Hey,
    sounds great, I´ll test it as soon as possible.

    thank you!!!



  • It´s working and it´s better than before!
    Thank you so much, you´re the man of the day!



  • You're welcome.
    It was for me also a struggle to get it working.


Log in to reply
 

Suggested Topics

  • 8
  • 12
  • 2
  • 44
  • 2
  • 90

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts