ATtiny85 as mode memory for switching light bulbs

I have a few light bulbs with mode memory, that can switch to different scenes (bright/medium/dim) using the wall switch. I like this, because there’s no fiddling with remotes or wireless setups, it just always works.

I want to install red LED lights in my room and switch to those at night. However, there are no light bulbs with mode memory that can switch between white and red – those only exist as “smart” bulbs and usually with RGB. I don’t want “smart”.

My large light fixture has space for many light bulbs. I’m thinking about making my own E27 splitter/socket with mode memory, so I can install a regular white bulb and a regular red bulb and switch between them from the wall switch.

Idea: use an ATtiny85 microcontroller, a two channel SSR board for switching the E27 sockets, and a little 5V power supply. Maybe use a capacitor to measure on startup how long ago the thing was switch off, and decide whether to alternate output or stick with mode memory based off that.

Could even add an RTC and switch automatically at set times. But at that point, I might as well use an ESP32. And then use 2ch triac dimmer module so I can automatically dim, too.

To be continued.

Automatic power off circuit for active speaker

Thinking about ways to automatically turn off the PSU of an active speaker. I have two options on my mind:

  1. Locally switching PSU, with a floating input detection circuit
  2. Remotely switching PSU, with a power signal line from audio source

Option 1 has the advantage that if it’s not connected to anything, the speaker will turn itself off. Also, no remote power signal is needed, so it can be connected with just a mono jack. However, to switch it off remotely, the source has to disconnect its output. An audio signal detection circuit would prevent the need for that, but I don’t like to turn off the amplifier when there is no signal e.g. between songs. This option needs a little battery to keep the detection circuit powered.

Option 2 has the advantage of being a little simpler, especially on the amplifier side. There is also no need for a battery. It does however need a stereo jack. Disconnecting input turns on the PSU, but I guess a simple “on/remote/off” power switch next to the jack could solve that.

1. Locally switching PSU, with a floating input detection circuit

Idea is to inject a miniscule DC sense signal (e.g. 4V through a 1MΩ inject resistor) onto the amplifier input, and use a comparator to measure impedance. If impedance is very high (input is floating so voltage is high, especially if amplifier has a coupling capacitor), keep PSU off, if impedance is lower (input connected so voltage is low), turn on PSU.

To prevent audio signals turning off the PSU, filter out the AC at the comparator (e.g. low pass using 1MΩ sense resistor plus 1µF capacitor). I doubt 4V DC at ~4µA would do anything to the source output so I don’t think I need coupling capacitors there.

Comparator would power an SSR that turns on/off the PSU. To power the sense signal and comparator as well as SSR, use a small Li-Ion battery. Float the battery from PSU using an isolated buck converter when powered on. Preferably use a protected battery. If I stay under 100µA, a 2000mAh 18650 could last over 2 years without power. Unfortunately, the most widely available comparator (LM393) draws closer to 400µA which brings battery life down a bit. Could run it with a timer and latch circuit to bring down average current to maybe 100µA, but that seems like a lot of work. Either get a lower power comparator, or just use a protected cell and accept that once every couple of months the amplifier needs to be turned on.

Would have to figure out how to drive the SSR module directly from the comparator without much current draw in off state.

To remotely switch off from the source, the source would need to lift its outputs. Putting anything in the signal path introduces noise, but something like a TS5A23157 analogue switch module with relatively low R_on and very low distortion should be inaudible.

Parts list:

  • 18650 protected cell
  • isolated buck converter set to battery float voltage + output diode
  • LM393 comparator module (plus SSR drive circuit)
  • SSR module
  • 1MΩ Resistors and 1µF capacitor
  • TS5A23157 module for source

2. Remotely switching PSU, with a power signal line from audio source

Use a stereo jack cable; TRS with control signal on the ring. 5V turns the active speaker off, 0V turns it on. In active speaker, use 5V NC SSR board in two modes:

  1. Off / Control = 5 V:
    Power the SSR board directly from the 5 V signal line. Current draw is negligible (few µA or less, just leakage).
  2. On / Control = 0 V:
    Signal line can’t supply 5 V any more. Instead, power the board from a small 42 V→5 V DC converter.

