Relay shield for arduino problems

Thread Starter

Killerbee65

Joined May 15, 2017
256
Hello everyone, so getting to the point I wanted to be able to control multiple DC motors (like a RC car) and I was told by multiple sources a relay shield might be what I need (mind you I'm pretty much a novice at programming and engineering). So I connected the arduino mega 2560 I have to the shield and the motor to the shield and got the code from a video explaining how to use a relay shield (I'll include any pictures and links needed) the only difference between the video and my design is the fact I am using a motor, and he a light bulb as well as the kind of arduino. So my question is why does his project work but mine does not?

Both links lead to each other but we're added for your convenience

Video of relay shield:

Link to code:
https://robojax.com/learn/arduino/?vid=robojax-relay-shield
 

Attachments

ebeowulf17

Joined Aug 12, 2014
3,307
We get this question a lot "Why doesn't XYZ work?" In many cases, we don't even get a good description of what XYZ is, nor what it's supposed to do. In this case, you've done a good job of sharing the relevant project info so we know what's supposed to happen, so kudos for that... but we don't know what its failing to do, or what you've tried so far. What's happening? Anything, nothing?

So, how far have you gotten? Is a relay clicking, but the motor isn't working? Is the relay not even clicking?

Is this your first Arduino project? Have you confirmed that the board, and your programming setup, are working by running something simpler, like a "blink" or "hello world" sketch? If not, I'd try that first. Those simpler setups are easier to debug, and getting them working may reveal what's wrong in your motor driving attempts.

Have you tested the motor without running it through the Arduino controlled relay? In other words, do you know for sure that the motor works off of whatever power supply you're trying to run it from?

We need to narrow things down to see where the problem is before we can solve it. Is it a problem with the Arduino or shield? Is it a problem with the relay or power wiring? Is it a problem in the code? Is it a problem due to using a Mega instead of an Uno?

Maybe one of the questions or suggestions above is helpful. If not, please tell us more about what you've tried so far in terms of isolating the problem and debugging.

Arduinos are loads of fun once you get the hang of it, but there are often little twists and turns along the way - plenty of problems to solve and bugs to fix. Don't get discouraged, and be methodical in your diagnostics and repair attempts.
 

Thread Starter

Killerbee65

Joined May 15, 2017
256
We get this question a lot "Why doesn't XYZ work?" In many cases, we don't even get a good description of what XYZ is, nor what it's supposed to do. In this case, you've done a good job of sharing the relevant project info so we know what's supposed to happen, so kudos for that... but we don't know what its failing to do, or what you've tried so far. What's happening? Anything, nothing?

So, how far have you gotten? Is a relay clicking, but the motor isn't working? Is the relay not even clicking?

Is this your first Arduino project? Have you confirmed that the board, and your programming setup, are working by running something simpler, like a "blink" or "hello world" sketch? If not, I'd try that first. Those simpler setups are easier to debug, and getting them working may reveal what's wrong in your motor driving attempts.

Have you tested the motor without running it through the Arduino controlled relay? In other words, do you know for sure that the motor works off of whatever power supply you're trying to run it from?

We need to narrow things down to see where the problem is before we can solve it. Is it a problem with the Arduino or shield? Is it a problem with the relay or power wiring? Is it a problem in the code? Is it a problem due to using a Mega instead of an Uno?

Maybe one of the questions or suggestions above is helpful. If not, please tell us more about what you've tried so far in terms of isolating the problem and debugging.

Arduinos are loads of fun once you get the hang of it, but there are often little twists and turns along the way - plenty of problems to solve and bugs to fix. Don't get discouraged, and be methodical in your diagnostics and repair attempts.
Hello! So the motor is simply just supposed to run when the relay is turned on. I plan to do more with the code and add more on like acceleration control and directional movement so learning how it simply turns the motor on and off using a relay is my first step to it, almost like connecting the motor directly to a 9v battery which is how I quickly test to see if the motor actually works still. As for testing the boards prior to this project, I have done various codes and projects with the mega with success but haven't used the relay shield. With the shield itself I used a code I found online that is similar to a "blink" code where it turns on each relay one by one so I'd assume it also works. The problem here is that I simply want to make the motor run when the relay is on but it won't run. I hope that answers your questions, again thank you for the response and I'll try to keep you all posted!
 

