I hope someone can give me a little guidance on an issue I can't quite decide how to approach. For some background, I do a little volunteer work with a local guy who helps people find lost pets using trapping methods primarily. He has asked me to try and put together a circuit that can operate at a range of about 1/2 mile to release a magnetic lock and allow a door to shut.
I've got two different approaches to this problem which will result in two different projects being completed. The final and more perfect one will involve using a hamshield to accept a radio transmission from my amateur radio gear. I understand how that one will go together but I can't make that first because the guy I'm working with has not obtained his amateur radio license. In the meantime, my plan is to use a pair of FM walkie talkies, clipping the speaker wires on the receiving one and hopefully using the voltage generated at those wires during a transmission to open a relay and release a magnetic lock.
Regarding that setup, I have a question. I will program the arduino to respond to any detected amount of input signal from the receiver to send a command to the relay, but I don't understand if this is a hookup for the digital or the analog side of things. I want the exact same action to be taken regardless of whether 1v or 2v is detected. The voltage of that signal will vary depending on ambient conditions but all I need is for the board to safely accept it regardless of the amount of voltage. So....getting there the long way, is this an analog signal or a digital signal I'm asking the board to interpret? Like I said, no need to measure the signal and it's just doing an on/off thing depending on whether or not there's voltage present, so I'm thinking the answer is to hook up to the digital side of things. I know it's a total noob question, but before I hook things up wrong I wanted to ask if someone could point me in the proper direction.
My very sincere thanks to anyone who can help put me on the right path!
Welcome to the Arduino forum. I have two comments.
First is the signal from the speaker will be AC, so you need a bridge rectifier to get some DC from it. Place an 8 ohm resistor in place of the speaker. Or use the usual earphone jack to get audio. Resistor still is needed.
Second, you will HAVE to send a tone to the HT in order to get any audio. But that is easy to do with today's HTs.
Thank you SO MUCH for your response! I hadn't even considered that the speaker wires would be AC rather than DC. I've either got a bridge rectifier on hand or I have enough on hand to put one together so I guess I know what I'm doing tonight!
use the volume on your walkies and make sure the signal from the speaker leads dont go past 5 volts before hooking to the arduno. i would imagine you might need to share a ground between the arduino and the radio too.
there are some things to consider.
if you read a signal from an audio output or speaker output you will get a wave. if you read the signal from a pin very quickly the voltage will fluctuate up and down. you would need to measure the TIME between the ups and downs to determine what "tone" you are getting.
simply measuring how high the voltage is might not do you much good. when dealing with audio, the amount of voltage you are reading would only give you the volume at best. unfortunately noise when not recieving will give you just as much volume as your signal. actually when you get a clear transmition it would be easier to detect silence (or steady low voltage) when the walkies talkies connect and the noise goes away!!!!!!
Thank you for sharing that, Taterking. I think between the two of you guys I'm finally in business!
Just to share what came of it, I put in 8 ohms of resistance between the speaker wires and built a bridge rectifier (the ones on hand were panic purchased when doing the Radio Shack clearance sale stuff and apparently they're for much more powerful stuff than I'm into). Instead of using voice, I'm using a call button that sends something like a ringtone to the second radio. It isn't a steady tone, but it sends a consistent 2 to 2.15V to my meter so I think I have something that'll at least signal the arduino to do what I want it to do.
I honestly can't believe this project is so close to completion now and I couldn't have done it with the advice both of you shared. I very sincerely appreciate your input. It certainly cleaned up the final big issue I've had even though I didn't really get that it was a problem until you guys helped me. Hopefully this project will lead to the capture of countless lost pets as the project is apparently of great interest to the rescue and trapping communities. If I win a Nobel prize for it, you guys won't be forgotten! lol . Thank you both so much!
Just monitor the voltage across the squelch indicator of the radio! It will be DC, but only an LED voltage drop. An Analog input on an Arduino would assess that but a 10k resistor and NPN transistor would do the same job.
Hi Paul_B. Thank you for that advice. I thought a little about that last night while I was assembling the bridge rectifier, and in hindsight it would probably have been the easier route but I had to disable the speaker on the receiving end anyway (the trap is only really going to be deployed to catch extremely skittish animals who have figured out how to avoid traditional box traps) so as to not spook the animals. Oddly enough, this is not the first approach that has been tried. The first design someone else had put together relied on a photo eye having it's beam broken, but between the indicator lights on it and the relay, it scared someone off. This version as well as the next should be dead silent once I have it packed in a pelican box to mute the relay...I hope lol I haven't explored the forums other than searching for information specific to the issues I've been having but if there's a place to post pics of projects I'll be sure to show it off once it's functional!
Ok, I'm hoping this is still going to generate a little attention because I'm completely stumped.
Just to clarify where things are now, I've got a receiving radio which I know does receive signal from the transmitting radio. The receiving radio's speaker wires were cut from the speaker. I added 8 ohms of resistance and then ran through a bridge rectifier. When I put this on my multimeter, I get a consistent reading of 2.15v to 2.18v when transmitting from one radio to the other. That voltage is sustained for about 3-4 seconds so it's not like I'm just missing it with a low rate of measurements or something along those lines
I'm taking the same pair of leads I had on my meter and inserting them into A0 and the nearest ground, two positions up the side of the Arduino. I've inserted language in the code to run the serial monitor and display the voltage detected by Arduino. Even when transmitting (at which time the meter verified that there is voltage present past the bridge rectifier), the only value that shows up in the serial monitor is 0 volts. So I know I have volts present at the connection point, but they will not register, so my relay won't switch (it's connected to digital pin 4 for what it's worth).
Now this code is an embarrassment but I don't believe it should need anything beyond what I have here:
int sensorPin = A0;
int relayPin = 4;
int sensorValue = analogRead(A0);
void setup()
{
Serial.begin(9600);
pinMode(sensorPin, INPUT);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH);
}
void loop()
{
Serial.print(sensorValue);
Serial.println (" V");
if (sensorValue = 0) digitalWrite (relayPin, HIGH);
else if (sensorValue > 1) digitalWrite (relayPin, LOW);
}
Does anyone have any thoughts on why (other than the Arduino being ruined which is a possibility too I guess) the serial monitor would not be picking up on the incoming voltage? The only idea I have is that maybe I should be using a digital input rather than analog. but I have absolutely no idea. I've done about 7 hours of tinkering with this today and I'm finally ready to admit that I'm lost and I've exhausted all paths before bugging you fine people with my issues!
You need to ensure the signal input is WRT Ground/0V on the arduino.
The speaker wires might have one side grounded, but quite likely not.
If you have used the bridge - ensure the -v ‘output’ is tied to the Gnd side, and the +v side goes to the analog input pin.
lastchancename, thank you for your thoughts. Could I ask you to elaborate on what you brought up with ensuring the input signal is WRT ground/0V?
Just to explain what I have happening, my goal is to use a radio signal to trip a relay to open a magnetic lock. To try and do that, I cut the speaker wires away from the speaker of a receiving walkie talkie, separated them with 8 ohms of resistance and then ran them through a bridge rectifier to come out in DC. When I transmit from the other walkie talkie, the receiving walkie talkie registers a consistent 2.2V (+/- 0.05V) on my multimeter. I plugged the +v out from the BR to the analog pin and the -v out to a ground on the Uno board. No matter what I try, the carduino will not read any voltage in the serial monitor and it won't switch the relay. I went out today and picked up another Uno from a more reputable manufacturer thinking the board may have been faulty, but it does the exact same thing. I'm wondering if the idea of having one of the speaker wires grounded differently may be a contributor to the issue I'm having but I'm not really certain exactly what you're telling me.
Did you fix the problem I wrote about in #10? You end an "if" with a semi-colon, and then begin the next line with an "else". There is no "else". Else is an internal Boolean that is set to true when a test result is false. There is no previous "if" because you wrote it that way!
You really only want to know then the pin test is a "1" and do the trap trigger thing. You could care less about a "0" condition.
I think I may have realized part of my problem. The output from the bridge rectifier isn't going to be an actual full sine wave DC. I think if I put it on an oscilloscope, the positive lead would show a half-cycle positive sine wave and then a half cycle of 0. Likewise, the negative would show a half wave of negative sine wave followed by a half cycle of 0. So I don't really have true DC. So I'm thinking I don't have a true ground then either?
Hi, Paul! I did remove the spare else I had in there. Thank you so much for explaining the reason behind it though. I didn't understand the effect of having the statement in there with the previous if ending in a semicolon and thought it was for the sake of making things neater. I understand the reason behind it now. I've effectively ignored my family all weekend messing around with this and need to get my daughter out to the pool for an hour or so before I'm in trouble lol. As soon as I get back, I'm going to remove the code asking the board to give any consideration to monitoring for 0 volts and instead to check only for 1 or more volts. I think between that and whatever solution I can google for the issue I mentioned in lucky #13, I might have a chance to sleep tonight haha
JohnRoth:
I think I may have realized part of my problem. The output from the bridge rectifier isn't going to be an actual full sine wave DC. I think if I put it on an oscilloscope, the positive lead would show a half-cycle positive sine wave and then a half cycle of 0. Likewise, the negative would show a half wave of negative sine wave followed by a half cycle of 0. So I don't really have true DC. So I'm thinking I don't have a true ground then either?
If you really have a bridge rectifier and if is connected properly, the + output, compared to the - output will show only + pulses on the + lead. The bridge rectifier will move the - pulses to the +, so you get 2X the number of sine wave input signal waves.
Do you, by any chance, have a schematic of the HT you are using? It may have a single ended audio output and capacitor coupled to the speaker. That would be the really cheap way to get audio.
WRT ground is simply reinforcing the fact Arduino only sees positive excursions (up to 3v3/5V).
Any negative voltage on a pin is going to have unintended consequences.
Afterthought. You could sink the power source to -Vcc/2 then Ain at 2V5 becomes mid point in. 5V sine wave, but you then have to modify the rest of your circuit to shift everything else into positive territory.
Hi everyone. First, I want to offer my sincere thanks to those of you who lent me a hand in getting things figured out. My project is finally wrapped up and good to go.
Just to share the details of how things ended up working out, I actually had two problems going on. First was a coding issue where I didn't have the analogRead on pin A0 inside the void loop. Once that was inserted into the correct spot, I was able to get the analog readings I was expecting. Just a noob problem, but after all that time spent working through the issue, I'm pretty sure I won't be missing that again lol
The second issue was with getting the speaker wires to read properly. In the end, I used a bridge rectifier to convert to DC and then needed to use a voltage divider to silence (or nearly silence) the signal to the A0 pin during times when the receiving radio isn't receiving anything. I was able to use the serial plotter to easily figure out where the threshold for triggering the output should be set.
Once again, thank you all so much for your assistance with my issues. I learned an awful lot with this project (including learning a lot about a large variety of approaches which were unhelpful or outright irrelevant, but learning is learning I guess!) and I hope I have the opportunity to return the favor one of these days.
I'm sorry, Paul. It works! It's a bit of a miracle that this got completed and I couldn't have gotten there without ya man!
The guy I'm building this for has unfortunately sustained an injury that's going to require surgery next week, so while my next step is actually fitting the device to his trap, we haven't been able to get together do that just yet. He's got a long recovery ahead of himself but if I know him as well as I think I do, he'll be back out helping people catch their runaway pets within a week. The good thing is that he runs a cellular video camera on all of his traps so when we finally have an opportunity to use this, I'll be able to grab a copy of the video to post. I'm certain the design is good but the final report on the project is just going to present much better with video.