BennyP’s Light Contraption using arduino
Disclaimer: I am not an expert in any of this. There is lots of information online regarding such designs. Although this setup worked for me, do not trust any of my calculations. Please work all this out for yourself and consult many other sources, or it may spontaneously burst into flames.
The contraption is a board containing two lights and a receptacle that are controlled by a computer communicating with the Arduino microcontroller. The project grew out of a desire to learn more about microcontroller programming and some circuit design, something I had never really done before.
Below is a video of the contraption in action. In the video, I control the two light bulbs, as well as a blender, from my computer. (Note: the video does not have sound)
Principle & Hardware
The hardware was laid out on a plain wood board as shown in the photos below.
Note that all power is actually flowing through the breadboard. This is probably not a very good idea, but as we are dealing with only an amp or two at most, I thought it might be satisfactory. I’ve included both an on/off switch, and a 5A circuit breaker for safety.
The schematic below shows the main circuit used in controlling the power to the lights and the receptacle. This circuit is nearly identical to that found in the MOC3022M datasheet.
The main principle is as follows:
- The opto-isolating triac (MOC3022M) receives an input from an Arduino output pin.
- This allows bi-directional voltage on the triac side (pins 6 and 4). This voltage comes from the mains through 180Ω resistor R2 and to the gate pin on the triac T1.
- This voltage turns on the BTB08 triac (T1) through its gate pin. This allows conduction through the triac and through the load.
A few notes and equations:
- The BTB08 triac chosen is ‘snubberless’. It therefore may not be necessary to include a snubber circuit for inductive loads. I didn’t include one, and as seen in the video, it seems to work ok for the blender motor.
- The Arduino output (Vcc) is 5V. Therefore, the max current through the left side of the MOC3022M is 5V/390Ω = 12.8mA
- The peak voltage of the AC Mains is approximately 170V. Therefore, current through the right side of the MOC3022M is limited to 170V/180Ω = 0.94A. This is just under the maximum of 1A listed in the data sheet
- The triac T1 is always operating in quadrants I or III.
If no voltage is applied to the left side of the MOC3022M, the mains current flow through the T1 triac will stop when the mains voltage reaches the zero-point crossing. The solution is to leave the Arduino output on, which works only if you want the mains circuit completely on. However, for dimming, you must know when the zero cross occurs.
This circuit allows an Arduino input pin to register when the AC mains voltage is in the positive half-wave.
- The negative half-wave is removed by the diode. Therefore, the RMS voltage is 60V
- The four resistors have an equivalent resistance of 10kΩ. Therefore, the RMS current is 60V/10kΩ = 6mA. The reason for several resistors is to reduce the power at each resistor. The voltage across each resistor is 30V, therefore the power dissipation is (30V)(30V)/10kΩ = 90mW
Note that detection by the Arduino of the start of the positive half of the sine wave is delayed, and the detection of the end is too early. Below is an exaggerated diagram.
For more detail: BennyP’s Light Contraption
We recommend EasyEDA for electronic circuit design.
From Schematic Drawing to PCB Production, Just Need One Tool
Cheap PCB Prototype: 10 pcs 2 layers only $10, quick delivery, 100% E-test