Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Detect current on Raspberry pi

Wed Oct 17, 2018 2:43 pm

Hi,

I'd like to test with my raspberry pi if there is a current flow on an intercom speaker.
The purpose is to get notified when someone rings at the entrance door.

My guess is that I should plug the speaker circuit to a GPIO pin and read this pin constantly to know if the intercom is ringing.
I know I have to protect the raspberry because the intercom circuit surely has way too high voltage and intensity, but I really don't know how.
Is there any electronic component which does that ?

Thank you for your help ;)

pcmanbob
Posts: 4460
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Detect current on Raspberry pi

Wed Oct 17, 2018 2:50 pm

To provide detailed help we would need to know what part of the circuit you intend to monitor and the voltages present , you might be able to use an opto isolator if the circuit in question can support the extra load, but without knowing a lot more its had to say for sure.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Wed Oct 17, 2018 8:55 pm

I want to monitor the speaker part of the circuit (cf attached picture).
I've just measured the voltage on the speaker when it's ringing, I get something between 3.4V and 3.6V.

Please let me know if I can give you some other information.
Thanks
speaker.jpg
speaker.jpg (151.11 KiB) Viewed 802 times

pcmanbob
Posts: 4460
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Detect current on Raspberry pi

Wed Oct 17, 2018 10:59 pm

So exactly what do you want to do,
measure current or just detect when there is some sound being played by the speaker ?

If you just want to want to detect when a sound is being played you might be able to do it using a opto isolator with the LED side connected across the speaker input with a 270Ω resistor in series with the LED you cam then use the output from the opto isolator like a switch which can be monitored using a gpio input.

you will need to experiment because I don't know if the output powering the speaker will be able to drive the opto isolator along with the speaker.

If you want to actually measure the current then you will need to put a low ohm resistor in series with the speaker and then use a ADC to measure the volt drop across the resistor and calculate the current using ohms law.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Thu Oct 18, 2018 11:57 am

Exactly, I just want the raspberry pi to know when a sound is being played through the speaker.

Should I look for a specific opto isolator ?
I found this but I don't know if that will do the job: https://www.aliexpress.com/item/50pcs-P ... st=ae803_4

Can you tell me why you put a resitor, and why 270 specifically ? It feels like a random magic number to me :D

I drew a scheme of the solution you came up with, can you tell me is this is correct ?

Thank you!
scheme.png
scheme.png (9.15 KiB) Viewed 755 times

pcmanbob
Posts: 4460
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Detect current on Raspberry pi

Thu Oct 18, 2018 2:17 pm

Yes you could use that opto isolator , you need a resistor to limit the current flowing through the LED, because if you just connected 3.6V to the LED you would burn it out.

so using the opto isolator you selected you now need a 330Ω resistor. You will also need a diode connected in reverse with the LED because you will be applying a signal to the speaker that could cycle positive and negative.

I have also shown how to connect the output of the opto isolator to the pi gpio so that it produces a true on speaker activation, but this will probably be a pulsing output so you will need to take that in to account when programming.

Image

https://github.com/raspberrypilearning/ ... up_down.md
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Thu Oct 18, 2018 3:58 pm

Thanks pcmanbob, this is pretty much clear to me now ! ;)
I'll order the opto isolator and let you know.

The link about pull up / pull down circuit says I don't need resitors (10K & 1K) since it's already integrated within the Pi when setting up the PIN to GPIO.PUD_UP / GPIO.PUD_DOWN mode.
Is that right ?

pcmanbob
Posts: 4460
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Detect current on Raspberry pi

Thu Oct 18, 2018 4:50 pm

If you use a software pull down you don't need the 10K resistor, the 1K resistor is there to protect the gpio in the event you set the pin to output and low while pressing the button which would short the 3.3v to ground damaging your pi so I advise you to fit it.

I prefer to use external resistors for pull up/down because the internal pull up/down is around 50K which might not be enough in an electrically noisy environment in something like your intercom.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

User avatar
tlfong01
Posts: 660
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Detect current on Raspberry pi

Fri Oct 19, 2018 4:35 am

Salah wrote:
Wed Oct 17, 2018 8:55 pm
I want to monitor the speaker part of the circuit (cf attached picture).
I've just measured the voltage on the speaker when it's ringing, I get something between 3.4V and 3.6V.

