Plant automatic watering tutorial: Simulation pump issue

Ask questions about projects relating to: aerodynamics or hydrodynamics, astronomy, chemistry, electricity, electronics, physics, or engineering.

Moderators: AmyCowen, kgudger, bfinio, MadelineB, Moderators

Post Reply
CyberObsequiousメタル猫又V4deltaMKI
Posts: 2
Joined: Mon Dec 11, 2023 8:21 am
Occupation: Other Adult

Plant automatic watering tutorial: Simulation pump issue

Post by CyberObsequiousメタル猫又V4deltaMKI »

Hello folks. I love the youtube tutorials you guys make but I noticed something on the following video (Automatic plant watering system). The LEDs function but the threshold does not activate the motor.

https://youtu.be/ojhrVsBs0nM

I noticed in the video they never press the run-simulation button so I can't verify if theirs worked or not. Here's my sim as well as code:

https://www.tinkercad.com/things/5Hp8Hi ... t=circuits

```// moisture and soil pump set
// declare variables for pins
const int sensorPin = A0;
const int sensorPower = 8;
const int LED1 = 2;
const int LED2 = 3;
const int pumpPin = 11;

// variable for sensor reading
int sensor;

//delay time between sensor readings (milliseconds)
const int delayTime = 1;

//wet and dry thresholds - these require calibration
int thresh = 600;

void setup () {
// set pins as outputs
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(sensorPower,OUTPUT);
pinMode(pumpPin,OUTPUT);

// initialize serial communication
Serial.begin(9600);
}

void loop() {
//power on sensor and wait briefly
digitalWrite(sensorPower, HIGH);
delay(10);
//take reading from sensor
sensor = analogRead(sensorPin);
//turn sensor off to help prevent corrosion
digitalWrite(sensorPower,LOW);

//print sensor reading
Serial.println(sensor);

if(sensor>thresh){
digitalWrite(LED1,LOW);
digitalWrite(LED2,HIGH);
digitalWrite(pumpPin,LOW);
}
else{
digitalWrite(LED1,HIGH);
digitalWrite(LED2,LOW);
digitalWrite(pumpPin,HIGH);
}
delay(delayTime);
}
```
Once again, the LEDs work as expected but the motor does not.

The version I'm trying to build in real life is using parts I have on hand so they vary slightly:
- NPN pn2222A instead of NMOS
-Arduino NANO 3.0 instead of UNO
-capacitive soil sensor instead of resistance

I tested the parts in a different setup to make sure the hardware works. Here's the diagram:
https://www.tinkercad.com/things/iJYYGD ... t=circuits

This appears to work, and so does swapping the POT for a moisture sensor. The only missing part of the puzzle is how to get the threshold to activate the sensor. Some help would be greatly appreciated. Thanks :mrgreen:
Attachments
scibuddiesSS.png
scibuddiesSS.png (144.67 KiB) Viewed 5518 times
bfinio
Expert
Posts: 761
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff
Project Question: Expert
Project Due Date: n/a
Project Status: Not applicable

Re: Plant automatic watering tutorial: Simulation pump issue

Post by bfinio »

Hi,

I flipped our Tinkercad simulation to public and you can access it here:

https://www.tinkercad.com/things/9BfpL7 ... ump-2-leds

I don't have any trouble getting the motor to spin in addition to the LEDs changing status when I run the simulation. You can see in the code that there are lines to control the motor, digitalWrite(pumppin,LOW); and digitalWrite(pumppin,HIGH); inside the if/else statement along with the lines to control the LEDs. If I click the soil moisture sensor while the simulation is running and drag the slider, the motor turns on/off as expected when the sensor reading crosses the threshold.

It can be kind of hard to see when the motor is spinning in Tinkercad - the gear animation isn't very prominent and the font size for the RPM text is pretty small.

The Tinkercad links you posted aren't working for me for some reason and are giving a "sorry, that page is missing" error. If you can post screenshots I can take a look at your circuit, if the transistor is wired wrong there's a chance the motor won't turn on even if the code is right.

Thanks,

Ben
CyberObsequiousメタル猫又V4deltaMKI
Posts: 2
Joined: Mon Dec 11, 2023 8:21 am
Occupation: Other Adult

Re: Plant automatic watering tutorial: Simulation pump issue

Post by CyberObsequiousメタル猫又V4deltaMKI »

Thank you!
Post Reply

Return to “Grades 6-8: Physical Science”