I had been looking for something that would remind me to water
the plants. I didn't want an app, or anything that sensed
the need for the plant to be watered, I just wanted a thing that
would raise an alarm every three days. This doesn't
appear to be a need that anyone has anticipated, at least not that
I could find on the web. Discussing this over lunch at work
it became an excuse to play with a PIC microcontroller from
MicroChip. I ordered the following from RadioSpares:
RE933-02, Surface Mount (SMT) Board TSSOP Epoxy Glass
Double-Sided 23.5 x 13.5 x 1.5 mm FR4,
Aiko Denshi Wire Lead Mount Battery Holder for 2 (AA), Coil
Spring Contact,
Kingbright L-53HD, Round Series Red LED, 660 nm, 5mm (T-1
3/4), Round Lens Through Hole Package,
Tactile Switch, SPST-NO 50 mA 1.3 mm.
Half a day's work with some vero board, single-core wire and 0.1"
pitch connectors gave me this:
Another couple of hours with a very fine soldering iron and
controlled breathing gave me this:
The above shows my second attempt to mount the TSSOP chip on the
carrier board: be very careful never to get a solder hair between
the pins of the chip, you will never be able to get it out and
you're done for. And obviously don't solder the carrier
board to the base board until you're sure all is good with both
parts.
I would give you a schematic but there's really nothing to it: the
power and ground come out to the connector bottom-left, USB comes
out to the connector middle left, the debug connector comes out to
the connector on the right and the IOs lines are brought to the
area of board on the left hand side so that I can mount the few
other components there.
Now, some software. Go to the Microchip website and download
the MPLAB X IDE, the XC8 compiler and the MLA libraries.
Strictly speaking you don't need this latter but, since there is
USB on the chip, I decided that it was worth getting the USB stack
running, if only for debug or for future projects. This
turned out to be the biggest pain. The MLA libraries are
huge and do everything, making it very difficult to understand how
you pull out just the bit you want and how that bit works.
In the end I followed some advice on the web and basically copied
in what looked like relevant USB files, pretty much one by one,
until I had a set of USB client files that would
compile. Then I could see what's what. The code I
ended up with can be found on Github here: http://github.com/RobMeades/PlantWateringTimer.
After discussions over lunch at work the following week the spec
changed a little. John suggested that, rather than flashing
an LED, the device should raise a flag when the time is up.
This makes sense since no power is consumed by the alarm being on,
only by the act of it coming on. He was thinking of a relay
modified to release a catch holding back something spring loaded
but I'd chosen a low voltage PIC (for power saving) and none of
the relays I could find would work down to 3 Volts. In
retrospect, I could have employed a supercap but what I decided to
do was use one of those tiny motors from a toy helicopter, which
will run down to almost 1 Volt. I happened to have just such
a motor in a broken remote controlled wasp-thingy, with some
useful gearing attached:
Driving the motor required a transistor plus a couple of resistors
for protection. Here is the whole circuit mounted on top of
the battery box with some velcro.
Current-wise, when running from its internal 31 kHz clock the
board takes 20 to 30 uA. That was measured with the spare IO
lines run as inputs and not grounded, since I wanted to keep my
options open. In the code archived above the IO lines are
set as outputs instead, which might or might not be better.
Either way I don't think that current consumption is likely to be
an issue with two 1800 mAh AA cells in the box. So, finally
here is the whole thing, mounted on a piece of wood that I can
place on a shelf:
And to prove that it works, here's a video of the timer running
with a 4 second timeout:
Operation: the period timer in the PIC goes off and switches on an
IO line which allows the motor to draw current via the transistor.
The flag arm is turned as a result and the flag raised until it
operates the microswitch (I just picked one from Radio Spares that
had the very lowest on-pressure). The PIC detects this and
switches off the IO line then puts itself back to sleep.
Resetting the arm causes the microswitch to release, waking up the
PIC, which starts the period timer once more and then puts itself
back to sleep. And repeat.
Update 1 March 2020:
After almost exactly 4 years (35,000 hours) of operation
the two series Duracell Plus Power AA cells powering the plant
watering timer became insufficient to power it. They had
both dropped to a terminal voltage of 1.34 Volts.
Apparently rated at 2 Ah (i.e. taking the 0.2 C curve in
the datasheet)
and assuming they are probably only around 70% discharged, that
suggests that the average current drawn by the plant watering
timer was
2000 * 0.70 / 35,000 = 40 uA.
Could be lower but quite good enough. Back to Meades Family Homepage