Hi All,
as some of you already know, Paul_123 from the tinycore forum has
adapted his modifications for the control GPIOs from squeezelite to the
'ffmpeg' ralphy squeezelite version used in piCoreplayer.
These modifications allowed you to :
- activate or deactivate a GPIO when the power on/off button is
activated for a specific player on LMS. This is done with the
- run a user script when the power on/off button is activated for a
specific player on LMS
The changes to squeezelite were then pushed to Ralphy's github repo in
both the 'basic' and 'ffmpeg' version of squeezelite. Now, piCoreplayer
users just need to update their sqeezelite version from the piCoreplayer
user interface to be allowed to control GPIOs from squeezelite. This
means you could conrol the power of your speakers from LMS.
Since I think this is a really neat feature, I've made a short
walkthrough to help anyone who might be trying to use this feature.
- *Setting up piCorePlayer*
As I mentioned, the first step if to make sure you have the latest
version of squeezelite installed from ralphy's repo. This can be done
directly from the main page of picoreplayer. You should have a version
greater than v1.8.2-708 for the GPIO control to be included
The second step is to go to the squeelite settings tab, and edit the
Various input line. This line is only visible in normal, advanced, or
beta mode.
If you want to just control one GPIO, enter the following
Code:
--------------------
-G 18
--------------------
This will control GPIO 18 for example. Note that you can only control
one GPIO at a time with this method.
If you want to do more advanced things, you can choose to call a
script. Assuming that the executable script is located at
Code:
--------------------
/home/tc/relay.sh
--------------------
then enter under Varipus input
Code:
--------------------
-S /home/tc/relay.sh
--------------------
I have included two scripts on this page
https://git.luzzato.com/charles.luzzato/piCorePlayer. More on this in
the examples from the section below. Suffice t say that the script is
called with argument 2 to initialize the GPIO, argument 0 to turn off
the GPIO and argument 1 to turn on the GPIO.
The script will need to be backed up to the piCorePlayer persistent
files to be conserved through a reboot. This is done by adding the
filepath for your script (without the leading / ) to the file
Code:
--------------------
/opt/.filetool.lst
--------------------
and then running
Code:
--------------------
sudo filetool.sh -b
--------------------
t osave the persistent files
- *Controlling your speakers*
I'll consider two types of speakers that you want to control:
- Speakers with a switch
These are speakers that you turn on by flipping a switch. As long as
the switch remains flipped, the speaker will be on as long as there
is current flowing to it. I'll take the example of the JBL LSR305
speakers reviewed here http://noaudiophile.com/JBL_LSR305/ . To
control those speakers from a GPIO, all you need to do it build a
relay, which will let mains current through, or open the mains
circuit, based on he GPIO signal. This is very simple, and the only
part that you need to buy is an optocoupler relay (maybe something
like this
http://www.ebay.de/itm/5V-2-Channel-Relay-Module-2-Kanal-Relais-Modul-5V-With-OPTOCOUPLER-Protection-/171269263396?hash=item27e0719024:g:RlUAAOSwajVUSDeT)
. Please make sure that the relay can be activated with a 3.3v
signal (which comes from the pi's GPIO) and powered by a 5V or 3.3v
input.
Using some power extension leads I built a small box and packaged
everything nicely to yield something like this
20072
20073
Each one of the 2 JBL LSR305 is powered separately, so I have two
female plugs coming off of the relay, with one GPIO controlling the
power for each plug. I use this script
https://git.luzzato.com/charles.luzzato/piCorePlayer/blob/master/relay.two_out.sh
with GPIOs 14 and 15. Its probably worth mentioning that this is
best done when the speaker you ae controlling by GPIO has an
internal timer or soft start, to avoid getting pops and crackles
when the GPIO switches to on. This is the case with the JBL LSR305.
- Speakers with a contact button
These are speakers which are turned on with a contact button.
Circuitry inside the speaker detects when the button is pressed for
a short amount of time, and turns on the speaker. This is the case
with the Sony SRS-BTM8 for example.
Powering these speakers with GPIO is a bit more complex, and
requires opening up the speaker itself. In the case of the Sonys, I
was able to figure out quite easily what pins from the ribbon
connector went to the on/off contact button.
20074
From there, it was just a question of soldering 2 cables on the
ON/OFF button pins, which would effectively allow me to connect a
GPIO controlled relay in parallel with the ON/OFF button, as showed
below.
20075
I used the script
https://git.luzzato.com/charles.luzzato/piCorePlayer/blob/master/relay.in_out.sh
which simulates the script being pressed for 0.5 seconds each time
the LMS player is swicthed on or off.
The obvious problem with this, is that you are never sure what state
your player is in (if for example a user decided to turn on the
player manually by pressing the physical on/off button, and then
turned on the player in LMS, the on/off button would be activated
for 0.5s by the script and promptly turn the player off.
As you can see from the script, I tried to build a second circuit to
detect if the player was on from (GPIO 17 acts as an input). This
second optocoupler circuit (described here
https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=31570) would
feed off the powers status led of the speaker, t tell the GPIO 17
whether the speaker was on or off.
The device never worked as the current from the 2.2v green led of
the speaker was never enough to activate the infrared led of the
optocoupler. If anyone is better in electronics than me and has any
ideas on how to solve this, I'm all ears. Nevertheless, up until
now, I've been able to control the speaker through GPIO successfully
without knowing its state.
Hopefully this will be useful for anyone else attempting this kind of
thing.
+-------------------------------------------------------------------+
|Filename: _2130001.jpg |
|Download: http://forums.slimdevices.com/attachment.php?attachmentid=20076|
+-------------------------------------------------------------------+
------------------------------------------------------------------------
Chluz's Profile: http://forums.slimdevices.com/member.php?userid=63178
View this thread: http://forums.slimdevices.com/showthread.php?t=105018
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix