The image is distorted.
Try a simple 1 second on 1 second off toggle sketch to see what happens.
Measure voltages while running.
The image is distorted.
Try a simple 1 second on 1 second off toggle sketch to see what happens.
Measure voltages while running.
BigKitty10:
Here is a image of my setup
Sorry, no it isn't! ![]()
It is a reference to a Google page which requires a login.
Remember, this a picture, we can't pull it off the screen and tilt it sideways to see what is under the croc clips.
That code is no good for testing the relay. This is because a random number is generated in the setup function and it will only fire the relay if that random number matches the relay. As the setup only runs once you will not get any different until you reset the Arduino.
The code
while (CurrentFloor != TargetFloor);
Will enter an endless loop and nothing will happen, this is because you end that line with a semicolon which means those two variables can not change and it will loop there forever.
Take the blink LED sketch from the IDE and change the pin to 11 and test that.
I have connected 5v directly to the relays and they do activate
Exactly what did you do? Where did you connect the 5V on the relay board and where did this 5V come from?
Paul__B:
The whole idea of these opto-isolated modules is that there must not be a common ground between relay module and Arduino to achieve isolation.
Yes but we are dealing with a crap Chinese relay board and some of these are not designed correctly. Some of these boards have a common ground and are not fully isolated at all. The problem is that we don’t know what we are dealing with.
The other big problem is the OP never had code to test the relays in the first place. So when that is corrected then maybe we will see there is nothing wrong with the hardware.
Alrighty then! Here we are! I took the relay and hooked it up in a more similar fashion. I tried to follow this picture when testing the relay!
And here is my setup!
As expected the relay does not click! Even though each wire is connected exactly as shown in the first photo! I measured some voltages and everything checked out, I got 5v coming from the power supply and I got 5v coming from the Arduino, the LED is on so the optocoupler LED is not fried. I can only assume that the problem lies with the transistor or the optocoupler's photo transistor. But at this point, I can't be too sure of anything.
Just to be clear, the Arduino's 5v pin goes straight to Vcc on the relay, the 13 pin goes to In1, the power supply's 5v wire goes to JD-Vcc, and the GND of the supply goes to GND on the relay! And yes, the jumper is removed!
Here is the code
/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
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
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Blink
*/
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Edit: if I short the transistor, I get 5v going through the multimeter. But the relay does not activate? Is it possible that I don't have enough current going through the relay?
For this test only, use 5v/GND from the Arduino to power the relay board, not your Proto 1000.
Good news! I was able to make the relay coil work! But it keeps turing on and off at a rapid pace!
Okay the Arduino cannot supply the current needed, this was just a test.
Get a regulated 5V external power supply 'instead' of your Proto 1000.
Just as a test connect the ground of your relay input to the ground of the Arduino keeping your Proto 1000 power supply.
Well, I tried to connect a usb cable from one of apple's usb charging blocks to the relay's coil power pins. And it did not activate even though the max current output is at >500mA, which is 430mA over the minimum trigger voltage for this relay! Is there something about usb power that I'm not aware of?
which is 430mA over the minimum trigger voltage
Trigger voltage is measured in Volts not in mA.
Just connecting one wire is not going to allow any current to flow.
Sorry, I meant to say trigger current. The trigger current is 70mA
The trigger current is 70mA
So what do you mean by trigger current? I suspect you mean the current that the relay draws when on. Which is not a trigger but a working current.
Now why did you not do what I asked about the test program? I said in reply #23:-
Take the blink LED sketch from the IDE and change the pin to 11 and test that.
But you didn't you left the pin at 13, why? This meant that your protestations that the diagram was exactly how it was wired was now not true.
Finally I asked you to do something in reply #29, but have not reported back on what happened, so to my mind you are ignoring me. All of us here are trying to help you. We have not got access to your setup, you are out eyes and hands, we rely on you to cooperate.
Now I am going to ask you to try something else please, and I am expecting you to try it and report back on the results.
Keep the circuit as you had it with Vcc connected to the 5V of the Arduino and move the input you use to the one next to the Vcc on the relay board, so both Arduino wires are next to each other. Do not power anything connected to the relay contacts, and run the "blink like" test program with the pin being blinked, the same one you have wired up.
Have you noticed a lot of your photographs are now not showing?
All fixed! Just made a few adjustments and now it works great! Thanks!
“All fixed! Just made a few adjustments and now it works great! Thanks!”
Well, that’s what we thought the problem was.