Relay not working for windturbine

Hi guys,
I try to open a relay with my arduino, and I use a digital pin for this.
I have added the circuit in a screenshot


Normally it’s a normally open relay and I tried to close it with my arduino and normally my LED should brighten, but nothing happens (even when I change the voltage from 5V to 0V on my pin 4 from my arduino nothing happens). So now I’m wondering if the relay I have can actually work (because I have a hard time understanding the technical file, because it looks like the relay is AC and my circuit works on DC).
Here’s the link to the technical file https://be.farnell.com/omron/g5ca-1ae-5dc/relay-spst-125vac-30vdc-15a/dp/1257565
I hope you guys can help me.
Snor

Hi,
What are R_B1 and the 1N5231B zener for?
Can you show more of your schematic,
Can you post your code please.
Or a simple test code for pin 4 that produces the same result.

Have you actually built this project?

Thanks… Tom… :grinning: :+1: :coffee: :australia:

The relay looks ok.
5V DC coil.
Where are you drawing the coil voltage from ? Preferably (not) directly from the Arduino.

As above, the extra components are a bit unnecessary. Max base resistance would be in the area of 1k

Here’s the relay data sheet.

Hi, @snormanlol1

The AC part of the spec is for the output contacts, usually they have a DC and an AC spec.
The important bit for your controller is the fact that the coil is 5V, 125R means it will draw.
I = V / R
I= 5 / 125 = 0.04A or 40mA, which is fine for your circuit.

Tom… :grinning: :+1: :coffee: :australia:

You can test the relay by shorting the collector and emitter of the transistor. If it works check your transistor.

To check your transistor do the following. When the Arduino gives 0V on the pin 4, there should be 0V on the base of transistor and 5V on collector. When the Arduino gives 5V, Vbe = about 0.8V, Vce = about 0.25V.

This is not by some chance, something running on a simulator is it? :roll_eyes:

I basically asked the same question, but no reply from the OP.

Tom… :grinning: :+1: :coffee: :australia:

Indeed you did, now I look at it! :+1:

Great minds think alike… :+1:
But fools never differ… :laughing:

Sorry for the late response,
I had a lot of work to do yesterday ;p
I have made the circuit, and that’s why I saw that it doesn’t work.

const int RelaisPin = 4;
const int SpanningTreinLezer= A3; //reads voltage train
const int controle =A0;

void setup() {
  // put your setup code here, to run once:
  pinMode(RelaisPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  // Ik wil een Normally closed -> dus als
  float WerkelijkeTreinspanning = analogRead(SpanningTreinLezer)*5.0/1023.0; //This is the voltage over the train (the voltage over R_Trein in the schematic 
  if (WerkelijkeTreinspanning<=4){
    digitalWrite(RelaisPin, LOW);
  }
  else {
    digitalWrite(RelaisPin,HIGH);
  }
}

It might be possible that LOW and HIGH are wrong, but i tried by changing low-> high and high → low and still nothing.
And I don’t hear my relay make the clicking sound that it should normally

No, it’s real the relay it’s purpose is to open when my generator of my windturbine produces a low voltage so that it can get to speed without letting my train run. (for educational purposes).
But I was testing the relay for lightning a LED, but sadly nothing happened.
@lastchancename Yes the voltage is straight from the Arduino, I see so I have to lower the base resistance? I tought it needed to be atleast that because my arduino has to generate more current than it can?

Did you check the relay according to post # 5?

I did something like that yesterday, I found a Vbe of 0.69 V or something like that, but I will look into it later today.
So there might be a problem with the transistor if it doesn’t work?

Unplug left pin of R_B1 from your Arduino and short to Ground. Close and open the collector of transistor to Ground. Your relay must work (click and close its contacts). If not - your relay is dead or its coil not for 5V. If the relay works do as in post #6.
Close left pin of R_B1 to 5V rail - relay must be on, close to Ground - must be off.
If not working - your transistor is dead.

Hi,
Do you have a DMM?
If so what do you measure on the output pin of the controller?
Can you tell us what model Arduino you are using?

Can you try this code please, it should make your relay turn on and off every 2 seconds, that should be long enough for you to measure the voltage at pin4 and see the voltage go from 0V to 5V.

/*
  Blink without Delay

  Turns on and off a light emitting diode (LED) connected to a digital pin,
  without using the delay() function. This means that other code can run at the
  same time without being interrupted by the LED code.

  The circuit:
  - Use the onboard LED.
  - Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
    and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
    is set to the correct LED pin independent of which board is used.
    If you want to know what pin the on-board LED is connected to on your
    Arduino model, check the Technical Specs of your board at:
    https://www.arduino.cc/en/Main/Products

  created 2005
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
  modified 11 Nov 2013
  by Scott Fitzgerald
  modified 9 Jan 2017
  by Arturo Guadalupi

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/

// constants won't change. Used here to set a pin number:
// const int ledPin =  LED_BUILTIN;// the number of the LED pin

// Variables will change:
int relayState = LOW;             // relayState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 2000;           // interval at which to blink (milliseconds)
const int RelaisPin = 4;
void setup() {
  // set the digital pin as output:
  pinMode(RelaisPin, OUTPUT);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (relayState == LOW) {
      relayState = HIGH;
    } else {
      relayState = LOW;
    }

    // set the LED with the relayState of the variable:
    digitalWrite(RelaisPin, relayState);
  }
}

As you can see I have just modified the “Blink without Delay” code to your application.

Can you post a picture of your project reguarding the controller, transistor and relay please?

Tom… :grinning: :+1: :coffee: :australia:

I don’t have a DMM I guess,
This is the circuit (the relay has 2 wires soldered to it because sadly it doesn’t fit in my breadbord)
Maybe there’s something wrong with my circuit (the way I put my components but I’m not sure)


It’s an arduino UNO

Hi,
You have a short under the relay, their are two conducting rails running along side the protoboard.
That is what the RED and BLUE line indicate.
HAVE YOU USED YOUR DMM TO LOOK AT ANY OF THE CIRCUIT?


You need to look at how your protoboard is constructed.

You may have cooked your transistor too.

Tom… :grinning: :coffee: :coffee: :australia:

Well I don’t know where I can find how it’s constructed.
And I don’t have one at home so I can’t but I can do it this Friday.
But I don’t understand why it’s shortened. Because on my circuit (schematic) my diode is in parallell with the coil.
And how is it possible that I fried the transistor? Is it because I shorted the coil? (which I don’t understand :frowning: )

OK, pack up everything now and get yourself down to Home Depot or the other hardware shop and get a cheap $5 digital multimeter.

(OK, if they don’t have the $5 ones, you may have to go for the $20 auto-ranging version. :laughing:)