Homemade dimmers for home automation systems

Published on February 27, 2018

Homemade dimmers for home automation systems

Hello to all! This article is about how to build and apply dimmers for lighting control. The schemes are the simplest. Designed for mains 220 volts AC, control - analog signal 0-5 volts (arduino) or 0-3.3 volts (esp8266).



1. Dimmer for incandescent lamp, transistor:

Circuit:



Composition:

Q1 - IGBT transistor IRG4BC30UD (radiator is required)
D1 - rectifier diode
D2 - diode bridge
Z 10V - diode of zener at 10 volt
4N25 - optocoupler
R 100K and R 10K - resistors
C 4.7 - capacitor

Principle of operation: amplification of a pwm signal with an arduino transistor.

Work example:


2. Dimmer on a triac, suitable for incandescent lamps and LED dimmable lamps:

Scheme:



Composition:

BT 139 - triac
MOC 3021 and 4N25 - optocouplers
R300, R10K, R50K - resistors

Principle of operation: INT0 - input to arduino (pin2) set to interrupt , it receives a signal of phase transition through zero (zero detector).
OUT is the output from the arduine (pin3) from which, through a delay, a signal arrives at the triac.

The dimming parameter is set via the serial port (0-255 #)
Example: 99 #

Program for arduino UNO
//#include <EEPROM.h>
int dimming=100,ac_dimm;
char incomB='0';
String openhab="";
void setup()
{
	Serial.begin(9600);
	Serial.println("Setup...");
	pinMode(3,OUTPUT);                        // Set AC Dimmer
	delay(1000);
	Serial.println("Start 0-255#");
	attachInterrupt(0, start_dimming, RISING); //pin 2
	myPrint();
}
void loop()
{
	myIncoming();
}
void myIncoming()
{
	if(Serial.available()>0)
	{
		incomB=Serial.read();
		if(incomB=='\n' || incomB=='#')
		{
			if(openhab.toInt()>=0 && openhab.toInt()<256)
			{
				dimming=openhab.toInt();
			}
			openhab="";
			myPrint();
		}
		else
			openhab+=incomB;
	}
}
void start_dimming()
{
	if(dimming>ac_dimm)
		ac_dimm++;
	if(dimming<ac_dimm)
		ac_dimm--;
	if(ac_dimm>1)
	{
		delayMicroseconds(999);
		delayMicroseconds(31*(256-ac_dimm));
		digitalWrite(3, HIGH);
		delayMicroseconds(20);
		digitalWrite(3, LOW);
		//Serial.println("test");
	}
}
void myPrint()
{
	Serial.print("dimming = ");
	Serial.println(dimming);
}


For more stable operation (for example, false interrupt signals), it is desirable to add an RC filter.

That's all, thank you for your attention, be careful with electricity.

After another scheme
Triac - contactless relay