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. Solar Powered Soil Moisture Sensor

Solar Powered Soil Moisture Sensor

Scheduled Pinned Locked Moved My Project
79 Posts 19 Posters 37.8k Views 35 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.
  • PaweMedP Offline
    PaweMedP Offline
    PaweMed
    wrote on last edited by PaweMed
    #47

    Hello. What should i do, when i have this problems:

    czujnik:12: error: expected unqualified-id before 'default'

    default BOD settings.

    ^

    C:\Users\Kompek\Downloads\arduino-1.6.9\czujnik\czujnik.ino: In function 'void setup()':

    czujnik:43: error: 'SENSOR_ANALOG_PINS' was not declared in this scope

    for (int i = 0; i < N_ELEMENTS(SENSOR_ANALOG_PINS); i++) {

                                  ^
    

    C:\Users\Kompek\Downloads\arduino-1.6.9\czujnik\czujnik.ino:5:35: note: in definition of macro 'N_ELEMENTS'

    #define N_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))

                                   ^
    

    C:\Users\Kompek\Downloads\arduino-1.6.9\czujnik\czujnik.ino: In function 'int readMoisture()':

    czujnik:102: error: 'SENSOR_ANALOG_PINS' was not declared in this scope

    pinMode(SENSOR_ANALOG_PINS[direction], INPUT_PULLUP); // Power on the sensor

           ^
    

    exit status 1
    expected unqualified-id before 'default'

    1 Reply Last reply
    0
    • F Offline
      F Offline
      flopp
      wrote on last edited by
      #48

      I would have try to use Ardunio IDE 1.6.8

      1 Reply Last reply
      0
      • HuczasH Offline
        HuczasH Offline
        Huczas
        wrote on last edited by
        #49

        it's misstaken source code - line 11 should be deleted and then all is compiling well, it's just end of comment from line 10, [enter] is unnecessery there.

        1 Reply Last reply
        0
        • F flopp

          @dbemowsk
          If you have the solar in the sun and the sensors in the shadow and protected from rain that will work.
          My idea is to use a solar for all my outdoor sensors but have a bigger solar panel and a bigger(more mah) that feeds my nodes, rain, temp, hum, pressure, light, UV and in future lightning.

          breimannB Offline
          breimannB Offline
          breimann
          wrote on last edited by
          #50

          @flopp
          I've been thinking along the same lines in terms of powering all my outdoor sensors with solar. Have you had a chance to try your ideas out yet? I'd be very interested in what you my have found. Should we start a new thread about that though? i'm very new to the forum so not sure (just joined tonight!).

          F 1 Reply Last reply
          0
          • breimannB breimann

            @flopp
            I've been thinking along the same lines in terms of powering all my outdoor sensors with solar. Have you had a chance to try your ideas out yet? I'd be very interested in what you my have found. Should we start a new thread about that though? i'm very new to the forum so not sure (just joined tonight!).

            F Offline
            F Offline
            flopp
            wrote on last edited by
            #51

            @breimann
            It have been in use since I write this post.
            I have had many problems with the nodes. I don't know if the problem is with my repeater node/GW.
            Time to time is stop sending and then suddenly without restarting the node, it start to send again.
            I have restarted the nodes sometimes also.
            Maybe it is to "small" solar panel so it takes time for it to recharge the battery?
            If you will do a solar panel node, go for a big panel with high mA output and also a big battery(1000mA), I am using 1.2 v battery. I think it is much better to use at least 2.5 volt battery then you don't need the step-up.

            breimannB 1 Reply Last reply
            0
            • Nca78N Offline
              Nca78N Offline
              Nca78
              Hardware Contributor
              wrote on last edited by
              #52

              I think the problem is the nimh battery, this kind of partial charge/discharge cycles is more suitable for a li-ion battery. It's ok when used as a garden light because the battery will discharge completely during the night and will not have a memory effect, but with the low power usage of a sensor it will lose capacity quickly.

              Also if the solar panel is 1.2V like one your picture I don't understand how it could have enough voltage to charge the battery after the voltage drop of the diode ? On the garden light I bought the solar panel is 2V so it's possible to charge the battery to 100% at 1.4V+

              F 1 Reply Last reply
              0
              • Nca78N Nca78

                I think the problem is the nimh battery, this kind of partial charge/discharge cycles is more suitable for a li-ion battery. It's ok when used as a garden light because the battery will discharge completely during the night and will not have a memory effect, but with the low power usage of a sensor it will lose capacity quickly.

                Also if the solar panel is 1.2V like one your picture I don't understand how it could have enough voltage to charge the battery after the voltage drop of the diode ? On the garden light I bought the solar panel is 2V so it's possible to charge the battery to 100% at 1.4V+

                F Offline
                F Offline
                flopp
                wrote on last edited by
                #53

                @Nca78
                Yes it can be the NiMh battery, but it is actually run for days maybe weeks with out any problem.
                Today I disconnect the power to ATmega and put it back directly and it started to work.
                If the power goes below 0.8-0.9 it seems that I have to disconnect the step-up otherwise the solar panel cannot charge the battery.

                Solar panel is 1.4V and battery is 1.2V it seems to work and I have around 1.2-1.3 V during night

                P 1 Reply Last reply
                0
                • F flopp

                  @breimann
                  It have been in use since I write this post.
                  I have had many problems with the nodes. I don't know if the problem is with my repeater node/GW.
                  Time to time is stop sending and then suddenly without restarting the node, it start to send again.
                  I have restarted the nodes sometimes also.
                  Maybe it is to "small" solar panel so it takes time for it to recharge the battery?
                  If you will do a solar panel node, go for a big panel with high mA output and also a big battery(1000mA), I am using 1.2 v battery. I think it is much better to use at least 2.5 volt battery then you don't need the step-up.

                  breimannB Offline
                  breimannB Offline
                  breimann
                  wrote on last edited by
                  #54

                  @flopp
                  Thank you for your reply. That's all helpful info.

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    flopp
                    wrote on last edited by
                    #55

                    A funny thing,
                    Yesterday I power off/on both my solar nodes and now the second one sent the data, haha strange??!! It was about 20 hours ago I powered it off/on

                    1 Reply Last reply
                    0
                    • F flopp

                      @Nca78
                      Yes it can be the NiMh battery, but it is actually run for days maybe weeks with out any problem.
                      Today I disconnect the power to ATmega and put it back directly and it started to work.
                      If the power goes below 0.8-0.9 it seems that I have to disconnect the step-up otherwise the solar panel cannot charge the battery.

                      Solar panel is 1.4V and battery is 1.2V it seems to work and I have around 1.2-1.3 V during night

                      P Offline
                      P Offline
                      punter9
                      wrote on last edited by punter9
                      #56

                      @flopp

                      guys seriously this is just yet another reason to write your reporting interval based on battery voltage and time and not on time alone.

                      You are using extremely cheap systems with cheap batteries of unknown age that are likely very prone to incur reduced capacity over shorter times and memory from discharge cycles.

                      See the posts above. This really is one of the greatest ideas I have seen for monitoring, just needs a tweak

                      With these findings I would set a floor voltage around 1-1.1 V for the arduino to go into sleep mode (find your own floor voltage by looking at your sleep discharge rate and length of night time).

                      1 Reply Last reply
                      1
                      • PaweMedP Offline
                        PaweMedP Offline
                        PaweMed
                        wrote on last edited by
                        #57

                        Hello.
                        Do you have any idea how to add to this code auto reset for instance every one hour? i have a problem with my sensor, because sometimes it is not responding, and i dont have any idea how to reset arduino automaticly

                        1 Reply Last reply
                        0
                        • mrwombleM Offline
                          mrwombleM Offline
                          mrwomble
                          wrote on last edited by
                          #58

                          Hi all, I was so impressed by this thread that I decided to build my own. I must have spent maybe £6 or so - I really pushed the boat out. :smiley:

                          It's been running successfully for a few weeks now, so I thought I'd share my code and a few pics. I upgraded the original code to v2.0. I've kept the update frequency high and it's running just fine, but we'll see how it goes in winter with less sun.

                          Pics!
                          0_1477923890152_IMG_20161016_151754 (Small).jpg
                          Here you can see the boost converter and the Arduino pro mini.

                          0_1477923898665_IMG_20161016_154217 (Small).jpg
                          Here you can see the finished product in its natural environment. The RF radio sits in the plastic area, as I figured the metal collar at the top (where the arduino + battery sits) would have blocked/reduced the RF transmission.

                          Code to follow.

                          1 Reply Last reply
                          1
                          • mrwombleM Offline
                            mrwombleM Offline
                            mrwomble
                            wrote on last edited by
                            #59

                            I meant to mention that the wires coming out of the bottom are the wires that go to the soil moisture probes.

                            Here's the code in case anyone else would like it:

                            // Updated to v2.0 of Mysensors
                            
                            // Enable debug prints
                            #define MY_DEBUG
                            #define MY_RADIO_NRF24
                            
                            #include <MySensors.h>
                            #include <SPI.h>
                            
                            #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
                            #define N_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
                            
                            #define CHILD_ID_MOISTURE 0
                            #define CHILD_ID_BATTERY 1
                            #define SLEEP_TIME 10000 // Sleep time between reads (in milliseconds), was 10000
                            #define THRESHOLD 1.1 // Only make a new reading with reverse polarity if the change is larger than 10%.
                            #define STABILIZATION_TIME 1000 // Let the sensor stabilize before reading default BOD settings
                            const int SENSOR_ANALOG_PINS[] = {A4, A5}; // Sensor is connected to these two pins. Avoid A3 if using ATSHA204. A6 and A7 cannot be used because they don't have pullups.
                            
                            // MySensor gw;   //removed for v2.0
                            MyMessage msg(CHILD_ID_MOISTURE, V_HUM);
                            MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE);
                            long oldvoltage = 0;
                            byte direction = 0;
                            int oldMoistureLevel = -1;
                            float batteryPcnt;
                            float batteryVolt;
                            int LED = 5;
                            
                            void setup()
                            {
                              pinMode(LED, OUTPUT);
                              digitalWrite(LED, HIGH);
                              delay(200);
                              digitalWrite(LED, LOW);
                              delay(200);
                              digitalWrite(LED, HIGH);
                              delay(200);
                              digitalWrite(LED, LOW);
                              
                              //  gw.begin(); //Removed for v2.0
                              for (int i = 0; i < N_ELEMENTS(SENSOR_ANALOG_PINS); i++) {
                                pinMode(SENSOR_ANALOG_PINS[i], OUTPUT);
                                digitalWrite(SENSOR_ANALOG_PINS[i], LOW);
                              }
                            }
                            
                            void presentation(){  //created for v2.0
                              sendSketchInfo("Plant moisture w solar", "1.0");
                              present(CHILD_ID_MOISTURE, S_HUM);
                              delay(250);
                              present(CHILD_ID_BATTERY, S_MULTIMETER);
                            }
                            
                            
                            void loop()
                            {
                              int moistureLevel = readMoisture();
                            
                              // Send rolling average of 2 samples to get rid of the "ripple" produced by different resistance in the internal pull-up resistors
                              // See http://forum.mysensors.org/topic/2147/office-plant-monitoring/55 for more information
                              if (oldMoistureLevel == -1) { // First reading, save current value as old
                                oldMoistureLevel = moistureLevel;
                              }
                              if (moistureLevel > (oldMoistureLevel * THRESHOLD) || moistureLevel < (oldMoistureLevel / THRESHOLD)) {
                                // The change was large, so it was probably not caused by the difference in internal pull-ups.
                                // Measure again, this time with reversed polarity.
                                moistureLevel = readMoisture();
                              }
                              send(msg.set((moistureLevel + oldMoistureLevel) / 2.0 / 10.23, 1));
                              oldMoistureLevel = moistureLevel;
                             
                              int sensorValue = analogRead(A0);
                              Serial.print("--Sensor value:");Serial.println(sensorValue);
                              float voltage=sensorValue*(3.3/1023);
                              Serial.print("--Voltage:");Serial.println(voltage);
                              batteryPcnt = (sensorValue - 248) * 0.72;
                              Serial.print("--Battery %:");Serial.println(batteryPcnt);
                              batteryVolt = voltage;
                              sendBatteryLevel(batteryPcnt);
                              resend((voltage_msg.set(batteryVolt, 3)), 10);
                              //send(voltage_msg.set(batteryVolt), 3);
                            
                              //flash led to indicate send
                              digitalWrite(LED, HIGH);
                              delay(200);
                              digitalWrite(LED, LOW);
                              
                              sleep(SLEEP_TIME);
                            }
                            
                            void resend(MyMessage &msg, int repeats)
                            {
                              int repeat = 1;
                              int repeatdelay = 0;
                              boolean sendOK = false;
                            
                              send(msg);
                            /*
                              while ((sendOK == false) and (repeat < repeats)) {
                                if (send(msg)) {
                                  sendOK = true;
                                } else {
                                  sendOK = false;
                                  Serial.print("Error ");
                                  Serial.println(repeat);
                                  repeatdelay += 500;
                                } repeat++; delay(repeatdelay);
                              }*/
                            }
                            
                            
                            int readMoisture() {
                              pinMode(SENSOR_ANALOG_PINS[direction], INPUT_PULLUP); // Power on the sensor
                              analogRead(SENSOR_ANALOG_PINS[direction]);// Read once to let the ADC capacitor start charging
                              sleep(STABILIZATION_TIME);
                              int moistureLevel = (1023 - analogRead(SENSOR_ANALOG_PINS[direction]));
                            
                              // Turn off the sensor to conserve battery and minimize corrosion
                              pinMode(SENSOR_ANALOG_PINS[direction], OUTPUT);
                              digitalWrite(SENSOR_ANALOG_PINS[direction], LOW);
                            
                              direction = (direction + 1) % 2; // Make direction alternate between 0 and 1 to reverse polarity which reduces corrosion
                              return moistureLevel;
                            }
                            
                            

                            My thanks to flopp for the cool idea and to everyone else on the thread for the contributions.

                            1 Reply Last reply
                            3
                            • NeverDieN Offline
                              NeverDieN Offline
                              NeverDie
                              Hero Member
                              wrote on last edited by NeverDie
                              #60

                              Interesting project. To what degree, if any, has corrosion been a problem after you switched to soldered connections? Obviously the operating environment (near the ground outdoors) can be intrinsically humid.

                              Also, can someone please post a larger photo of how the sensor is attached at the base? The area of interest on the photo provided is miniscule, and it's too grainy if I try to enlarge it to a better size:
                              alt text

                              NeverDieN F 2 Replies Last reply
                              0
                              • NeverDieN NeverDie

                                Interesting project. To what degree, if any, has corrosion been a problem after you switched to soldered connections? Obviously the operating environment (near the ground outdoors) can be intrinsically humid.

                                Also, can someone please post a larger photo of how the sensor is attached at the base? The area of interest on the photo provided is miniscule, and it's too grainy if I try to enlarge it to a better size:
                                alt text

                                NeverDieN Offline
                                NeverDieN Offline
                                NeverDie
                                Hero Member
                                wrote on last edited by
                                #61

                                By the way, I notice this guy has a rather interesting soil moisture sensor that appears to go beyond measuring mere electrical conductance: https://www.tindie.com/products/Power_Modules/fdr-100mhz-plant-soil-sensor-mineral-transparency/

                                mrwombleM 1 Reply Last reply
                                0
                                • ? Guest
                                  AWIA Offline
                                  AWIA Offline
                                  AWI
                                  Hero Member
                                  wrote on last edited by
                                  #62

                                  @flopp Can you please include the pictures in your posting as the "tinypic.com" is rather intrusive, thanks...

                                  1 Reply Last reply
                                  0
                                  • NeverDieN NeverDie

                                    Interesting project. To what degree, if any, has corrosion been a problem after you switched to soldered connections? Obviously the operating environment (near the ground outdoors) can be intrinsically humid.

                                    Also, can someone please post a larger photo of how the sensor is attached at the base? The area of interest on the photo provided is miniscule, and it's too grainy if I try to enlarge it to a better size:
                                    alt text

                                    F Offline
                                    F Offline
                                    flopp
                                    wrote on last edited by flopp
                                    #63

                                    @NeverDie said:

                                    Interesting project. To what degree, if any, has corrosion been a problem after you switched to soldered connections? Obviously the operating environment (near the ground outdoors) can be intrinsically humid.

                                    I have not checked how the sensor look like now, but I have only run it for 6 months. I have always used soldered connections.

                                    Also, can someone please post a larger photo of how the sensor is attached at the base?

                                    1_1479545970922_20160606_131714652_iOS.jpg 0_1479545970922_20160606_131710115_iOS.jpg

                                    NeverDieN 1 Reply Last reply
                                    2
                                    • ? Guest
                                      AWIA Offline
                                      AWIA Offline
                                      AWI
                                      Hero Member
                                      wrote on last edited by
                                      #64

                                      @flopp Just copy the area's of intrest with a "snipping tool" (screen print) and copy in the post. Or, use one of the less intrusive services of the big cloud names...

                                      1 Reply Last reply
                                      0
                                      • NeverDieN NeverDie

                                        By the way, I notice this guy has a rather interesting soil moisture sensor that appears to go beyond measuring mere electrical conductance: https://www.tindie.com/products/Power_Modules/fdr-100mhz-plant-soil-sensor-mineral-transparency/

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

                                        @NeverDie
                                        Interesting, but would make the project a little pricey.

                                        1 Reply Last reply
                                        0
                                        • F flopp

                                          @NeverDie said:

                                          Interesting project. To what degree, if any, has corrosion been a problem after you switched to soldered connections? Obviously the operating environment (near the ground outdoors) can be intrinsically humid.

                                          I have not checked how the sensor look like now, but I have only run it for 6 months. I have always used soldered connections.

                                          Also, can someone please post a larger photo of how the sensor is attached at the base?

                                          1_1479545970922_20160606_131714652_iOS.jpg 0_1479545970922_20160606_131710115_iOS.jpg

                                          NeverDieN Offline
                                          NeverDieN Offline
                                          NeverDie
                                          Hero Member
                                          wrote on last edited by NeverDie
                                          #66

                                          @flopp
                                          Perfect! Thanks a bunch. I like it. Very clever.

                                          I think you were wise to cover the insulated wire with the silicon. Despite the appearance of being waterproof, I've noticed that regular wire insulation isn't waterproof/vaporproof, and regular wires used outdoors don't survive well (especially "copper" wires from China, which tend to have a high iron content and thus literally rust their way to failure). I don't know that silicon is sufficient, but if it isn't it might at least slow down the degradation process. It takes some effort to put these things together, so plainly you want them to last as long as possible.

                                          Nice work!

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


                                          21

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


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

                                          • Don't have an account? Register

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