-1

I am trying to make a simple irrigation system with my Arduino. I've managed to successfully get moisture data from my moisture sensor but when I try to add my 6volt pump to it it doesn't. I think I made a mistake wiring it but I am not sure. When I connect the pump to a 5v power source it works perfectly. I am trying this circuit out that I found. arduino circuit

I am using a BC550C transistor instead of 2N5551 NPN because I didn't have it. I've wired my transistor like this. red wire is connected to 5v, green wire goes to pin 2 and purple wire goes to my pumps vcc. transitor circuit

The code I am using:

#define WATERPIN 2
#define READSOILPIN A0

// higher number is more dry
#define MAXDRYNESS 700

#define WATERDELAY 750
#define WATERPOSTDELAY 5000

void setup()
{
 Serial.begin(9600);
 pinMode(READSOILPIN, INPUT);
 pinMode(WATERPIN, OUTPUT);
}

void loop()
{
 int SensorValue = analogRead(READSOILPIN); //take a sample
 Serial.println(SensorValue); Serial.print(" - ");

 if(SensorValue >= MAXDRYNESS) 
 {
  // if the soil is too dry start watering for 3/4 a second then
  // wait for 5 seconds before monitoring again
  Serial.println("Soil dry start watering");
  digitalWrite(WATERPIN, HIGH);
  delay(WATERDELAY);
  digitalWrite(WATERPIN, LOW);
  delay(WATERPOSTDELAY);
 }

 delay(50);
}


Did I make a mistake wiring or is it something in my code?

  • 1
    That doesn't seem like an appropriate circuit at all. Not only is it unclear what connections are made, the parts just don't seem right - 20 ohms in series with the motor would be a mistake, and 20 ohms is too small to be the required base resistor... – Chris Stratton 2 days ago
  • I also tried to put the pumps VCC directly in pin 2 and then set it to high when the soil is to dry but it doesn't work. I just don't know why? I thought that would work because when I plug the VCC directly in the 5v pin the motor starts working. so why not when I try setting the 2 pin high. – imkeVr 2 days ago
  • 1
    You cannot power a motor with an MCU I/O pin. That's why you need a proper circuit with a transistor or FET. But it has to be a proper circuit. – Chris Stratton 2 days ago
  • Do you maybe know how I could make it a proper circuit? I have done some more research and what I now tried was to connect my pump Vcc to Arduino 5v then the pump gnd I connected to transistor collector. I connected the emitter to Arduino gnd and the base I connected to pin2 with a 220ohm resistor in-between. This didn't work so I ran out of ways to build a proper circuit with my current knowledge. – imkeVr 2 days ago
  • @ChrisStratton I found a way that works for me I used a MOSFET ass you suggested. and I plugged a 6-volt source in my Arduino and used the Vin pin to use it. It all works now thank you for leading me in the right direction – imkeVr 2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.