Introduction: Plant Moisture Alarm
There is an upcomming event at Fablab Umeå with the theme beeing plant related, so we decided to build a simple moisture alarm for plants to keep them as happy plants.
The focus of this instructable is not to build the perfect moisture alarm, more to show what is possible to achieve with some electronics and some creativity.
One other goal was to build it with cheap electronics and keeping the number of components low.
These goals led us in the way to not use a Arduino UNO (size and cost), but instead use the ATTiny45. By doing this we could hold the size and cost low.
The total cost for all of the components are about 3 US dollars.
Step 1: Materials
--- The sensor, control, and alarm ----
1 - ATTiny45 - small microcontroller that could be programmed with Arduino IDE. Other versions of ATTiny would also be fine.
3 - LEDs (red, green, yellow)
3 - 100 ohm resistors (or whatever your LEDs would like to have)
1 - 57 kOhm resistor - one half of the voltage divider
2 - 3" nails - for the soil sensor, also the other half of the voltage divider
1 - 47 uF electrolytic capacitor - noise filtering
--- Makeing it run on 9V battery ---
1 - LM7805 - voltage regulator, converts 9V to 5V.
1 - 0.33 uF ceramic capacitor
1 - 0.1 uF ceramic capacitor
1 - 9V battery
1 - 9v battery clip
--- Test setup ---
1 - breadboard
--- Final product ---
all above electronics
- wood glue
- small pieace of 3 mm MDF board cut in the laser cutter
- rounnd stick of wood, mine was about 3.8 mm in diameter
--- Tools ---
- not needed, but I started to prototype from a Arduino UNO. You could however start directly from ATTiny45.
- Tiny Programmer from Sparkfun (or some equivalent equipment) - to be able to program the ATTiny45.
- Arduino IDE installed on computer
- laser cutter
- soldering station
- basic tools
Step 2: Prototyping the Sensor
First I browsed the internet to find out how other people had tackled the moisture sensoring challange. There are a lot of them out there, but I choosed to go for a really simple one.
This setup have the Vcc (+5 V) going through a resistor (57 kOhm) and then through the actual soil sensor (the nails) before reaching ground. To measure the mositure in the soil you will connect an analouge input in between the resistor and the first nail. Depending on the amount of water in the soil this voltage divider will give different readings.
The drawback of this solution is that the current will constantly flow through the moisture sensor, which will drain the battery and cause electrolysis to take place in the nails. However, for this prototype, we didn't bother about that.
As an alarm, we choosed to have a "traffic light", giving the green LED the status 'happy plant', the yellow LED 'somewhat thisty plant', and the red LED the status 'I need water - I'm about to die'.
Second I prototyped the sensor using an Arduino UNO, but this step you could skip, and I'm not describing this part here. When I moved to the ATTiny45 microcontroller, I used the Tiny Programmer from Sparkfun. This board need to be set up correctly on your computer (needs a driver) so that you could program your ATTiny IC. You could use other solutions to program it, but theese are not described in this instructable. You also need to add ATTiny45 to your Arduino IDe and do the correct setup. Both the configuration of Arduino IDE and the how to install the Tiny Programmer driver in your computer can be found here: https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/?_ga=1.60274856.465809056.1449761682
The Tiny Programmer is easy to use, and first I prototyped directly from the programmer board, since it has possibilities to use jumpeers to the breadboard. In the attached picture I have however set up the circuit completly on the breadboard for easier understanding (I also uploaded a picture of the circuit produced in Fritzing for that reason).
A simple program to measure the voltage at the sensor with the analoge input and compare it to different levels, testing it to have resonable settings, and then were done.
But remember that different soil give different readings, and that different plants thrive in different moisture levels. This are good settings for our soil and plant.
To copy our solution:
- open Arduino IDE, do the settings for ATTiny45
- open the Arduino code (below), compile and upload
- do the wireing of components as shown in picture
- Test it :)
Step 3: Create the Casing
So now we have a operable prototype but only on breadboard. One direction could be to design and create a circuit board, for example using Fritzing, etching and so on.
We were also lacking some casing for the alarm.
To solve both these obsticles at the same time, we decided to go for point-to-point wiring of the components, and attach them to the casing. As I started to draw the casing in Inkscape I choose to desing the casing as a plant with a traffic light as the flower, and all the components as bugs, flies, beetles and so on.
The legs of the insects were etched to the MDF board, and the casing were cut out, and the casing glued together.
To recreate this step:
- send the PDF file to your laser cutter.
- glue the casing to one piece (except the holder of the nails)
Step 4: Solder the Electronics to the Casing
We started by connecting the wires to the nails and then glued the holders of the nailes to the casing. After that comes the tricky part of connecting all the components correctly (and preferably with the easiest routing). We choosed to have a IC socket for the ATTiny45 as it made somewhat easier to solder.
This step has no more pitfalls than to solder it incorrect.
Simply recreate by doing this.
Step 5: Test Your Moisture Alarm
Test your Moisture Alarm.
I set our alarm in a pot with a plant, and it seems to work pretty okay. But, as discussed in the beginning, it drains the battery pretty quick.
A redesign would be great, either to have the actual sensor in sleep mode, and only starting it when needed (once a hour or so). One could also have every second time the sensor is turned on to be in the reversed direction to stop the electrolysis to take place.
We have a be nice policy.
Please be positive and constructive.