Thursday, April 28, 2016

Solar Swiss Army Knife


Over the past month or so I built an  ESP-8266 based "Solar Swiss Army Knife".

It's primary purpose is to measure the soil moisture, and turn on a valve to water my garden when the soil is dry.

Since it's solar powered, the only connection needed is to the garden hose.


Soil moisture is detected by measuring the AC resistance across a probe stuck in the soil. An AC square wave is made with a 555 timer. Using AC eliminates the galvanic reaction a DC probe would have.

Watering is controlled by a pulse valve driven by an  H-bridge. A pulse valve uses no current when in the open or the closed position so it's perfect for a solar powered project.

A parameter file is read from a micro SD card and sets the watering parameters. Watering parameters include the soil moisture to trigger watering, minimum time watering, and watering hours. The file also provides the network credentials needed to connect to WiFi and the Sparkfun IOT site.

When the  device connects, it gets the time from the NTP server and sets the RTC. It then gets its readings and controls the valve if necessary. Finally, it sends watering and battery status to an IOT site where I can monitor its activity. You can see the data it sends here.

A MOSFET output is provided if I want to control something that needs high current.

A 2000 mAh LiPo is used. To save power, it sleeps for 4 minutes and wakes only to check if the soil needs water and send it's data.

In order to supply all the necessary I/Os, the board uses an I2C GPIO (PCF8574) for 8 additional I/O and I2C ADC/DAC (PCF8591) for 4 analog in and 1 analog out.

To make the build easier I used SMD components and off the shelf modules. The modules used are:
  • Adafruit solar charger - It's worth having a good solar charger. The solar cell is also from AdaFruit.
  • Pololu H-Bridge - Used to reverse polarity to turn pulse valve on and off.
  • LiPo Fuel Gauge - Measures battery voltage and state of charge (SOC). Knock-offs are also available on eBay.
  • Current Sensor - (eBay) Measures the current to and from the battery
  • SD card module - (eBay) 
  • RTC module - (eBay)  
  • Pulse Valve - (eBay) Garden hose in, drip watering system out.

Schematic of the board ...



Wiring diagram . . .



PCB board layout ...



I have some boards available for this project.If you're interested contact me.