-2

I am powering solenoid with 24 volt as required however I am using TIP122

transistor that has base connected to Arduino Digital Pin 6 via a 1K Resistor. And the collector is connected to negative side of 1N4001 diode, this also serves as the Negative out for solenoid. and emitter is connected to the 24 volt power input. The positive input from power source is connected to positive terminal of diode is directly connected to solenoid.

enter image description here

As per the logic I am trying to turn on Solenoid based on Signal from Arduino PIN 6, but for some reason Solenoid doesnt power up.

In my code below I want to turn on solenoid if soil moisture goes above 60. the signal is coming from Pin 6 but solenoid doesnt power up.

#include <SPI.h>

int solenoidPin = 6;    //This is the output pin on the Arduino we are using

int GLED = 5; // Wet Soil Indicator at Digital PIN D5
int RLED = 9; // Dry Soil Indicator at Digital PIN D9
int SENSE = 1; // Soil Sensor input at Analog PIN A1
int val = 0;

int greenLedPin = 2; // LED on pin 2
int yellowLedPin = 3;
int redLedPin = 4;

int lightSensorPin = A0;
int analogValue = 0;



void setup() {
  pinMode(solenoidPin, OUTPUT);           //Sets the pin as an output

  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  pinMode(greenLedPin, OUTPUT); // LED on pin 2
  pinMode(yellowLedPin, OUTPUT);
  pinMode(redLedPin, OUTPUT);

  pinMode(GLED, OUTPUT);
  pinMode(RLED, OUTPUT);

}

void loop() {
  val = analogRead(SENSE);
  val = val / 10;
  analogValue = analogRead(lightSensorPin);
  Serial.print("LDR value: ");
  Serial.print(analogValue);
  digitalWrite (redLedPin, analogValue < 55) ;
  digitalWrite (yellowLedPin, analogValue >= 55 && analogValue <= 100) ;
  digitalWrite (greenLedPin, analogValue > 100) ;

  Serial.print(" Soil Moisture: ");
  Serial.println(val);
  digitalWrite(GLED, (val < 50));
  digitalWrite(RLED, (val > 50));
  // Turn on Solenoid Valve if soil moisture value greater than 60
  digitalWrite(solenoidPin, (val > 60));

}

I am doubting on the diode to use , because I am powering solenoid of 24 volt and not sure if the diode is correct , as per my knowledge, diode can get direct if higher voltage is passed.

Any help will be greatly appreciated.

8
  • Maybe connect it to pin 6 instead of to pin 4?
    – Majenko
    Nov 26, 2016 at 11:44
  • Also 24V on Vin is pretty big voltage. Power regulator might be (and it will be) overheating.
    – KIIV
    Nov 26, 2016 at 12:22
  • Sorry ignore power input shown in image above as I mention sources of power are different for solenoid and Arduino Vin is not connected to anything Nov 26, 2016 at 12:24
  • 1
    Determine whether it's a problem with your code or a problem with your circuit by connecting the yellow wire to the 5v output of the Arduino - see whether the solenoid actuates.
    – Mark Smith
    Nov 26, 2016 at 13:02
  • 1
    My suggestion is still the same - except for the wire colour as you changed it: break the problem into smaller parts. Determine whether it's a problem with your code or a problem with one of your circuits by connecting the light blue wire to the 5v output of the Arduino - see whether the solenoid actuates.
    – Mark Smith
    Nov 26, 2016 at 19:05

1 Answer 1

2

When looking your schematic and assuming that J1 connector is not powered by your MacBook as your Arduino board, the main problem is located to the GND signal.

In order to have a commutation current to the Base of the TIP122 through the 1K resistor, you need to link the GND signal its Emitter with the GND signal of your Arduino board.

See a proposed schematic from "High-Power Control: Arduino + TIP120 Transistor"

enter image description here

2
  • would it be ok, if I take power from 5volt pin of UNO and use stepup xl6009 to convert to 24 volts and power solenoid ? Nov 27, 2016 at 7:38
  • O boy I used xl6009 to convert 5 volt to 24 volt and supply to solenoid with common ground as you mentioned and its working as expected Nov 27, 2016 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.