Ac dimming


I’m trying to connect an AC dImming circuit to the electric imp.

I notice the wiki says “Please don’t try yet. Waiting for SW fix.” for the IO Example 2 - AC Light Dimmer. Is that the current state of things?

I verified that I am able to set the brightness level through the web API, but I am not getting any activity out. My circuit works fine with the arduino.



You should get activity out; the issue with the “don’t try yet” is that the imp.sleep, if it’s above 20ms, it’ll flush system buffers first (which would cause jitter).

If you’re doing a 60Hz dimmer, then your max period will be 16ms so it should just work.

Good to hear. I’m trying to chase this down.

I am able turn the bulb on and off with the blink-o-matic code and my output circuit (e.g. the imp drives the triac). Also, I see my zero-cross detector is firing as expected on the imp input (0 and 3.3V at 120 Hz). I’m not having any luck with the actual dimming.

I wonder if maybe I need to redesign my circuit to sink less power on the zero-cross input or use an additional transistor on the triac output. I see the imp pins can sink/source 4mA max…

By my calculations it looks like the imp will be sinking 0.21mA on the zero-cross input when my signal is high ((3.3VCC-1.2V forward voltage)/10K ). And it will be sourcing 2.2 mA on the triac output ((3.3V-1.2)/1K). Both should be fine.

If it was underpowered on the output I wouldn’t expect the circuit to work with the “on/off” blink-o-matic code. So I’m thinking the zero-cross input is the problem maybe…

Thanks for any help! It would be great to look at your dimmer design if you don’t mind.

The code wasn’t written for any specific dimmer; it’s not been tried on actual hardware as far as I’m aware, so nothing to show you there.

If you hook the triac control output to an LED, do you see dimming? (ie, the LED is being driven on and off)

I have a LED hooked up in parallel to the triac control and I don’t see dimming.

I forgot about that in my current calcs above: it’s in parallel to the triac and pulling 4.4mA I think.

With the blink-o-matic code I do see that LED turning on and off.

Which makes me think there is some problem with the zero cross signal or event routine.

The triac may clamp the line and prevent the LED from reaching its Vf? Can you try with the triac disconnected and just the LED in the circuit?

You said that you were seeing 120 zero-cross events per second which sounds right.

Thanks for the suggestion. I’m away from town until next Wed but will try this out when I return.

I got it working.

I either have a problem with my breakout board soldering or I’ve burned out a pin on my imp. I’m not able to use pin 1 as an input or output. This was preventing the circuit from working.

With pin2 for my zero cross input the dimmer works fine. When I disconnect the optocoupler I see the LED fade.

Now I need to redesign my circuit with a lower-power optocoupler: the MOC3020 I have been using to drive the triac expects 15mA typically for the trigger current, which the imp can’t do. I’m thinking of using the MOC3023 which has a much lower trigger current (5mA max).

Thanks for your help Hugo.

Hi~I also try to use same circuit.
One thing I wonder if I use 50Hz for imp’s sleep timer it make jitter?
And I want to fade out AC light. is it possible?


There’s an AC dimming API coming very shortly, which gives hardware support for this.