WEEK 4—7
Midterm Project - Interactive Sprinkler for Your Plants!
︎Date - October 3rd, 2022
- First, we tested the motor to check how much power it needed to pump water.
- Connected microcontroller A0 / D14 through 1k resistor.
- The third leg (emitter/source) connects to the ground. They share the ground with the motor.
- The middle one (drain/collector) is connected to the DC Motor (black wire)
- The red wire of the DC motor goes into the Power Supply.

*Basic components for the project (soil sensor, power supply, wires, water pump with DC motor, tube)
︎Process
1. I made three holes in the tube, so water can go out through the holes. I had to make sure that the holes are tiny, so a large amount of water would not come out.


2. After making the holes, we tested the tube to see if the water would come out correctly as we expected. And it did!



3. We started to connect the wires and the power supply.
a. Base connects to microcontroller A0 (analog) / D 14 (digital) through a transistor (1K).
b. The third leg (emitter/source) connects to the ground. They share the ground with the motor.
c. The middle one (drain/collector) is connected to the to DC Motor (black wire).
d. The red wire of the DC motor goes into the Power Supply.

*This is the code for the DC motor and power supply together.
* The video shows that the motor works with the codes.
︎Date - October 6th, 2022
︎Process
We got the soil sensor and tested the moisture level with a wet paper towel, and we found out that actually, the sensor was superior with a capacitive measurement. Capacitive measurements use only one probe. It gives a reading ranging from about 200 (very dry) to 2000 (very wet). It also provides the ambient temperature from the internal temperature sensor on the microcontroller, it's not high precision, so good to + or - 2 degrees Celsius.
*The video of testing the soil sensor with an wet paper towel.

The number is around 300-400 when the sensor is with less capacitance in the air.

The number is around 1000 when the sensor is with more capacitance with the wet paper towel.

Then we added the code with the Arduino Data informations to the DC motor code.

Then we added the code with the Arduino Data informations to the DC motor code.








Notes from the p comp workshop




︎Date - October 11th, 2022
︎Process
During the weekend, someone probably watered the plant. The soil was wet, so we could not test it with her, but we still needed to figure out how much power we would give to the motor. We’ll leave the device on and check the flower every day to see if it gets dry over the next few days and see when the photocell will trigger the motor to water the plant.


We raised the capacity to 1000 for the motor to be triggered, and the motor pushed through half of the container with water until we turned off the power. We may need another condition for the motor to stop when the soil sensor registers values above 700. And then we put our trigger to water the plant at 600?
We suspect a few things that went wrong:
- The first time we ran the Arduino, the motor pumped three cycles and stopped. The next time we ran the Arduino, it worked without stopping.
- The motor may be too high of power. We didn't check what that was, but it was somewhere in the middle of the dial.
- The question is, why did the motor not stop on its own?
- How do we power the Arduino when we leave the plant alone?
We'll need to gauge her water intake as all succulent plants are 'individuals,' according to Tanika (a fellow ITP interested in plants).
We tried to water our plant and it seems like someone watered it this morning. So we decided to raise the value of our capacitor from 800 to 1000 (it already indicated 850 values when we put the soil sensor in), so it could trigger the motor. It did start the motor, but it wouldn't stop, and it went through half of the container with water until we unplugged the motor.
We guessed a few things are happening:
- The motor was at too high power.
- The motor was pumping too much water too fast for the sensor to read it and then trigger the motor off. Or, the 1000 is too high of a value. Bc when we run the program, the serial monitor registers values between 950 and 1000, but it takes a little time until the sensor reads higher values.
︎Date - October 13th, 2022
︎Process
We tried to find a right amount of voltage from the power supply to control the pump.
1: 5.0 V regulator (LM7805C) (1H288H) then with a few Resistors 4.7, but it didnt matter, we needed two of them) - voltage divider, we bring it lower.
2: Meter test the voltage on the power supply. It's accurate 3.1
We measured the regulator, and it brought the voltage one step lower from the power supply.
Now whatever we plug into the board will be 5V. Now we'll use two resistors to bring it lower.
If you put two resistors (same) in the ground (the current starts in ground) the current will be split in two. They each will get 2.5V. So one will go to the motor, and the other will go back to the ground.

We’ll use the potentiometer for our resistor… it gives us the proper flow of water. The question is how to program this.
The POT has 10K, and the knob in the middle would balance the two halves (5k and 5k). as we move the knob ( wipe - 10K and zero, zero, and 10k). Depending on the wipe direction, we’d have even sprinkled a lot or nothing. We used it to find the 9,950 amps ratio and 50 resistance on the other side to have the normal water flow.
So now we go with a fixed resistor value. One is 10K Ohms, and the other 50 Ohms canceling because the flow is too slow.
Replacing the 10K with two 4700 (x2) will give us a difference of 600 ohms. Still slow. If the power supply is above 5 will stay at 5V bc it goes through a regulator.
We are still testing how many resistors and what resistance we need to have the flow we want.
We noticed that the power supply changed Voltage if we turned it up, and the flow altered. It might be about the way the regulator works. So we decided to keep the power supply at a constant 12V. If the Voltage is above 7 or 8, it’s ok with three resistors of 10 Ohms (30 in Total) 1.7 V currently works for our flow.
︎Date - October 17th, 2022
︎Process
We checked how long the difference in Serial monitor and the values take. Record the analog level when it is dry and see how long it takes to raise the numbers. The problem was that the soil from the plant we’ve testing is too wet to test out, so we brought dry plants from the garden in the school. Yoni helped us getting the right amount of the water for this time as well.. :)
When the sensor is entirely out and has no contact with the soil registers 325-350.
Now testing with a dry soil plant. The sensor registers 560 - 590 values.

