To explain my project very quickly, I've made a line of lamps (halogen), which would visualize the amount of sound, more lamps going on if the sound is loud.
The setup works really well if it's just the arduino running. The relay/code reacts nicely to the amount of sound coming in. (More relay gates opening if the sound is loud, and closing when it's quiet again).
However, when I put power on the relay and lamps the sound doesn't reset, but instead uses the highest number it got as a base.
For example, if there was only background noise the signal would be around 300, blow into the mic or tap on it and it would go up to 500 and when I stop it goes back to 300.
When the power is on it doesn't go back to 300.
It doesn't reset if I reset the code, or reupload it. The only way I have found to reset this, is to remove all power from both the arduino and the relay, leave it for a while and then come back.
The analog output of the microphone goes directly into (tried with different resistors and and doesn't make a difference) the Arduino A0 port.
Can anyone help me with this? I don't think it's the code and instead the lamps messing with the signal?
Let me know if you need the code and/or setup, and sorry if my explanation isn't clear.
Thanks!
How I solved it, probably a stupid way but it worked.
I got another arduino uno which only houses the microphone, and uses serial communication to send the received value to the other arduino.
InsaneCold:
Can anyone help me with this? I don't think it's the code and instead the lamps messing with the signal?
We can't see the code or the wiring setup so there's no hope of any of us being able to tell what the issue is. How do you think we could figure out what's wrong with something when we have ZERO information about it other than the fact that it seems to not work?
Delta_G:
We can't see the code or the wiring setup so there's no hope of any of us being able to tell what the issue is. How do you think we could figure out what's wrong with something when we have ZERO information about it other than the fact that it seems to not work?
I thought it was some trivial mistake, like, hey a relay interferes with other components.
But I've added the code and an attempt at the wiring.
Please keep in mind that I have very little experience with arduino.
The wires at the top go to the relay, but the sketch thing didn't have one.
InsaneCold:
I thought it was some trivial mistake, like, hey a relay interferes with other components.
That would depend on how things were wired.
InsaneCold:
But I've added the code and an attempt at the wiring.
Please keep in mind that I have very little experience with arduino.
The amount of experience you have with Arduino has no bearing on whether or not you can figure out that a person can't debug what they can't see. That's just basic common sense.
It seems the relay and/or halogen lamp currents interfere with the microphone.
We DO need the FULL picture to give you the proper advice.
How is the relay module powered, how is the Arduino powered, how are the lamps powered, etc.
You could try powering the (sensitive) mic board from 3.3volt.
That should be "cleaner" than the 5volt rail.
Leo..
Are you driving those relays directly off the Arduino pins? You probably need a transistor on each one so you aren't trying to pull so much power through the Arduino.
InsaneCold:
Yeah, the relay goes straight to the pin, no transistor between.
You may be hurting the Arduino that way. Is this a replay shield of some sort or are those just normal relays? If the latter then you should probably be using a transistor to drive them.
Delta_G:
You may be hurting the Arduino that way. Is this a replay shield of some sort or are those just normal relays? If the latter then you should probably be using a transistor to drive them.
Just a normal 8-way relay, thanks for the advice, I'll look into that.
But that can't be the problem right? I mean, the relay works fine if there is no power coming from the wall, it's just when I plug it in, it breaks. Does the relay send power back into the Arduino somehow?
Delta_G:
No, but it can consume an awful lot of current from the Arduino and cause the voltage on the Arduino to sag. Hence the need to keep them isolated.
Got it. I have a few short questions how to implement them though.
This is how I would wire them right?
right pin to ground, left to pin, and middle to relay.
No, that's not how you would wire it. The pin would go to the base which is the middle pin. Which of the other two is which is hard to say since i don't know which way round you have the transistor in the drawing. But the collector goes to the relay low side and the emitter goes to ground.
The advice given by Delta_G is for bare relays, not for a relay board.
I'm going to assume you use a common 8-relay board.
It is not a problem to control an 8-relay board with the Arduino pins,
but powering such a board from the Arduino is probably not ok.
If all relays are "on", the board (relay coils) draw about 650mA.
Too much for USB (500mA fuse), and likely too much if you power the Arduino from the DC socket (hot regulator).
You should have answered all the questions from post#6
You might have to use a separate 5volt/1Amp (cellphone) supply to power that relay board.
Post a link (or picture) of the board, so we can give the right advice.
Leo..
You need a 5volt supply, e.g. old cellphone or tablet charger, with a minimum rating of 1Amp, because the board can use up to 650mA.
Remove the JD-VCC jumper.
Connect the 5volt supply(+) to JD-VCC and relay ground(-).
Connect VCC (from the long row) to Arduino 5volt.
Connect relay inputs to Arduino pins.
DO NOT connect relay ground to Arduino ground.
If you do, you don't have opto isolation.
The Arduino needs it's own supply (for opto isolation).
If you don't need the extra safety of opto isolation, then you can connect relay ground to Arduino ground.
In that case, the Arduino will be powered from the relay supply.
Low is indeed active.
To stop the relays from chattering during bootup,
digitalWrite a HIGH to the pin BEFORE you set the pin with pinMode to OUTPUT.
Leo..
Wawa:
You need a 5volt supply, e.g. old cellphone or tablet charger, with a minimum rating of 1Amp, because the board can use up to 650mA.
Remove the JD-VCC jumper.
Connect the 5volt supply(+) to JD-VCC and relay ground(-).
Connect VCC (from the long row) to Arduino 5volt.
Connect relay inputs to Arduino pins.
DO NOT connect relay ground to Arduino ground.
If you do, you don't have opto isolation.
The Arduino needs it's own supply (for opto isolation).
If you don't need the extra safety of opto isolation, then you can connect relay ground to Arduino ground.
In that case, the Arduino will be powered from the relay supply.
Low is indeed active.
To stop the relays from chattering during bootup,
digitalWrite a HIGH to the pin BEFORE you set the pin with pinMode to OUTPUT.
Leo..
Thanks man, that's really helpful!
One last question though, I only have USB power supplies. Could I cut a usb cable in half and use those?