drotosclerosi
Posts: 4
Joined: Fri Jun 14, 2019 9:17 am

Let's give voice to my robot... Speaker problem

Fri Jun 14, 2019 9:23 am

Hiya people,
I hope this is the right section.
I have a problem that seems complex to me but maybe it is not.
I just assembled a smart car kit with the pi3 b+ that occupy some of the gpio connectors (the 3v one and other three).
I already planned to add an usb microphone, it has a camera and an ultrasonic sensor and now I would like to add a speaker.
Unfortunately all the hats (like phat) needs all of the gpios.
I planned to buy A 3.5mm speaker but it would need too much space and I don't think it would be very powerful. Are there any usb micro speakers or speaker modules which needs only some gpios and don't need an amp?
Image

hippy
Posts: 5375
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Let's give voice to my robot... Speaker problem

Fri Jun 14, 2019 1:46 pm

There are lots of mini speakers which can be broken open to reveal a tiny PCB and speaker which can be used with a 5V supply and plugs straight into the 3.5mm audio jack.

Example, rather than recommendation - https://images.mobilefun.co.uk/graphics ... 0254/1.jpg

User avatar
omegaman477
Posts: 148
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: Let's give voice to my robot... Speaker problem

Fri Jun 14, 2019 1:56 pm

You dont need a hat for basic sound.

So most RPI boards have an Analogue Audio Out via a 3.5mm TRS audio jack, like a PC or Smartphone. Audio needs to be enabled in both firmware and software first, see https://www.raspberrypi.org/documentati ... -config.md

The Audio out is Line level, not speaker level, and will not drive a standard impedance speaker (4-16 ohms) directly. A high impedance piezo speaker may make some noise, but unlikely.

You will need an Amplifier. Discrete and not a hat., like https://www.adafruit.com/product/1552.

This amp will drive anything. I would look for a naked compact speaker driver or element from a mobile phone, tiny but you can drive them hard. I have used this tiny speaker with the Amp i described https://core-electronics.com.au/mini-me ... gIpVfD_BwE
..the only thing worse than a stupid question is a question not asked.

amcdonley
Posts: 154
Joined: Mon Jan 26, 2015 5:56 pm
Location: Florida, USA

Re: Let's give voice to my robot... Speaker problem

Fri Jun 14, 2019 7:23 pm

My current bot first used a "Wired Rechargeable Speaker": https://www.amazon.com/Otimo-Rechargeab ... B01DQ6RE4O
Carl_Charging_After_Marathon.jpg
Carl_Charging_After_Marathon.jpg (27.19 KiB) Viewed 731 times
This was an OK speaker, but a bit of a pain because I needed to recharge it separate from recharging the bot, and I had to get on the floor with the bot to see where to plug the recharging cable into the speaker.

Here is a video with that speaker: Carl's First Words

Currently I am using a single speaker from a "Laptop USB powered Wired Stereo Speaker Set". It draws 40-50mA continuously which took an hour off my robot's play time, but it is ultimately more convenient, more powerful, and very clean audio. Small or light, it is neither.
Carls_Always_On_Speaker.jpg
Carls_Always_On_Speaker.jpg (243.45 KiB) Viewed 731 times
BTW, this are my text-to-speech functions, time of day aware whisper(), say(), shout() https://github.com/slowrunner/Carl/blob ... b/speak.py

drotosclerosi
Posts: 4
Joined: Fri Jun 14, 2019 9:17 am

Re: Let's give voice to my robot... Speaker problem

Fri Jun 14, 2019 11:14 pm

Thank you everybody.

I think I will first try that mini jack speaker, even if needs a recharge.

THe fact is that i'm already in big pain installing opencv for facial recognition so I will (and i mean it) look for other solutions (like the first reply) later.

Disassembling a speaker should be ok also due to the fact that the 5V gpio is free... so why not

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Let's give voice to my robot... Speaker problem

Sat Jun 15, 2019 6:41 am

I usually just use a blue tooth speaker for my RPi sound

hippy
Posts: 5375
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Let's give voice to my robot... Speaker problem

Sat Jun 15, 2019 12:05 pm

omegaman477 wrote:
Fri Jun 14, 2019 1:56 pm
A high impedance piezo speaker may make some noise, but unlikely.
Indeed. It did work when audio PWM is also directed to a GPIO pin and the piezo placed across the pin and 0V was but was extremely quiet.

That should be improved upon by using a MAX 232 type serial buffer, turning 0V/3V3 to +10V/-10V to drive the piezo harder.

amcdonley
Posts: 154
Joined: Mon Jan 26, 2015 5:56 pm
Location: Florida, USA

Re: Installing OpenCV

Sat Jun 15, 2019 12:42 pm

drotosclerosi wrote:
Fri Jun 14, 2019 11:14 pm

THe fact is that i'm already in big pain installing opencv for facial recognition

