I`m new to electrical engineering, so it's probably a newbie problem.
I'm using a wall power supply(5V-2A) to power the DC Motor(www.dx.com/p/hsyy01-water-pump-motor-w-hose-white-silver-236808#.VqvzTfkrKHsDC Motor) and the Attiny85.
A C1 470uF to make the power more stable. I don't know if it is necessary, but it helped.
A D1 green led to show if it's on.
A reset button connected to ground to reset(Duh).
One relay(833H-1C-C) connected to the digital pin 0 of the attiny to turn the motor on and off.
Two rotational potentiometer connected to two analog pins(2,3) to decide how much time the mini water pump will be on(0-1023 to 1s-30s) and the other to compare to the humidity sensor to decide how much dry the soil will be when the motor will need to be to turn on the motor.
And one humidity sensor. www.dx.com/p/soil-humidity-moisture-detection-sensor-module-blue-black-white-200142#.VqwBW_krKHs sensor.
#include "kPot.h" // my library, just analogReads
#define HUMIDITY_PIN 1 //humidity sensor
#define LEVEL_PIN 3 //rotational potentiometer
#define TIMER_PIN 2 //rotational potentiometer
#define MOTOR_PIN 0 //connected to the relay switch
kPot humiditySensor = kPot(HUMIDITY_PIN, 10); //(pin, average of 10 reads)
kPot levelPot = kPot(LEVEL_PIN, 10);
kPot timerPot = kPot(TIMER_PIN, 10);
int humidity = 0;
int level = 0;
int timer = 0;
void setup() {
pinMode(MOTOR_PIN, HIGH);
humidity = humiditySensor.Read();
level = levelPot.Read();
timer = timerPot.Read();
}
void loop() {
humidity = humiditySensor.Read();
level = levelPot.Read();
timer = timerPot.Read();
timer = map(timer, 0, 1023, 1000, 30000); //1s to 30s
if(humidity < level){
digitalWrite(MOTOR_PIN, HIGH);
delay(timer);
digitalWrite(MOTOR_PIN, LOW);
}
delay(300000); // 5min Update
}
The problem: The mini water pump turnturns on and don'twon't stop, I.
I removed the reset button to make sure that wasn't resetingresetting, didn't resolvedhelp. Maybe
Maybe the motor is getting all thetaking too much current and reseting the attiny. Probably I?
I probably have to put a diode somewhere, but as I said, I'm a newbie, so...
thanks.