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. My Project
  3. Leaf Wetness

Leaf Wetness

Scheduled Pinned Locked Moved My Project
45 Posts 9 Posters 33.2k Views 3 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.
  • hekH hek

    @epierre

    gw.sleep() sleeps the radio as well. What do you mean by power down radio? Like cutting power using digital pin?

    epierreE Offline
    epierreE Offline
    epierre
    Hero Member
    wrote on last edited by
    #20

    @hek said:

    @epierre

    gw.sleep() sleeps the radio as well. What do you mean by power down radio? Like cutting power using digital pin?
    yes, now you combine sleep for the radio and delay, what I mean is to have loop() run without radio, and if a transmission is needed to have a command that power it.

    If you have a long dry period, a device on battery will consume a lot of power having the radion on and off, if it is always off until a sensor finds something, that would save more power, no ?

    z-wave - Vera -> Domoticz
    rfx - Domoticz <- MyDomoAtHome <- Imperihome
    mysensors -> mysensors-gw -> Domoticz

    1 Reply Last reply
    0
    • RJ_MakeR Offline
      RJ_MakeR Offline
      RJ_Make
      Hero Member
      wrote on last edited by
      #21

      Wake only on interrupt?

      RJ_Make

      1 Reply Last reply
      0
      • epierreE Offline
        epierreE Offline
        epierre
        Hero Member
        wrote on last edited by
        #22

        In my idea, a value above 0 would mean sending the info, an interrupt could be generated this way ?

        z-wave - Vera -> Domoticz
        rfx - Domoticz <- MyDomoAtHome <- Imperihome
        mysensors -> mysensors-gw -> Domoticz

        1 Reply Last reply
        0
        • elisavetgrigE Offline
          elisavetgrigE Offline
          elisavetgrig
          wrote on last edited by
          #23

          Hey,
          I am a newbie (in the forum) and in the arduino/sensors development. I bought the Leaf Wetness from cooking-hacks.com. Can I connected it to my Arduino via Analog input? Is it easy?

          SparkmanS 1 Reply Last reply
          0
          • elisavetgrigE elisavetgrig

            Hey,
            I am a newbie (in the forum) and in the arduino/sensors development. I bought the Leaf Wetness from cooking-hacks.com. Can I connected it to my Arduino via Analog input? Is it easy?

            SparkmanS Offline
            SparkmanS Offline
            Sparkman
            Hero Member
            wrote on last edited by
            #24

            @elisavetgrig Welcome to the forum. The answer is yes to both questions. Given that the sensor is a resistive element, you need to build a voltage divider. Google "voltage divider" Arduino and you'll find lots of examples.

            Cheers
            Al

            1 Reply Last reply
            0
            • FotoFieberF Offline
              FotoFieberF Offline
              FotoFieber
              Hardware Contributor
              wrote on last edited by
              #25

              Measuring the current with DC doesn't seem to be the ideal solution:
              thread

              SparkmanS 1 Reply Last reply
              0
              • FotoFieberF FotoFieber

                Measuring the current with DC doesn't seem to be the ideal solution:
                thread

                SparkmanS Offline
                SparkmanS Offline
                Sparkman
                Hero Member
                wrote on last edited by
                #26

                @FotoFieber That thread is regarding soil moisture measurements which is different than leaf wetness. For soil, capacitive is the best way to go IMHO.

                Cheers
                Al

                1 Reply Last reply
                0
                • FotoFieberF Offline
                  FotoFieberF Offline
                  FotoFieber
                  Hardware Contributor
                  wrote on last edited by
                  #27

                  AC Statement ☺

                  1 Reply Last reply
                  0
                  • elisavetgrigE Offline
                    elisavetgrigE Offline
                    elisavetgrig
                    wrote on last edited by
                    #28

                    ok...Thank you... I will try the "voltage divider" and I will see what will happen!

                    1 Reply Last reply
                    0
                    • elisavetgrigE Offline
                      elisavetgrigE Offline
                      elisavetgrig
                      wrote on last edited by elisavetgrig
                      #29

                      assembly.jpg

                      1 Reply Last reply
                      0
                      • elisavetgrigE Offline
                        elisavetgrigE Offline
                        elisavetgrig
                        wrote on last edited by
                        #30

                        Did you mean something like the figure above? Or I only need to connect one resistor to one wire and the other wire to another pin in the Arduino?

                        SparkmanS 1 Reply Last reply
                        0
                        • elisavetgrigE elisavetgrig

                          Did you mean something like the figure above? Or I only need to connect one resistor to one wire and the other wire to another pin in the Arduino?

                          SparkmanS Offline
                          SparkmanS Offline
                          Sparkman
                          Hero Member
                          wrote on last edited by
                          #31

                          @elisavetgrig You're missing the connections to a voltage source and ground. You also only need one resistor as the wetness sensor is the 2nd resistor in the voltage divider circuit. Take a look at this: http://homepage.cs.uri.edu/faculty/hamel/workshops/as220-sept-09/sensors-voltage-dividers.html.

                          Cheers
                          Al

                          1 Reply Last reply
                          0
                          • elisavetgrigE Offline
                            elisavetgrigE Offline
                            elisavetgrig
                            wrote on last edited by
                            #32

                            You are right! I thought that I missing something... always there are Data connection, VCC connection and GND.. and I had only one! I made another dummy scheme... Is that better?leaf wetness.jpg

                            SparkmanS 1 Reply Last reply
                            0
                            • elisavetgrigE elisavetgrig

                              You are right! I thought that I missing something... always there are Data connection, VCC connection and GND.. and I had only one! I made another dummy scheme... Is that better?leaf wetness.jpg

                              SparkmanS Offline
                              SparkmanS Offline
                              Sparkman
                              Hero Member
                              wrote on last edited by
                              #33

                              @elisavetgrig Take a look at the second diagram of the link I posted. Right now you show the GND pin connected to the Analog pin and Vcc is also connected to the same spot, so that's not going to work.

                              Cheers
                              Al

                              1 Reply Last reply
                              0
                              • elisavetgrigE Offline
                                elisavetgrigE Offline
                                elisavetgrig
                                wrote on last edited by
                                #34

                                I based in the second diagram... i think that I understand it... resistorss-leaf wet.png

                                SparkmanS 1 Reply Last reply
                                0
                                • elisavetgrigE elisavetgrig

                                  I based in the second diagram... i think that I understand it... resistorss-leaf wet.png

                                  SparkmanS Offline
                                  SparkmanS Offline
                                  Sparkman
                                  Hero Member
                                  wrote on last edited by
                                  #35

                                  @elisavetgrig As I mentioned a few posts ago and how it's shown in the diagram on that link, is that you only need one resistor. The leaf wetness sensor becomes the other resistor in the circuit. In your last diagram, you have both the terminals of the wetness sensor connected to ground. Think of the wetness sensor as a resistor, with each of the terminals representing one leg of a regular resistor.

                                  Cheers
                                  Al

                                  1 Reply Last reply
                                  0
                                  • elisavetgrigE Offline
                                    elisavetgrigE Offline
                                    elisavetgrig
                                    wrote on last edited by
                                    #36

                                    OK... So I need only one resister... I think that "Scheme 2" is closer to the solution... images ofs.jpg

                                    1 Reply Last reply
                                    0
                                    • 5546dug5 Offline
                                      5546dug5 Offline
                                      5546dug
                                      wrote on last edited by
                                      #37

                                      @epierre how is the gold plating holding out on the sensor?
                                      Is there pitting and would you'd recommend this over the style in the store?
                                      How is the battery life with this setup?

                                      Thanks

                                      1 Reply Last reply
                                      0
                                      • epierreE Offline
                                        epierreE Offline
                                        epierre
                                        Hero Member
                                        wrote on last edited by
                                        #38

                                        Hello,

                                        gold plating is a must have for outdoor.

                                        I am now regarding to have something more robust in time , I'm waiting for a light with movement with solar pannel to modify it for it.

                                        z-wave - Vera -> Domoticz
                                        rfx - Domoticz <- MyDomoAtHome <- Imperihome
                                        mysensors -> mysensors-gw -> Domoticz

                                        1 Reply Last reply
                                        0
                                        • AWIA Offline
                                          AWIA Offline
                                          AWI
                                          Hero Member
                                          wrote on last edited by AWI
                                          #39

                                          In the case described there is a constant battery drain when there is "wetness" (moisture) on the sensor. This also implies an electrolytic process which takes care of eroding your sensor. No matter if you use gold plating or not.

                                          electrolysis.jpg

                                          To avoid both you can supply the sensor during measurement only -and- reverse te polarity each time.

                                          An example ketch which takes care of measuring three moisture sensors which relies on this principle.

                                          (the actual measurement is in the "ReadMoistureValues()" routine)

                                          /*
                                           PROJECT: MySensors / Floor moisture sensor - measures moisture
                                           PROGRAMMER: AWI
                                           DATE: june 7, 2015/ last update: june 9, 2015
                                           FILE: AWI_FloorMoisture.ino
                                           LICENSE: Public domain
                                          
                                           Hardware: tbd .- ATmega328p board w/ NRF24l01
                                          	and MySensors 1.4
                                          
                                          	(later: Temp & Humidity - HTU21)
                                          	
                                          	
                                          Special:
                                          	program with Arduino Pro 3.3V 8Mhz
                                          	
                                          SUMMARY:
                                          	Moisture by analog read a polarity switching voltage divider between (high/ low)
                                           Remarks:
                                          	Fixed node-id
                                          */
                                          
                                          #include <SPI.h>
                                          #include <MySensor.h>
                                          #include <Wire.h> 								// I2C
                                          
                                          #define batteryVoltagePin A0
                                          #define MoistureHighPin 3
                                          #define MoistureLowPin 4
                                          #define Moisture1ReadPin A1
                                          #define Moisture2ReadPin A2
                                          #define Moisture3ReadPin A3
                                          #define BuzzerPin 5
                                          #define LedPin 6
                                          
                                          // MySensors Child ID's
                                          #define MOISTURE1_CHILD_ID 5					// Moisture 1
                                          #define MOISTURE2_CHILD_ID 6					// Moisture 2
                                          #define MOISTURE3_CHILD_ID 7					// Moisture 3
                                          // #define MOISTURE4_CHILD_ID 8					// Moisture 4
                                          
                                          // MySensors messages 
                                          MyMessage moisturePercentageMsg1(MOISTURE1_CHILD_ID, V_HUM);	// Percentage
                                          MyMessage moisturePercentageMsg2(MOISTURE2_CHILD_ID, V_HUM);	// Percentage
                                          MyMessage moisturePercentageMsg3(MOISTURE3_CHILD_ID, V_HUM);	// Percentage
                                          
                                          // MySensors instantiate 
                                          MySensor gw(9,10); 								// board, 3.3v (pin default 9,10)
                                          
                                          // Reference values for ADC and Battery measurements
                                          const float VccMin        = 1.0*3.5;    // Minimum expected Vcc level, in Volts. Example for 1 rechargeable lithium-ion.
                                          const float VccMax        = 1.0*4.2;    // Maximum expected Vcc level, in Volts. 
                                          float VccReference = 3.3 ;				// voltage reference for measurement (=vcc)
                                          unsigned long SLEEP_TIME = 60000;  		//  10 sec sleep time between reads (seconds * 1000 milliseconds)
                                          
                                          // **** class for Moisture measurement *****
                                          // attaches an analog input to a data structure for measurements
                                          // 			measures % of full scale voltage and scales the range of actual values
                                          // 			stores current/ min & max values for the sensor
                                          class MoistureSense
                                          {
                                          public:
                                          	// Create an instance of MoistureSense and initialize (digital & input pin and reference values)
                                            MoistureSense(uint8_t ReadPin, int LowValue, int HighValue) ; 		// attach to pin and init
                                            void ReadHigh();								// Read moisture if positive
                                            void ReadLow();								// Read moisture with polarity inverted
                                            // average the low/ high readings ang get the moisture percent value
                                            uint8_t MoisturePercent();
                                            void ResetMinMax();							// reset min & max values
                                          
                                          protected:
                                            uint8_t _ReadPin ; 							// Hardware Analog Pin number
                                            int _CurMoisture, _MaxMoisture, _MinMoisture, _Low, _High, _HighValue, _LowValue ;
                                            uint8_t _curState; 
                                            };
                                          
                                          // to create an instance of MoistureSense and initialize (input pin and reference values)
                                          MoistureSense::MoistureSense(uint8_t ReadPin, int LowValue, int HighValue) {		// attach to pins and init
                                          	_ReadPin = ReadPin;
                                          	_LowValue = LowValue;
                                          	_HighValue = HighValue;
                                          	_CurMoisture = _MaxMoisture = _MinMoisture = NULL ;	// min & max in percent
                                            }
                                          void MoistureSense::ReadHigh()
                                           // Read moisture with high polarity (in relation to Gnd)
                                          {
                                          	_High = analogRead(_ReadPin);
                                          }
                                          void MoistureSense::ReadLow()
                                           // Read moisture with low polarity (in relation to Vcc)
                                          {
                                          	_Low = 1024 - analogRead(_ReadPin);
                                          }
                                          void MoistureSense::ResetMinMax()
                                           // Reset min & max values
                                          {
                                          	_MinMoisture = _MaxMoisture = _CurMoisture;
                                          }
                                          uint8_t MoistureSense::MoisturePercent()
                                          // average the low/ high readings ang get the moisture percent value
                                          {
                                          	uint8_t reading = constrain(map((_Low + _High)/2, _LowValue, _HighValue, 0, 100),0,100);	// average map to the 0-100% range
                                          	_MinMoisture = min(reading, _MinMoisture);	// set min and max values
                                          	_MaxMoisture = max(reading, _MaxMoisture);
                                          }
                                          
                                          // Instantiate moisture sensor objects
                                          MoistureSense Moisture1(Moisture1ReadPin, 0, 1024); 
                                          MoistureSense Moisture2(Moisture2ReadPin, 0, 1024); 
                                          MoistureSense Moisture3(Moisture3ReadPin, 0, 1024); 
                                          
                                          void setup(){
                                            	// MySensors setup (baud 115200)
                                          	gw.begin(NULL, 21);  // fixed node 21, (final: connected to repeater 3 (living))"
                                          	// Send the sketch version information to the gateway and Controller
                                          	gw.sendSketchInfo("AWI FloorMoisture 21", "1.0");
                                          	gw.present(MOISTURE1_CHILD_ID, S_HUM);			// Present Moisture sensors as humidity
                                          	gw.present(MOISTURE2_CHILD_ID, S_HUM);			// Present Moisture sensors as humidity
                                          	gw.present(MOISTURE3_CHILD_ID, S_HUM);			// Present Moisture sensors as humidity
                                          
                                          	Serial.print("AWI Moisture Started ");
                                          	pinMode(BuzzerPin,OUTPUT);						// Setup intermittent buzzer & light
                                          	pinMode(LedPin,OUTPUT);
                                          }
                                          
                                          void loop(){
                                          //
                                          	Serial.println("Moisture Percentages");
                                          	ReadMoistureValues();
                                          	gw.send(moisturePercentageMsg1.set(Moisture1.MoisturePercent())); // MySensors Send (V) 
                                          	gw.send(moisturePercentageMsg2.set(Moisture2.MoisturePercent())); // MySensors Send (V) 
                                          	gw.send(moisturePercentageMsg3.set(Moisture3.MoisturePercent())); // MySensors Send (V) 
                                          	gw.sendBatteryLevel(batteryPercentage());
                                          	// show local alarm if moisture > 20%
                                          	if ((Moisture1.MoisturePercent()>20) || (Moisture2.MoisturePercent()>20) || 
                                          		(Moisture3.MoisturePercent()>20) || (batteryPercentage() < 10))
                                          	{
                                          		MoistureAlarm();
                                          	}
                                          	gw.sleep(SLEEP_TIME);							// low power for sleep time
                                          }
                                          
                                          unsigned ReadMoistureValues()
                                          // read all moisturevalues
                                          {
                                          	pinMode(MoistureLowPin, OUTPUT);				// first set all pins to measurement(non floating) mode
                                          	pinMode(MoistureHighPin, OUTPUT);
                                          	digitalWrite(MoistureLowPin, LOW); 				// Set polarity on voltage divider high and read the values
                                          	digitalWrite(MoistureHighPin, HIGH); delayMicroseconds(100);
                                          	Moisture1.ReadLow(); delayMicroseconds(100);
                                          	Moisture2.ReadLow(); delayMicroseconds(100);
                                          	Moisture3.ReadLow(); delayMicroseconds(100);
                                          	digitalWrite(MoistureLowPin, HIGH);				// reverse polarity on voltage divider and read values
                                          	digitalWrite(MoistureHighPin, LOW); delayMicroseconds(100);
                                          	Moisture1.ReadHigh(); delayMicroseconds(100);
                                          	Moisture2.ReadHigh(); delayMicroseconds(100);
                                          	Moisture3.ReadHigh(); delayMicroseconds(100);
                                          	pinMode(MoistureLowPin, INPUT);					// reset pins to floating, to avoid power leakage
                                          	pinMode(MoistureHighPin, INPUT);
                                          	Serial.print("Moist1: ");
                                          	Serial.print(Moisture1.MoisturePercent());
                                          	Serial.print(" , Moist2: ");
                                          	Serial.print(Moisture2.MoisturePercent());
                                          	Serial.print(" , Moist3: ");
                                          	Serial.print(Moisture3.MoisturePercent());
                                          	Serial.println();
                                           }
                                          
                                          unsigned MoistureAlarm()
                                          // If moisturelevel to high, sound & show local alarm
                                          {
                                          	digitalWrite(MoistureLowPin, HIGH);
                                          	digitalWrite(MoistureHighPin, HIGH); 
                                          	delay(100);										// sound & light for 100ms, uses a lot of power, so no no need for power down
                                          	digitalWrite(MoistureLowPin, LOW);	
                                          	digitalWrite(MoistureHighPin, LOW);
                                          }
                                          
                                          // get Battery Voltage & charge current
                                          // assumes a balanced voltage divider on Battery and uses the Vcc as reference (3.3V in this case)
                                          // Parameters:
                                          // - VccMin = minimum battery voltage
                                          // - VccMax = maximum battery voltage
                                          // - VccReference = reference voltage for ADC
                                          uint8_t batteryPercentage()
                                          {
                                          	float batteryVoltage = ((float)analogRead(batteryVoltagePin)* VccReference/1024) * 2;	// actual voltage is double
                                          	Serial.print("Batt: ");
                                          	Serial.print(batteryVoltage);
                                          	Serial.print("V ; ");
                                          	return(constrain(map(batteryVoltage, VccMin, VccMax, 0, 100),0,100));	// and map to the 0-100% range
                                          }
                                          
                                          1 Reply Last reply
                                          1
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          13

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 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