If you are willing to use Python and not virtual environments:

(From https://www.pyimagesearch.com/2018/09/1 ... ll-opencv/)

sudo apt-get update && sudo apt-get upgrade

sudo apt-get install libhdf5-dev libhdf5-serial-dev libhdf5-100
sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev


wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py


**** OPTION A: INSTALL OpenCV to RPi system (not virtual environments)

sudo pip install opencv-contrib-python

There is a bug in the install package that does not install the opencv data so:

== get opencv/data/ ===
(browse to https://opencv.org/releases, find OpenCV - 3.4.4, click Sources to dnld zip) or
cd ~/Carl/Examples/OpenCV/
wget https://github.com/opencv/opencv/archive/3.4.4.zip
unzip *.zip

data is in ~/Carl/Examples/OpenCV/opencv-3.4.4/data

My face reco in image and in pycam: https://github.com/slowrunner/Carl/tree ... enCV/Faces

drotosclerosi
Posts: 4
Joined: Fri Jun 14, 2019 9:17 am

Re: Installing OpenCV

Mon Jun 17, 2019 11:28 am

amcdonley wrote:
Sat Jun 15, 2019 12:42 pm
drotosclerosi wrote:
Fri Jun 14, 2019 11:14 pm

THe fact is that i'm already in big pain installing opencv for facial recognition

If you are willing to use Python and not virtual environments:

(From https://www.pyimagesearch.com/2018/09/1 ... ll-opencv/)

sudo apt-get update && sudo apt-get upgrade

sudo apt-get install libhdf5-dev libhdf5-serial-dev libhdf5-100
sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev


wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py


**** OPTION A: INSTALL OpenCV to RPi system (not virtual environments)

sudo pip install opencv-contrib-python

There is a bug in the install package that does not install the opencv data so:

== get opencv/data/ ===
(browse to https://opencv.org/releases, find OpenCV - 3.4.4, click Sources to dnld zip) or
cd ~/Carl/Examples/OpenCV/
wget https://github.com/opencv/opencv/archive/3.4.4.zip
unzip *.zip

data is in ~/Carl/Examples/OpenCV/opencv-3.4.4/data

My face reco in image and in pycam: https://github.com/slowrunner/Carl/tree ... enCV/Faces
I ended up doing that with OpenCV 4 following a tutorial and managed to install.
I haven't tried any recognition, also because I think it will go like 1-2 fps on the barebone raspberry pi 3 b+, but i'll try it later when i'll get the intel compute stick v2
hippy wrote:
Sat Jun 15, 2019 12:05 pm
omegaman477 wrote:
Fri Jun 14, 2019 1:56 pm
A high impedance piezo speaker may make some noise, but unlikely.
Indeed. It did work when audio PWM is also directed to a GPIO pin and the piezo placed across the pin and 0V was but was extremely quiet.

That should be improved upon by using a MAX 232 type serial buffer, turning 0V/3V3 to +10V/-10V to drive the piezo harder.
I would like to understand more of this.
I'm not very practical with connecting a piezo speaker to the raspberry, what should I do to do that? Just buy a piezo speaker w/ 32ohm and connect the gpios with some kind of tutorial?

hippy
Posts: 5375
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Installing OpenCV

Mon Jun 17, 2019 1:03 pm

drotosclerosi wrote:
Mon Jun 17, 2019 11:28 am
Just buy a piezo speaker w/ 32ohm and connect the gpios
No; don't do that or you'll burn out the GPIO pin.

You either need to use a high impedance piezo to limit current drawn, which means it will be quiet. Or you need an amplifier which allows more current through that piezo which makes it louder.

Most typical means of putting a voltage through a piezo will limit the output voltage to the power supply rails, 5V or 3V3.

An RS232 serial driver will typically convert an input signal to +/-10V, effectively boosting the 3V3 input to a 20V output.

drotosclerosi
Posts: 4
Joined: Fri Jun 14, 2019 9:17 am

Re: Let's give voice to my robot... Speaker problem

Wed Jun 19, 2019 2:29 pm

So i bought this little speaker.
https://www.amazon.it/gp/product/B01MZ1 ... UTF8&psc=1

It should be ok, it's very small.

I'm just worried about the weight: could a 42grams speaker connected to the 3.5 mm jack damage it in any way?

I have no support to place it on.

amcdonley
Posts: 154
Joined: Mon Jan 26, 2015 5:56 pm
Location: Florida, USA

Re: Let's give voice to my robot... Speaker problem

Thu Jun 20, 2019 5:46 pm

drotosclerosi wrote:
Wed Jun 19, 2019 2:29 pm
So i bought this little speaker

I'm just worried about the weight: could a 42grams speaker connected to the 3.5 mm jack damage it in any way?
Use a short extension cable and velcro the speaker to your bot.

Return to “Automation, sensing and robotics”