AlbertHall

Joined Jun 4, 2014
12,345
With the shield itself I used a code I found online that is similar to a "blink" code where it turns on each relay one by one so I'd assume it also works.
When you run this code can you hear, or feel, the relays operating?
If not then probably the code changing to account for the differences between uno and mega.
 

Thread Starter

Killerbee65

Joined May 15, 2017
256
I have not, but then again I don't own a voltmeter. I can try at my school so I'll let you know if it actually does output something!
I hooked it up and it shows 0.09mV

I tested a 9v battery to make sure the voltmeter works and it displayed 9v like it's supposed to but when connected to the "on" relay it shows 0.09mV
 

Attachments

bertus

Joined Apr 5, 2008
22,270
Hello,

The relays will not give any voltage at its contacts.
The contacts will behave like a switch.
Looking an the video you posted, there is an external powersupply and a lamp.

Bertus
 

Thread Starter

Killerbee65

Joined May 15, 2017
256
Hello,

The relays will not give any voltage at its contacts.
Looking an the video you posted, there is an external powersupply and a lamp.

Bertus
I assumed the power supply was the arduino Uno connected to his computer, my relay is connected to my mega and to my computer.
 

bertus

Joined Apr 5, 2008
22,270
Hello,

The relays coil is activated by the voltage of the control board.
The contacts are isolated (do not carry any voltage by its own) from the control board.
Here is the schematic symbol of the relays:

relays.png

The box on the left is the coil, that is controlling the contacts on the right of the picture.

Bertus
 

Thread Starter

Killerbee65

Joined May 15, 2017
256
Hello,

The relays coil is activated by the voltage of the control board.
The contacts are isolated (do not carry any voltage by its own) from the control board.
Here is the schematic symbol of the relays:

View attachment 201607

The box on the left is the coil, that is controlling the contacts on the right of the picture.

Bertus
Ah, I see, so basically I need an external power source like you mentioned right? If that's the case then I have a energy shield that is basically a rechargeable power supply that connects right to the board like the relay shield and I want to know if I'd be able to use that.
 

ebeowulf17

Joined Aug 12, 2014
3,307
What are the specs for the motor? What voltage does it need to run on (V?) Does it list current (A or mA) or power (mW or W?)

Most motors consume quite a bit more energy than an Arduino, so an Arduino battery pack may not have enough juice to last very long at all powering a motor. It also may not operate at the correct voltage for the motor. It all depends on the motor specs.
 

Thread Starter

Killerbee65

Joined May 15, 2017
256
What are the specs for the motor? What voltage does it need to run on (V?) Does it list current (A or mA) or power (mW or W?)

Most motors consume quite a bit more energy than an Arduino, so an Arduino battery pack may not have enough juice to last very long at all powering a motor. It also may not operate at the correct voltage for the motor. It all depends on the motor specs.
I think they are just generic motors in a housing. I'm not exactly sure what the specs are but I'll include a link to to the one's I used.

https://www.amazon.com/KEYESTUDIO-M...words=arduino+car+motor&qid=1584364401&sr=8-2
 

ebeowulf17

Joined Aug 12, 2014
3,307
Here are the specs. Looks like Arduino level ~5V should be ok, although it won't deliver maximum motor torque. Current draw is probably acceptable for a USB powered Arduino to test it, but if you're ultimately going to have multiple motors, or load even one more heavily than just a test spin, you should probably get an external power supply.
 

Attachments

Thread Starter

Killerbee65

Joined May 15, 2017
256
Here are the specs. Looks like Arduino level ~5V should be ok, although it won't deliver maximum motor torque. Current draw is probably acceptable for a USB powered Arduino to test it, but if you're ultimately going to have multiple motors, or load even one more heavily than just a test spin, you should probably get an external power supply.
https://ns-electric.com/product/energyshield-2/

Here's the link to the energy shield I'm using I don't know if it'll work or not? On paper it looks like it does but I haven't tried it yet. I wanted to actually get to motor running first before using the shield but I didn't know of the complications at the time.
 
Top