1

I am using an AC dimmer module to dim a 240V light. I would like to use node.js so I am using the pigpio module.

The script is not working as expected as the light bulb goes straight to 100% when I execute the node.js script.

The AC dimmer module is http://www.inmojo.com/store/krida-electronics/item/ac-led-light-dimmer-module-with-heatsink/

Module's Pins:

+5V -> device power, DC 5 volts 
SYNC -> zero-cross detector output positive impulse (pulse length 200us) 
GATE -> triac gate input pin 
GND -> ground of low voltage side 

I have connected Module's VCC, GND and Gate pins to raspberry's +5, GND pin 18 respectively.

enter image description here (the wiring is actually done with a Raspberry Pi 3, ignore the Arduino board in the wiring diagram above)

My code:

var Gpio = require('pigpio').Gpio,
  led = new Gpio(18, {mode: Gpio.OUTPUT}),
  dutyCycle = 0;


led.pwmWrite(dutyCycle);

setInterval(function () {
  led.pwmWrite(dutyCycle);

  dutyCycle += 1;
  if (dutyCycle > 255) {
    dutyCycle = 0;
  }
}, 20);

I have also tried with the led.hardwarePwmWrite() method, but I am a bit confused as to how this can be used.

Is there anything that can be fixed in my wiring, the above code or by implementing hardwarePwmWrite()?

  • Do you have any reason to believe this works with 3.3V logic? I don't see any on the page you linked. I also suspect there is something missing from your code as you seem to be varying a duty cycle but did not set a pulse width (unless there is a default you are relying on). – goldilocks Oct 29 '16 at 15:20
  • What are you doing with the SYNC line? – goldilocks Oct 29 '16 at 15:24
  • @goldilocks I have updated the question adding information about the pins. The SYNC line is not connected to anything: in the module's producer Arduino example code they are only using the Gate line. – Martin Oct 29 '16 at 15:59
  • 1
    If you have a screen attached to the Pi use piscope to check for GPIO activity. GPIO 18 should be toggling regardless of whether 3.3V is seen as high. – joan Oct 29 '16 at 16:12
  • 1
    You're also almost definitely going to need to use the sync line - pwm is basically pointless in this situation because once a triac switches on, it will remain on until the AC zero crossing point. At which point you use the sync to schedule a delay of a percentage of the wave before turning it on again. What you're wanting to be doing is something called trailing edge dimming. – calcinai Oct 29 '16 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.