back home

interface and application programming

write an application that interfaces with an input &/or output device that you made

In my final project I plan to use a moisture sensor in order to water the plant when it is dry. This is why this week I am going to use the values I get from the percentage of water in the soil for this assignment.

The sensor I am using is called FC-28 Soil Moisture Sensor, see image below:

I connected the VCC, GRD and Analog Pin to my Bocoduino Board (the one I made for my final project). I am using the analog pin because I want to know the values in percentages. This site was very helpful to gide me through the process of understanding and setting everythin up. I used an Arduino test code (which you can download below) to test the sensor and I was happy to see that it worked. When the sensor was outside the water the value was 0% but if I inserted inside a glass of water it increased until reaching 100% if it was totally underwater. All this values were displayed in my serial monitor in Arduino.
I must remember to set the right parameters for the moisture medium, as depending on the medium it is set I will have to declare what is 0 and what is 100 in the code. Right now it goes from 0 to 1024:
output_value = map(output_value,1024,0,0,100);

Once I had Arduino reading the senor values correctly, I moved to Processing and drew a simple sketch. It shows a red circle which represents 100% moisture, in the middle, a pink circle that will grow or decrease depending on the level of moisture.

Now it was time to connect Arduino and Processing together, in order to do that I found this very helpful tutorial. I carefully read and understood the steps and I was able to connect both softwares. Then, in the Processing code I changed the dimensions of the pink circle to 0.1 and then multiply it by the value recived from Ardunino. So now, the more moist the sensor detects, the bigger the pink ball is (demo below).

Files:
Arduino code(.ino)

Processing code(.pde)