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. Office plant monitoring

Office plant monitoring

Scheduled Pinned Locked Moved My Project
223 Posts 39 Posters 131.7k Views 42 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.
  • J Jan Gatzke

    @Dennis-van-der-Wolf

    Which sketch did you use? The one from this page needs the fork connected to analog input pins Ax.

    Dennis van der WolfD Offline
    Dennis van der WolfD Offline
    Dennis van der Wolf
    wrote on last edited by
    #204

    @Jan-Gatzke I have connected the fork to A0 and A1 of mine arduino nano. Now i have this result:

    10.02.2017 12:17:35	Multi Sensor (multi2)	SoilMoistPercentageSensor	-182 %
    10.02.2017 12:12:04	Multi Sensor (multi2)	SoilMoistPercentageSensor	-455 %
    10.02.2017 12:06:33	Multi Sensor (multi2)	SoilMoistPercentageSensor	-317 %
    10.02.2017 12:01:02	Multi Sensor (multi2)	SoilMoistPercentageSensor	255 %
    10.02.2017 11:55:31	Multi Sensor (multi2)	SoilMoistPercentageSensor	-547 %
    10.02.2017 11:49:26	Multi Sensor (multi2)	SoilMoistPercentageSensor	1169 %
    10.02.2017 11:43:55	Multi Sensor (multi2)	SoilMoistPercentageSensor	40 %
    10.02.2017 11:38:24	Multi Sensor (multi2)	SoilMoistPercentageSensor	-250 %
    

    This is the sketch i use:

    /*
     * 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
     *
     * Arduino soil moisture based on gypsum sensor/resistive sensor to avoid electric catalyse in soil
     *  Required to interface the sensor: 2 * 4.7kOhm + 2 * 1N4148
     *
     * Gypsum sensor and calibration:
     *    DIY: See http://vanderleevineyard.com/1/category/vinduino/1.html
     *    Built: Davis / Watermark 200SS
     *        http://www.cooking-hacks.com/watermark-soil-moisture-sensor?_bksrc=item2item&_bkloc=product
     *        http://www.irrometer.com/pdf/supportmaterial/sensors/voltage-WM-chart.pdf
     *        cb (centibar) http://www.irrometer.com/basics.html
     *            0-10 Saturated Soil. Occurs for a day or two after irrigation
     *            10-20 Soil is adequately wet (except coarse sands which are drying out at this range)
     *            30-60 Usual range to irrigate or water (except heavy clay soils).
     *            60-100 Usual range to irrigate heavy clay soils
     *            100-200 Soil is becoming dangerously dry for maximum production. Proceed with caution.
     *
     * Connection:
     *  D6, D7: alternative powering to avoid sensor degradation
     * A0, A1: alternative resistance mesuring
     *
     *  Based on:
     *  "Vinduino" portable soil moisture sensor code V3.00
     *   Date December 31, 2012
     *   Reinier van der Lee and Theodore Kaskalis
     *   www.vanderleevineyard.com
     * Contributor: epierre
     */
    
    // Copyright (C) 2015, Reinier van der Lee
    // www.vanderleevineyard.com
    
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation, either version 3 of the License, or
    // any later version.
    
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <math.h>       // Conversion equation from resistance to %
    #include <MySensors.h>
    
    // Setting up format for reading 3 soil sensors
    #define NUM_READS 10    // Number of sensor reads for filtering
    #define CHILD_ID 0
    
    MyMessage msg(CHILD_ID, V_LEVEL);
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    long buffer[NUM_READS];
    int index;
    
    /// @brief Structure to be used in percentage and resistance values matrix to be filtered (have to be in pairs)
    typedef struct {
        int moisture; //!< Moisture
        long resistance; //!< Resistance
    } values;
    
    const long knownResistor = 4700;  // Constant value of known resistor in Ohms
    
    int supplyVoltage;                // Measured supply voltage
    int sensorVoltage;                // Measured sensor voltage
    
    values valueOf[NUM_READS];        // Calculated moisture percentages and resistances to be sorted and filtered
    
    int i;                            // Simple index variable
    
    void setup()
    {
        // initialize the digital pins as an output.
        // Pin 6,7 is for sensor 1
        // initialize the digital pin as an output.
        // Pin 6 is sense resistor voltage supply 1
        pinMode(6, OUTPUT);
    
        // initialize the digital pin as an output.
        // Pin 7 is sense resistor voltage supply 2
        pinMode(7, OUTPUT);
    }
    
    void presentation()
    {
        sendSketchInfo("Soil Moisture Sensor Reverse Polarity", "1.0");
        present(CHILD_ID, S_MOISTURE);
    }
    
    void loop()
    {
    
        measure(6,7,1);
        Serial.print ("\t");
        Serial.println (average());
        long read1 = average();
    
        measure(7,6,0);
        Serial.print ("\t");
        Serial.println (average());
        long read2= average();
    
        long sensor1 = (read1 + read2)/2;
    
        Serial.print ("resistance bias =" );
        Serial.println (read1-read2);
        Serial.print ("sensor bias compensated value = ");
        Serial.println (sensor1);
        Serial.println ();
    
        //send back the values
        send(msg.set((long int)ceil(sensor1)));
        // delay until next measurement (msec)
        sleep(SLEEP_TIME);
    }
    
    void measure (int phase_b, int phase_a, int analog_input)
    {
        // read sensor, filter, and calculate resistance value
        // Noise filter: median filter
    
        for (i=0; i<NUM_READS; i++) {
    
            // Read 1 pair of voltage values
            digitalWrite(phase_a, HIGH);                 // set the voltage supply on
            delayMicroseconds(25);
            supplyVoltage = analogRead(analog_input);   // read the supply voltage
            delayMicroseconds(25);
            digitalWrite(phase_a, LOW);                  // set the voltage supply off
            delay(1);
    
            digitalWrite(phase_b, HIGH);                 // set the voltage supply on
            delayMicroseconds(25);
            sensorVoltage = analogRead(analog_input);   // read the sensor voltage
            delayMicroseconds(25);
            digitalWrite(phase_b, LOW);                  // set the voltage supply off
    
            // Calculate resistance
            // the 0.5 add-term is used to round to the nearest integer
            // Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
            long resistance = (knownResistor * (supplyVoltage - sensorVoltage ) / sensorVoltage) ;
    
            delay(1);
            addReading(resistance);
            Serial.print (resistance);
            Serial.print ("\t");
        }
    }
    
    
    
    // Averaging algorithm
    void addReading(long resistance)
    {
        buffer[index] = resistance;
        index++;
        if (index >= NUM_READS) {
            index = 0;
        }
    }
    
    long average()
    {
        long sum = 0;
        for (int i = 0; i < NUM_READS; i++) {
            sum += buffer[i];
        }
        return (long)(sum / NUM_READS);
    }
    
    1 Reply Last reply
    0
    • ronnyandreR Offline
      ronnyandreR Offline
      ronnyandre
      wrote on last edited by
      #205

      Thanks for this great solution @mfalkvidd! It works great when my Arduino Pro Mini is connected to the computer, but not when I try to run it off a battery pack.

      I have a Pro Mini 3.3v connected to a 0.8-3.3v step up from a battery pack (2xAA; 3v). And then I have connected the radio and sensor to VCC on the Pro Mini. When the Pro Mini is connected to my iMac, Domoticz receives everything as it should. However, when I disconnect it from the computer and connect the battery source, all LEDs light as they should, indicitating that they have power, but it won't connect to Domoticz over NRF24.

      I have used a multimeter to check the voltage and if the radio receives enough power, and it does. All power/ground pins show around 3.3v. Any ideas to debug what's wrong?

      Newbie with RPi and Domoticz, trying to automate my home.

      mfalkviddM 1 Reply Last reply
      0
      • J joshmosh

        @mfalkvidd, @Nicklas-Starkel
        similar problem here. I have a bare ATMega 328P, running @ 8 MHz internal oszillator. no LED, bod disabled, (if enabled, the ADC is running also during sleep, so this means additional power consumption), nothing else connected that could draw additional power.
        I use mfalkvidd's sketch (BTW, thanks a lot for it !), but converted to mysensors 2.0. I see a voltage drop way higher than mfalkvidd, although I don't use a china clone ;-).
        So it seems, that the higher power consumption may be due to mysensors V2 ? I cannot imagine a reason for that, because why should relatively low level functions like power save routines be different in 2.0 ?
        Perhaps hek can comment ?

        Fat FlyF Offline
        Fat FlyF Offline
        Fat Fly
        wrote on last edited by
        #206

        @joshmosh said in Office plant monitoring:

        mfalkvidd

        Where i find mfalkvidd's sketch ?

        mfalkviddM 1 Reply Last reply
        0
        • ronnyandreR ronnyandre

          Thanks for this great solution @mfalkvidd! It works great when my Arduino Pro Mini is connected to the computer, but not when I try to run it off a battery pack.

          I have a Pro Mini 3.3v connected to a 0.8-3.3v step up from a battery pack (2xAA; 3v). And then I have connected the radio and sensor to VCC on the Pro Mini. When the Pro Mini is connected to my iMac, Domoticz receives everything as it should. However, when I disconnect it from the computer and connect the battery source, all LEDs light as they should, indicitating that they have power, but it won't connect to Domoticz over NRF24.

          I have used a multimeter to check the voltage and if the radio receives enough power, and it does. All power/ground pins show around 3.3v. Any ideas to debug what's wrong?

          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by mfalkvidd
          #207

          @ronnyandre a multimeter is unfortunately not sensitive enough to display if there is enough power during the short bursts when the radio is active.

          Most step-ups don't deliver power that is stable enough. You could try adding more/larger capacitors, but from what I have seen in the forum, people seldom get thing working reliably with a step-up. I have never tried using step-up myself, I use power directly from the batteries.

          If you haven't checked already, see the troubleshooting chart at https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help/

          ronnyandreR 1 Reply Last reply
          1
          • Fat FlyF Fat Fly

            @joshmosh said in Office plant monitoring:

            mfalkvidd

            Where i find mfalkvidd's sketch ?

            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #208

            Where i find mfalkvidd's sketch ?

            At github, but be aware that this code is for MySensors 1.x. It does not work with MySensors 2.x.

            1 Reply Last reply
            0
            • mfalkviddM mfalkvidd

              @ronnyandre a multimeter is unfortunately not sensitive enough to display if there is enough power during the short bursts when the radio is active.

              Most step-ups don't deliver power that is stable enough. You could try adding more/larger capacitors, but from what I have seen in the forum, people seldom get thing working reliably with a step-up. I have never tried using step-up myself, I use power directly from the batteries.

              If you haven't checked already, see the troubleshooting chart at https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help/

              ronnyandreR Offline
              ronnyandreR Offline
              ronnyandre
              wrote on last edited by
              #209

              @mfalkvidd Thanks for the quick answer! I also read on the page for battery powered sensors that the step up generates alot of noise that can interfere with the radio, and that a solution might be to add capacitators (which I already tried), but also powering the radio directly from batteries. I'll try that later today. Thanks! :smiley:

              And thank you for the link to the troubleshooting. It's now bookmarked! :wink:

              Newbie with RPi and Domoticz, trying to automate my home.

              1 Reply Last reply
              1
              • Fat FlyF Offline
                Fat FlyF Offline
                Fat Fly
                wrote on last edited by
                #210

                Please somebody help me add to skech one relay for water pump. I use this in Domoticz. I do not want build other hardware for this.It is possible ?

                1 Reply Last reply
                0
                • gohanG Offline
                  gohanG Offline
                  gohan
                  Mod
                  wrote on last edited by
                  #211

                  Just copy the relay code from https://www.mysensors.org/build/relay and add it your sketch and make necessary changes to adapt it: like setting child_id in presentation

                  Fat FlyF 1 Reply Last reply
                  0
                  • gohanG gohan

                    Just copy the relay code from https://www.mysensors.org/build/relay and add it your sketch and make necessary changes to adapt it: like setting child_id in presentation

                    Fat FlyF Offline
                    Fat FlyF Offline
                    Fat Fly
                    wrote on last edited by
                    #212

                    @gohan I make something this. Please look if all is right. My software writer skill is low. :) Some small errors. :)
                    https://pastebin.com/8LWpgb8L

                    1 Reply Last reply
                    0
                    • gohanG Offline
                      gohanG Offline
                      gohan
                      Mod
                      wrote on last edited by
                      #213

                      because you are using old code, you need to convert it from libraries 1.5 to 2.x: there is a guide to do that

                      1 Reply Last reply
                      0
                      • Fat FlyF Offline
                        Fat FlyF Offline
                        Fat Fly
                        wrote on last edited by
                        #214

                        Can i use old libraries and gateway version 2.1 ?

                        1 Reply Last reply
                        0
                        • gohanG Offline
                          gohanG Offline
                          gohan
                          Mod
                          wrote on last edited by
                          #215

                          You can downgrade libraries and use old examples, but I'd suggest to stick to the new version

                          1 Reply Last reply
                          1
                          • Fat FlyF Offline
                            Fat FlyF Offline
                            Fat Fly
                            wrote on last edited by
                            #216

                            @gohan said in Office plant monitoring:

                            but I'd suggest to stick to the new version

                            I try but idonotknow. :)

                            1 Reply Last reply
                            0
                            • Fat FlyF Offline
                              Fat FlyF Offline
                              Fat Fly
                              wrote on last edited by
                              #217

                              @gohan
                              Please help with small errors. https://pastebin.com/VRXyT8Ut I try for library 2.x

                              1 Reply Last reply
                              0
                              • fhenrycoF Offline
                                fhenrycoF Offline
                                fhenryco
                                wrote on last edited by
                                #218

                                It's a pity that at least one sketch for the analog reading of moisture sensor is not v2 compatible and made available on the main page ... i have no idea if making it v2 compatible would be a hard job...even if it's just a question of changing some library calls i'm afraid i don't have the skill for that...

                                1 Reply Last reply
                                0
                                • mfalkviddM Offline
                                  mfalkviddM Offline
                                  mfalkvidd
                                  Mod
                                  wrote on last edited by
                                  #219

                                  My Bonsai tree humidity node celebrates 2 years on battery today!

                                  During these two years, the gateway has received 146,528 updates on humidity level (and an additional 30,870 updates on voltage level).

                                  The battery level has gone from 3.187V to 3.049, which means an average drop of 0,0058V per month. Assuming I let it go down to 2.34V (limit for 8MHz according to the datasheet) and that the voltage drop is linear, I should get (3.187-2.34)/0.0058 = 146 months = ~12 years. There are several error sources in this calculation, but it looks like battery life will be quite good.

                                  Here are the voltage and humidity graphs for the last year.
                                  0_1510070572143_chart.png
                                  0_1510070578967_temp.png

                                  As you can see, there was a problem in November. I was asked to verify the battery voltage reading by using a multimeter. When I opened the box to do that, I must have tripped something because the node got caught in some sort of loop, consuming battery. I restarted the node and the batteries recovered almost to the level they had before the problem occurred.

                                  Last year's report: https://forum.mysensors.org/post/52232

                                  gohanG 1 Reply Last reply
                                  2
                                  • mfalkviddM mfalkvidd

                                    My Bonsai tree humidity node celebrates 2 years on battery today!

                                    During these two years, the gateway has received 146,528 updates on humidity level (and an additional 30,870 updates on voltage level).

                                    The battery level has gone from 3.187V to 3.049, which means an average drop of 0,0058V per month. Assuming I let it go down to 2.34V (limit for 8MHz according to the datasheet) and that the voltage drop is linear, I should get (3.187-2.34)/0.0058 = 146 months = ~12 years. There are several error sources in this calculation, but it looks like battery life will be quite good.

                                    Here are the voltage and humidity graphs for the last year.
                                    0_1510070572143_chart.png
                                    0_1510070578967_temp.png

                                    As you can see, there was a problem in November. I was asked to verify the battery voltage reading by using a multimeter. When I opened the box to do that, I must have tripped something because the node got caught in some sort of loop, consuming battery. I restarted the node and the batteries recovered almost to the level they had before the problem occurred.

                                    Last year's report: https://forum.mysensors.org/post/52232

                                    gohanG Offline
                                    gohanG Offline
                                    gohan
                                    Mod
                                    wrote on last edited by
                                    #220

                                    @mfalkvidd said in Office plant monitoring:

                                    and that the voltage drop is linear

                                    You wish!!! :D

                                    mfalkviddM 1 Reply Last reply
                                    0
                                    • gohanG gohan

                                      @mfalkvidd said in Office plant monitoring:

                                      and that the voltage drop is linear

                                      You wish!!! :D

                                      mfalkviddM Offline
                                      mfalkviddM Offline
                                      mfalkvidd
                                      Mod
                                      wrote on last edited by mfalkvidd
                                      #221

                                      @gohan no actually I don't. The voltage drop is normally a s-shaped curve that is very flat in the middle. That means I am experiencing a higher drop at the beginning. That's likely the reason that the prediction after 2 years is more than 10% longer battery life than the prediction after 1 year was.

                                      1 Reply Last reply
                                      0
                                      • gohanG Offline
                                        gohanG Offline
                                        gohan
                                        Mod
                                        wrote on last edited by
                                        #222

                                        Yes, it depends when the voltage starts to drop significantly, but unless you have tested another battery before it is hard to know in advance 😀

                                        mfalkviddM 1 Reply Last reply
                                        0
                                        • gohanG gohan

                                          Yes, it depends when the voltage starts to drop significantly, but unless you have tested another battery before it is hard to know in advance 😀

                                          mfalkviddM Offline
                                          mfalkviddM Offline
                                          mfalkvidd
                                          Mod
                                          wrote on last edited by
                                          #223

                                          @gohan alkaline batteries in general have been tested quite extensively and don't deviate much from the S-curve characteristics.

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


                                          14

                                          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