Buck converter must be isolated to prevent ground loop, and use Schottky diodes to prevent backfeeding into the control signal line. Use a capacitor by the SSR large enough to bridge the gap between powering on PSU and buck converter giving 5V.

There should never be 5V and signal at the same time through the wire, so no added noise expected as long as 0V is really 0V. I guess I can use an optocoupler, another isolated 5V buck converter and a pulldown resistor to audio gnd, to prevent injecting noise onto 0V. To prevent damage from DC with wrong connection, limit 5V output to just enough current to keep the SSR board powered.

Alternatively, directly inject 5V DC control signal onto audio signal. This allows using a mono jack cable instead, and again, audio and 5V should never be on the line at the same time. However, this would require filtering out AC at the SSR, and DC at both the amplifier and the source, and might be more difficult to prevent ground loops and noise. Also, higher chance of damage if connecting a different amplifier. Separate wire seems like a much better idea.

Reflection, issues

Option 1 seems elegant but very sensitive, e.g. to floating ground and false triggering. Switching module at source will likely add pops/noise when turning off amp.

Option 2 seems more robust, but need to think about wiring. For instance, can the source handle connecting a mono cable, shorting the 5V to gnd? I guess with good current limiting, that shouldn’t be a problem.

Ultimately, both options seem like a lot of work and can potentially introduce noise, without solving any real problems. Is it really so bad to have to get up and control a physical on/off switch, instead of a software one?

Quieting LED dimmers, done for now

I managed to fit the small inductor into the other dimmer. It fits, but only just.

Please don’t look at my shoddy soldering job. Also, I did tape it up to be safer.

This definitely lessened the chopping noise from my speakers, but unlike with the other dimmer, the noise is not gone entirely. I guess it’s because I tested the specific inductor with the other dimmer and lights, and because this dimmer runs right next to the amplifier.

Still, the noise is much less than before and only noticeable because I know it’s there, and even then I can only hear it when I turn the volume way down. I might revisit this in the future, but for now, problem solved :)

Quieting LED dimmers, first success

I dug out my box of random inductors and tried to quieten one of the LED dimmers today. Contrary to what I thought in my previous post, the coils actually worked best when installed in series between the dimmer and the LED load. Almost all the inductors I tried helped quieten the chopping noise heard on my headphone amp. One interestingly completely stopped the noise when dimmed at 0%/50%/100%, but was still slightly audible at the in-between settings:

Two of the inductors were able to completely remove the noise. This one, and a very similar looking one:

Yay, I can listen to my headphones and dim my lights at the same time now! I love simple solutions :)

The other inductor that removed all the noise looks very similar but it’s slightly smaller. I might actually be able to fit it into the other dimmer module, to solve the noise on my speaker amp.

LED dimmer noise

My cheap AliExpress LED dimmers are noisy. Not audibly, but they output a lot of EMI (?).

One of my (triac?) dimmers has multiple Philips bulbs on it. When I turn it on, I can hear a loud chopping noise on my headphone amp.

Another dimmer is in the same socket as the amplifier for my speakers, and the cables run closely parallel to each other. When I use this dimmer, I can hear the same chopping noise on my speakers, and at a little lower volume I can hear it on my headphones too.

I’m thinking of modifying the dimmers by adding a coil to them. I’ve never used them before but I have a big box of de-soldered ones from when I first got a soldering iron and liked to disassemble things.

What I need, short of getting better dimmers, is probably a lamp debuzzing coil in series. There might not be enough space in the little dimmer modules to add an inductor, though. The dimmer running to multiple bulbs already has a junction box that I can put it in, so I can experiment with that one first. The coil should go on the load side (or at least not between the dimmer and the load).

I have no idea how to calculate the ideal inductance value, and I probably can’t even measure the inductance of the ones I have, so I should just experiment with a few different ones to see which solve the problem without affecting the dimming.