The values when the soil sensor is out of the soil. (dry)

The values when the soil sensor is inside of of the soil. (dry)
QUESTION
- do we want the plant to dry out and then be watered? Or do we want a constant flow of water to maintain it? For the plant's sake, we need to give it breathing room, so we would like to water the plant when the values fall and reach 650.
The challenge was that the wire connecting the Mosfet to the power on the Arduino breadboard (3.3V) would turn on unless plugged into the ground to turn off. Thus, Yoni connected the (gatePin) power to the digital pin 2 on the Arduino (above the ground pin). That solved the problem, and the motor turned on and off according to the code. The gatePin for the Source (drain) goes into ground, and that ground is shared with the Arduino breadboard (3.3V). The middle pin is where one of the resistors goes.

The flow was still quite fast, or the soil was too dense to retain the water. Within a minute, the water started flowing out of the plant. The readings went down to one-digit numbers, fluctuated between one and two-digit numbers for at least 30 seconds, and then slowly got up to the three-digit numbers. It went up to 1014 reading by the end of a minute time, as could be noticed in the serial monitor. The delay was about 60 seconds.
Per David, VERY IMPORTANT to (DC Motor 6-7) to keep the power supply stable, so if the motor is meant to operate at 3V and we crank up the voltage on the power supply, it will affect the resistors and the other components on the board. For testing, keep the same voltage.

︎Date - October 21st, 2022
︎Process
We tested the code from the last time we figured with Yoni. But, the motor just kept pumping the water..Then we covered the photocell, and it slowed the speed of the motor pumping the water, but did not completly stopped it.
Photocell from 300 to 80 started the motor at this daylight/fluorescent light available on the floor, but it stopped the flow of water faster when covering the photocell.
Andria’s notes on David’s suggestions..
REMEMBER per David:
‘if, else’ or ‘if inside and if’ statement
Rewrite the code for more control:
Soil sensor is more important - there is a hierarchy
General: If statement: IF it’s wet - turn everything off
if it’s not wet - check photo cell: if statement ( 900 (stronglight) and soilsensor dry 350
Inside that If statement: if it’s dry and the light is at 900 (strong) turn on the motor, otherwise don’t turn it on
Third code: if the soil is wet, LED light on ; else, if Dry - turn OFF
NEXT STEP: Add an LED light to our board to signal that the water is fed. The code will be: when the capacitive values reaches 450 (ex.) turn the LED on.
︎Date - October 24th, 2022
︎Process (Final testing)
Initial idea: to connect all to one breadboard only, so we can track it easily.
In the perfect world..
First, the MOSFET will power (turn on/off) our LED, and the second MOSFET will regulate the power supply for 5V DC Motor. Lastly, The ARDUINO 3.3 V will power the soil sensor;
However, transferred circuits only to an extent. That caused our Arduino not to be self-sustainable. It’s still powered by the laptop.
We tried to connect the LED light, so we can let people know that plant is already watered, so they don’t accidentally water the plant again. (we’ve been having this problem since the begnning of the project..haha).
The first time we tried the code, it worked in backward, the LED light was on when the soil is dry and the photosell is exposed to the flashlight. Also, the motor wouldn’t stop pumping water.

FINAL CODE w lots of help from the workshop :)..
#include "Adafruit_seesaw.h"
Adafruit_seesaw ss;
int gatePin = 2;
int photoSensor = A1;
int ledPin = 3;
void setup() {
// put your setup code here, to run once:
pinMode(gatePin, OUTPUT); //declare the gatePin of the DC motor, MOSFET as OUTPUT
pinMode(ledPin, OUTPUT); // declare the ledPin
pinMode(photoSensor, INPUT); //declare the photoSensor pin as INPUT
Serial.begin(115200);
Serial.print target="_blank">Serial.println("seesaw Soil Sensor example!");
if (!ss.begin(0x36)) {
Serial.println("ERROR! seesaw not found");
while (1) delay(1);
} else {
Serial.print("seesaw started! version: ");
Serial.println(ss.getVersion(), HEX);
}
}
void loop() {
Serial.println(analogRead(photoSensor));
uint16_t capread = ss.touchRead(0);
Serial.print("Capacitive: ");
Serial.println(capread);
delay(100);
// put your main code here, to run repeatedly:
// if (analogRead(photoSensor) > 900 && capread < 400) { //Has to be brighter than 900 to trigger the motor and the soil is dry below 400 the motor goes ON
// digitalWrite(gatePin, HIGH);
// } else { //otherwise turn off
// digitalWrite(gatePin, LOW);
// }
bool soilWet = capread > 390; //boolean is true or false, dry or not;
bool lightOverThreshold = analogRead(photoSensor) > 900;
if (soilWet) {
digitalWrite (gatePin, LOW);
digitalWrite(ledPin, HIGH); // when the soil is wet, turn the LED on;
return; // this will ensure that nothing else turns on.
}
// Soil is not wet, continue
digitalWrite(ledPin, LOW); // Turn off LED
if (lightOverThreshold) {
digitalWrite(gatePin, HIGH); // Turn on motor if light is bright enough
// delay(300);
// digitalWrite(gatePin, LOW); // In case it overflows;
// delay(300);
}
}
Final Presentation with Andriana ︎︎︎