I guess your intercom circuit has a relay module. Perhaps you can use Rpi to detect the input signal of the module.
Attachments
intercom_relay_module_2018oct1903.jpg
intercom_relay_module_2018oct1903.jpg (142.39 KiB) Viewed 699 times
I am an electronics, smart phone, and smart home hobbyist.

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Sun Oct 21, 2018 10:42 pm

Hi tlfong01,

I don't see any original relay module in the intercom.
The thing you labelled "A", is indeed a relay, but one I added to control the door opening switch with my raspberry pi.

User avatar
tlfong01
Posts: 660
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Detect current on Raspberry pi

Mon Oct 22, 2018 6:03 am

Salah wrote:
Sun Oct 21, 2018 10:42 pm
Hi tlfong01,
I don't see any original relay module in the intercom.
The thing you labelled "A", is indeed a relay, but one I added to control the door opening switch with my raspberry pi.

The capacitor before the loudspeaker might cause a problem

So I made a wrong guess.

Now I agree one way is to check the voltage signal at the loudspeaker. However I worry that the capacitor C3 in the intercom circuit below might prevent you doing so.

Let me explain.

Your voice signal is low frequency audio, below 20kHz. An audio power amplifier such as LM380 can be used to amplify the audio signal. There is usually a RC (Resistor Capacitor) low frequency filter at the amplifier output to filter out high frequency noise. This DC signal blocking capacitor might prevent the Rpi doing the job.

If you use a multi meter to check the voltage at the loudspeaker when there is no sound signal, you might get Vcc or zero. When there is a sound signal, your multi meter might give an average (or RMS, root mean square) value of the AC signal.

I have no idea how you can use Rpi to check this AC signal. But I am interested to see the result. :)

Update 2018oct22hkt1609

In case you find Rpi not detecting AC signals at the loudspeaker, you may like to consider the following sound detector:

Amazon Microphone Sound (Voice) Detector Sensor module with digital and analog out - for Arduino, STM32, Raspberry DIY projects
https://www.amazon.com/RobotDyn-Microph ... B073S39CG4

Appendix - Intercom references

Super Simple Intercom
https://electronicsforu.com/electronics ... e-intercom

Hacking the old door phone
https://community.home-assistant.io/t/h ... hone/34095

How to Install a Home Intercom System
https://home.howstuffworks.com/how-to-i ... ystem1.htm
Attachments
simple_intercom_cct_2018oct2202.jpg
simple_intercom_cct_2018oct2202.jpg (166.68 KiB) Viewed 613 times
I am an electronics, smart phone, and smart home hobbyist.

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Mon Oct 22, 2018 8:20 am

Thank you for the explanation tlfong01,

I think my intercom is lightly different from the one on the diagram.
Mine has a handset with a separate microhpone and speaker. The speaker I want to wire to the pi only buzz to alert me someone wants to come in, there is no audio voice out of it.

I attached more pictures of the intercom so you can have a better understanding of the full circuit.
The thin wires white/blue/red goes to the handset. I wired the blue and red ones (ground and handset speaker I guess) to a 3.5mm jack which I plugged to a usb sound stick on the raspberry pi and I managed to get the voice audio on the Pi.
IMG_0643.jpg
IMG_0643.jpg (98.47 KiB) Viewed 594 times
IMG_0548.jpg
IMG_0548.jpg (78.44 KiB) Viewed 592 times

User avatar
tlfong01
Posts: 660
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Detect current on Raspberry pi

Mon Oct 22, 2018 9:46 am

Salah wrote:
Mon Oct 22, 2018 8:20 am
I think my intercom is lightly different from the one on the diagram.
Mine has a handset with a separate microhpone and speaker. The speaker I want to wire to the pi only buzz to alert me someone wants to come in, there is no audio voice out of it.

The thin wires white/blue/red goes to the handset. I wired the blue and red ones (ground and handset speaker I guess) to a 3.5mm jack which I plugged to a usb sound stick on the raspberry pi and I managed to get the voice audio on the Pi.

Ah, now I see I am making simple things too complicated.

Let me see, if Rpi's audio input jack can get the signal from the 3.5mm plug connected to the intercom loudspeaker, then you can just write a simple program, say, in python, with the help of so many python audio libraries out there, to do what you want. In other words, there is no extra hardware required for your project.

