Plant watering system and power usage

I am building a plant watering system with soil moisture sensor (like in this post).

I am using this code for low power and using a solar power bank (they say it is 5000 mAh but I dont think it is more than 4000 mAh). The system runs for 4 days before the battery dies (the solar panel is 1W as per the seller). My next step is to switch off the sensor before I sleep the chip (not sure how much current the sensor draws and unable to get the data sheet). I am also thinking that I don't need to read the sensor every 12 seconds as it won't dry that fast but again if I want to sleep for a long time I have to loop the sleep instruction but not sure how would that affect power usage and if when I wake up the chip and check moisture, I would probably need to run the watering pump for longer than 4s. Any ideas ?

#include "LowPower.h"

const int VAL_PROBE = 0; //Analog pin 0
const int MOISTURE_LEVEL = 250; // the value after the LED goes on

void setup() {
  // put your setup code here, to run once:
  pinMode(7, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  int moisture = analogRead(VAL_PROBE);
  if(moisture > MOISTURE_LEVEL)
  {
    digitalWrite(7,HIGH);
    LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF); 
    digitalWrite(7,LOW);
  }
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

Try this http://www.gammon.com.au/power

I have a soil sensor on batteries that is only used every few minutes. It is simple metal strips in the soil, and I use alternating voltage and measure the resistance both ways to prevent electrolysis. I can't find which sensor you use and what the schematic is.

Koepel: I have a soil sensor on batteries that is only used every few minutes. It is simple metal strips in the soil, and I use alternating voltage and measure the resistance both ways to prevent electrolysis. I can't find which sensor you use and what the schematic is.

This is the sensor I am using. I am using the schematic in this instructable. The whole idea is to use solar power bank is not to use any wires

codlink:
Try this Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors

I read this before but I don’t want to build my own MCU board

I use two digital pins from the Arduino with resistors to the pins or metal strips in the soil. They are 10k at the moment, but 4k7 might be better. I make one digital pin high and the other low, and a analog pin is used to measure the voltage. After that I alternate the high and low and measure again. I do that a couple of times. That means I use 3 pins of the Arduino.
With those numbers I calculate the resistance of the soil.
If that is finished, I set the digital pins as input, so no current is used, and I put the ATmega328P into sleep mode with the narcoleptic library.

Do you have a schematic for that sensor. Is the LM393 only used for the digital output ?

When I started, I translated the resistance of the soil into a percentage (which was a log() or log10() of the resistance). But I don’t do that anymore, since the range is too big. The resistance of the soil for the flowerpots and planters varies between 100 ohm and 1M.

hm, it sounds as if your biggest power drain wasn't the system itself, but the electronics within the powerbank. Have you tried switching from a solar powerbank to just a battery, and running a 3.3V arduino? That might save a considerable amount of power.

No, the 30mA or so drain of the Arduino explains it.

For low power you need a board designed for low power - most Arduino board have a USB interface
that cannot be powered down, so are simply not suitable. Pro Mini’s have no USB interface, and use
a lot less power when in sleep (in practice only the quescent power draw of the regulator chip,
not sure what that is though). You do need a USB->serial lead to program Pro Mini’s though.

I am interested in the Powerbank also, what voltage is it? 1 watt from the panel is tiny and if you are correct and are using 1 amp per day then you need to be putting back at least 1.1amp per day to recharge the battery. Assuming a 5vdc battery this equates to 5.5 watts, which in turn requires at least 5.5 hours of usable sunlight, this does not include current to run the load at the same time.

If you wish to avoid electrolysis by using AC for the probes, then the obvious thing to do is to put a 1 µF (or higher) ceramic capacitor in series with each probe lead.

Kiwi_Bloke: I am interested in the Powerbank also, what voltage is it? 1 watt from the panel is tiny and if you are correct and are using 1 amp per day then you need to be putting back at least 1.1amp per day to recharge the battery. Assuming a 5vdc battery this equates to 5.5 watts, which in turn requires at least 5.5 hours of usable sunlight, this does not include current to run the load at the same time.

This is a standard mobile phone power bank which should be 5V and powering the Arduino from its USB port. This is the solar charger I am using approximately 750 mAh per day (turns out the power bank is not really 5Ah as it uses LiPo battery at 3.7v and converts to 5v). I have no shortage of usable sunlight as am in Dubai with lots of sun. With all this in mind I might actually be using more than 750 mAh as the panel is supplying power too. I now did a modification so that I turn on and off the sensor as needed and this is the new code, am hoping for additional time and I also have 2x6Vx1W solar panels that am thinking of hooking to the USB charging port of the power bank but not sure if I can connect it directly with a diode or do I need to lower its voltage ?

#include "LowPower.h"

const int VAL_PROBE = 0; //Analog pin 0
const int MOISTURE_LEVEL = 250; // the value after the LED goes on

void setup() {
  // put your setup code here, to run once:
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
}

void loop() {
  // Power on the sensor
  digitalWrite(8,HIGH);
  //Wait for the sensor to be ready
  LowPower.powerDown(SLEEP_500MS, ADC_OFF, BOD_OFF);
  //Plants need water :)
 while(analogRead(VAL_PROBE) > MOISTURE_LEVEL)
  {
    digitalWrite(7,HIGH);
  }
  //Turn off the pump then the sensor
  digitalWrite(7,LOW);
  digitalWrite(8,LOW);
  //Sleep and repeat
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}