Wireless AC Light Dimming Using Arduino

0
670

We have AC loads all around us. And the majority of household appliances are powered by alternating current (AC). There are numerous situations in which we want complete control over an AC load, such as dimming a lamp, controlling the speed of an AC motor/fan, controlling a vacuum cleaner, and many other applications. The proper method for dimming 230v AC is to use phase control with a Triac: the Triac is then fully opened, but only during a portion of the sinus AC wave. However, controlling an AC load is more difficult than controlling a DC load. The electronic circuit for each of these applications is unique. The frequency of the alternating current mains with a sinusoidal wave is 50Hz. The zero-crossing points (the points where the wave changes polarity) are critical when building an AC dimmer. To detect these points, we must first construct a zero-crossing detector. Similarly, we must control the waveform’s phase and cycle. Because every component can not withstand 220V AC, we must isolate the circuit from 220V AC using another component.

Materials List

The following are the components needed to complete the AC Dimmer Project. Eagle Electronics sells all of the necessary components.

 

S.N. COMPONENTS NAME QUANTITY                SHOPPING
1 Arduino UNO 1  https://eagleelectronicsonline.com/index.php?route=product/product&product_id=85
2 AC Dimmer Module 1  https://eagleelectronicsonline.com/index.php?route=product/product&product_id=492
3 HC-05 Bluetooth Module 1  https://eagleelectronicsonline.com/index.php?route=product/product&product_id=123
4 12V Arduino Power Supply  https://eagleelectronicsonline.com/index.php?route=product/product&product_id=50
5 AC Bulb 1
6 Female To Female Jumper Wires 8  https://eagleelectronicsonline.com/index.php?route=product/product&product_id=379


Hardware Connections

Arduino Hardware Connections
       AC Dimmer Module         Arduino Pin
5V 5V
GND GND
PWM 3
Z-C 2
HC05 BLUETOOTH MODULE  
VCC 5V
GND GND
TXD 0
RXD 1

 

AC Dimmer Module & Bulb Connections

       AC Dimmer Module Pin         Connections
N Input 230V AC Neutral
L Input 230V AC Phase
N Connect Bulb Neutral
L Connect Bulb Phase

 

Downloads

Program/Source Code

#include <SoftwareSerial.h>
#include <TimerOne.h>           
volatile int i=0;               // Variable to use as a counter
volatile boolean zero_cross=0;  
int AC_pin = 3;                // Output to Opto Triac
int POT_pin = A3;             // Pot for testing the dimming
int led = 13;                    // LED for testing
int dim = 0;                    // Dimming level (0-128)  0 = on, 128 = 0ff
long ch = 0;
int freqStep = 75;    // This is the delay-per-brightness step in microseconds.
void setup()
{                                      // Begin setup
Serial.begin(9600);
Serial.setTimeout(10);
pinMode(AC_pin, OUTPUT);                          // Set the Triac pin as output
pinMode(led, OUTPUT);                             // Set the LED pin as output
attachInterrupt(0, zero_cross_detect, RISING);   // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
Timer1.attachInterrupt(dim_check, freqStep);
}
void zero_cross_detect()
{
zero_cross = true;               // set the boolean to true to tell our dimming function that a zero cross has occured
i=0;
digitalWrite(AC_pin, LOW);
}
// Turn on the TRIAC at the appropriate time
void dim_check() {
if(zero_cross == true) {
if(i>=dim) {
digitalWrite(AC_pin, HIGH);  // turn on light
i=0;  // reset time step counter
zero_cross=false;    // reset zero cross detection
}
else {
i++;  // increment time step counter
}
}
}
void loop()
{
// dim = analogRead(POT_pin) / 8;  // read dimmer value from potentiometer
// analogWrite(LED, dim);  // write dimmer value to the LED, for debugging
while(Serial.available())
{
ch = Serial.parseInt();
dim = ch;
dim = 128 - dim;
analogWrite(led ,dim);
}
}

 Project Video

LEAVE A REPLY

Please enter your comment!
Please enter your name here