Smartthings Cree PCM integrated Audio Volume Control


(steve) #1

For some time I’ve been researching a unique way to integrate a “line level” volume control into my ST system. I’ve seen a few other posts on this and other forums with people looking to do the same so I guess it’s time to get this discussion started.

My current challenge is that I have a device that switches audio from different sources (TV, Sonos, etc.) and I want to be able to control/automate the volume of that line level output with ST.

Currently I can adjust the volume on my amps with my Harmony hub or if I choose I can rewire and use the Sonos line in feature but those options though functional are not ideal.

What I’m shooting for is a solution that gives me the ability to automate my audio volume to set percentages, similar to how the bulb dimmer sliders work.

I think using the PCM from the Cree Connected board may be the best solution.

One solution I’m considering is using the PCM output on the Cree to drive a servo or stepper attached to an ALPS potentiometer preamp kit readily available on ebay.

The challenge with this servo/stepper option doesn’t seem overly complicated other than calibrating the servo to operate in the same range as the ALPS pot which is “code wise” beyond the scope of my expertise without help.

The other and preferable solution involves using the PCM to control an LDR attenuator circuit similar to this… http://diyaudioprojects.com/Solid/DIY-Lightspeed-Passive-Attenuator/

With the LDR attenuator, if using the circuit described in the link, the section using the 100k dual pot would be replaced with something that performs it’s same function only controlled by the PCM output of the Cree board. Technically I suppose this pot could be controlled via servo but it sounds more fun to do it without the mechanical parts.

Anyway I would be interested in hearing other ideas or input on these if anyone else has a similar challenge.


(Ben Lebson) #2

One thing to keep in mind is that the Cree analog channel is pretty noisy. In order to get an accurate reading I needed to read the analog pin three times and then average the reading and then read it another three times and average those three. If the two values were the same then I would output that value. It can cause a 1-3 second lag on the command.


(steve) #3

Wow that’s good to know thanks. I just barely tore one of the bulbs apart to mess around with it.


(Ben Lebson) #4

One thing I forgot to mention, I was taking the reading 3 times and converting it into my preferred value range. I also had to take measurements for 0%, 1%, 99% and 100% in order to get the true raw range of the analog output.


(steve) #5

Just out of curiosity what are you using it for and how are you converting it?


(Ben Lebson) #6

I was attempting to use it to control some motorized blinds. I had it hooked up to an Arduino Nano for reading the input. Unfortunately it uses way too much power when idle to run off batteries so I eventually ditched it.


(Dan) #7

@zjoozy

Steve,

I assume you’re considering using the Zigbee board inside a Cree Conencted bulb, correct? If so, you may find an old proof of concept project I did a few years back interesting. It might be a decent starting point for your project.

Additionally, these days most folks are preferring to use inexpensive NodeMCU ESP8266 boards (~$9 on Amazon) for connected custom projects. You could very easily look into using my ST_Anything project which supports a variety of sensors and devices.


(steve) #8

Yes I was planning on using the board from the Cree Connected and have one pulled out. I don’t have to go this route if there is another way. Just glancing at the architecture flow chart from the ST_Anything post, I would use the ESP8266 in place of the cree to handle the communication with ST, is that correct?


(Dan) #9

Correct. You could just use an NodeMCU ESP8266 to handle everything. Your use-case is a bit unique, so you’re probably in for some coding to get things working as desired. ST_Anything is really designed for implementing Standard SmartThings Capabilities (http://docs.smartthings.com/en/latest/capabilities-reference.html). As you mentioned, a dimmer switch is probably the closest ST Capability to a volume control.

You could also just use my “SmartThings” library (which is used by “ST_Anything” as well) which provides all network communications between the ST Cloud and the NodeMCU ESP8266 board. You could build a custom solution that implemented different “scenes” which would in turn adjust the volume as necessary. Perhaps you could create a bunch of Child Switch devices which each represented a scene. Then ST could turn on any one of these switches (scenes), which could cause any other active switch (scene) to turn off. When any switch is activated on the ESP8266, you could perform whatever action you desire.

I just thought of another idea… Why not simply measure the LINE Level voltage and automatically adjust it to maintain a constant average output signal using whatever attenuator you desire? This would not require ST at all. I would probably do this by reading in either the LEFT or RIGHT audio signal on a high impedance analog input I/O point for a reasonably long period of time to get a decent average value. Then I’d implement a simple feedback controller to compare the input against your target, and then adjust the output. You could even use a simple PID Control Loop. The one issue would be during quiet or very loud portions of the audio signal. You don’t want to flatten the volume, just shift it…

Sounds like an interesting project!


(steve) #10

Thanks for the info. Interesting stuff with the PID Control Loop idea, I had to look that up. This will be my first Arduino project so I’m in over my head since that portion is going to be new for me but it’s time I take the leap I think. I like the idea of using the ESP8266 for the project. Though it seems like overkill as just a way have control over volume but I guess the cree board was too.