By the way, the very ancient intercom in my home is similar to yours, except there is no electronic component inside, only wires and switches! :(

Good luck to your project.
Attachments
interecom_cct_2018oct2201.jpg
interecom_cct_2018oct2201.jpg (146.65 KiB) Viewed 583 times
I am an electronics, smart phone, and smart home hobbyist.

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Mon Oct 22, 2018 12:02 pm

tlfong01 wrote:
Mon Oct 22, 2018 9:46 am

Let me see, if Rpi's audio input jack can get the signal from the 3.5mm plug connected to the intercom loudspeaker, then you can just write a simple program, say, in python, with the help of so many python audio libraries out there, to do what you want. In other words, there is no extra hardware required for your project.
I'm not sure I get what you are thinking about.

Let's say ringing speaker is "speaker1", and the handset speaker is "speaker2".
Currently I can get the signal from the speaker2 with a 3.5mm jack.
My goal is to know when the speaker1 is ringing.
You are suggesting to wire speaker1 to jack 3.5mm on the Pi, and then use python software to monitor audio for ringtone, is that right ? That would require another USB sound stick since I'm already using the one I got for the speaker2.

klricks
Posts: 5891
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Detect current on Raspberry pi

Mon Oct 22, 2018 12:39 pm

tlfong01 wrote:
Mon Oct 22, 2018 9:46 am
......

Ah, now I see I am making simple things too complicated.

Let me see, if Rpi's audio input jack can get the signal from the 3.5mm plug connected to the intercom loudspeaker, then you can just write a simple program, say, in python, with the help of so many python audio libraries out there, to do what you want. In other words, there is no extra hardware required for your project.

...
NO! The RPi alone does not have audio input. The 3.5mm jack provides video and audio OUTPUT only.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

User avatar
tlfong01
Posts: 660
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Detect current on Raspberry pi

Mon Oct 22, 2018 1:34 pm

klricks wrote:
Mon Oct 22, 2018 12:39 pm
tlfong01 wrote:
Mon Oct 22, 2018 9:46 am
......

Ah, now I see I am making simple things too complicated.

Let me see, if Rpi's audio input jack can get the signal from the 3.5mm plug connected to the intercom loudspeaker, then you can just write a simple program, say, in python, with the help of so many python audio libraries out there, to do what you want. In other words, there is no extra hardware required for your project.

...
NO! The RPi alone does not have audio input. The 3.5mm jack provides video and audio OUTPUT only.

Ah, let me see. I remember old versions of Rpi have a 3.5mm jack for audio output, and another socket for composite video output. For new versions of Rpi, there is no composite video jack, but the 3.5mm jack is for both audio and video output.

I think Salah is using the 3.5mm jack of a usb sound stick, and I am referring to the same jack of the USB sound stick.
I wired the blue and red ones (ground and handset speaker I guess) to a 3.5mm jack which I plugged to a usb sound stick on the raspberry pi and I managed to get the voice audio on the Pi.

I have been using the same USB sound stick for both Rpi 3 and Windows 10 and so far so good. I once played with the SnowBoy thing and found no problems.

Snowboy, a Customizable Hotword Detection Engine
http://docs.kitt.ai/snowboy/
Attachments
rpi_usb_microphone_speaker_2018oct2202.jpg
rpi_usb_microphone_speaker_2018oct2202.jpg (164.16 KiB) Viewed 516 times
Last edited by tlfong01 on Mon Oct 22, 2018 3:00 pm, edited 1 time in total.
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 660
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Detect current on Raspberry pi

Mon Oct 22, 2018 1:56 pm

Salah wrote:
Mon Oct 22, 2018 12:02 pm
Let's say ringing speaker is "speaker1", and the handset speaker is "speaker2".

Ah, I did not realize that you have two speakers, one for ringing, another for voice. I was thinking of the circuit I posted earlier, using one speaker for both ringing and voice.

The visitor pushes the ring button at the top left corner of the circuit, and the one and only one speaker rings.
Attachments
simple_intercom_cct_2018oct2202.jpg
simple_intercom_cct_2018oct2202.jpg (166.68 KiB) Viewed 537 times
I am an electronics, smart phone, and smart home hobbyist.

User avatar
tlfong01
Posts: 660
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Detect current on Raspberry pi

Mon Oct 22, 2018 2:14 pm

Salah wrote:
Mon Oct 22, 2018 12:02 pm
Let's say ringing speaker is "speaker1", and the handset speaker is "speaker2".
Currently I can get the signal from the speaker2 with a 3.5mm jack.
My goal is to know when the speaker1 is ringing.
You are suggesting to wire speaker1 to jack 3.5mm on the Pi, and then use python software to monitor audio for ringtone, is that right ? That would require another USB sound stick since I'm already using the one I got for the speaker2.

I am also confused. :? If you want to know when the speaker 1 rings, why not connect the 3.5mm plug to the speaker 1, and forget the other speaker 2?
Attachments
salah_intercom_2018oct2302.jpg
salah_intercom_2018oct2302.jpg (182.45 KiB) Viewed 489 times
I am an electronics, smart phone, and smart home hobbyist.

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Tue Oct 30, 2018 12:24 pm

tlfong01 wrote:
Mon Oct 22, 2018 2:14 pm

I am also confused. :? If you want to know when the speaker 1 rings, why not connect the 3.5mm plug to the speaker 1, and forget the other speaker 2?
The main purpose of this project si to get notified on my smartphone when I'm away and the intercom rings.
I also want to be able to communicate with the person who is downstairs. For that part, I need speaker 2.

Actually I'm having an issue for that part, so I you're willing to help me on that too, I'd really appreciate it.
I'm going to create a separate thread for that.

User avatar
Mortimer
Posts: 901
Joined: Sun Jun 10, 2012 3:57 pm

Re: Detect current on Raspberry pi

Tue Oct 30, 2018 1:10 pm

Wouldn't it be easier to look for the signal that triggers the oscillator circuit driving the ringer speaker, because that will be a simple Voltage level change surely? Much easier to interface to a GPIO.

If not :

I would take the speaker feed, AC couple to a rectifier, and then a simple smoothing circuit (RC network). Some sort of comparator or op-amp circuit to get the logic level required for GPIO.

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Tue Oct 30, 2018 1:16 pm

Mortimer wrote:
Tue Oct 30, 2018 1:10 pm
Wouldn't it be easier to look for the signal that triggers the oscillator circuit driving the ringer speaker, because that will be a simple Voltage level change surely? Much easier to interface to a GPIO.
On the speaker, this is also a simple voltage level change ? What's the difference exactly ?
Mortimer wrote:
Tue Oct 30, 2018 1:10 pm
If not :

I would take the speaker feed, AC couple to a rectifier, and then a simple smoothing circuit (RC network). Some sort of comparator or op-amp circuit to get the logic level required for GPIO.
You completely lost me here :lol:

Idahowalker
Posts: 372
Joined: Wed Jan 03, 2018 5:43 pm

Re: Detect current on Raspberry pi

Tue Oct 30, 2018 3:21 pm

A VOX should work to do the thing.

Put the VOX input next to the speaker, adjust the sensivity, and send the groomed binary signal to the RPi. No need to cut wires.

You can make a VOX, just do a search using your favorite search engine for "audio activated switches circuit' and build one to suit your requirements or one can be bought.

Like this: Image
Without knowing why you are deleting my postings, I will not know how...

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Tue Oct 30, 2018 3:46 pm

Idahowalker wrote:
Tue Oct 30, 2018 3:21 pm
A VOX should work to do the thing.

Put the VOX input next to the speaker, adjust the sensivity, and send the groomed binary signal to the RPi. No need to cut wires.

You can make a VOX, just do a search using your favorite search engine for "audio activated switches circuit' and build one to suit your requirements or one can be bought.

Like this: Image
I had a thought about this but I'm concerned about false detection.
Let's say I accidentally hit the intercom, I might get a false positive.

Idahowalker
Posts: 372
Joined: Wed Jan 03, 2018 5:43 pm

Re: Detect current on Raspberry pi

Tue Oct 30, 2018 4:10 pm

If you mean 'hit' by accidentally enabling the intercom switch, but you did not speak, nothing.

If you accidentally hit the intercom switch and spoke, the same thing would happen if the device was not present.

Which gives me the idea that the power for the device could be supplied by the intercom switch. In that way in the area random conversations would not a source of false triggers.

If you physically hit the intercom, make a loud sound, or some other noise occurs and the push to talk switch is not pressed, which powers or enables the VOX, nothing will come through.

I bought a few of those devices, removed the mics, and used them as amplifiers / competitors to enable a few GPIO pins with a level detected input.
Without knowing why you are deleting my postings, I will not know how...

Salah
Posts: 25
Joined: Mon Jul 09, 2012 12:47 pm

Re: Detect current on Raspberry pi

Tue Oct 30, 2018 11:24 pm

What are you referring as the intercom switch ?

I like you idea of powering the VOX with the intercom to avoid false triggers.
I could wire the VOX directly to the speaker right ? Though I'm not sure that 3.5V would be enough to power it on.

Return to “Beginners”