DONOFF iot light dimmer

Placed on

Build a DONOFF device

Warning:
any circuit that works with mains voltages is inherently dangerous and you should NEVER work with mains voltages unless you know exactly what you are doing. The DONOFF circuit is purely theoretical and offers no isolation or safety functions! Therefore, without modification, it is not a safe circuit, or has practical applications beyond serving as a proof-of-concept.

DONOFF dimmer PCB

If you're still reading this, I have one more warning: whatever you do, don't build this circuit on a breadboard! You can build it on an experiment board (use a board with through-plated pads) and make sure you have good soldering.

By far the best way is to use a specially designed printed circuit board (PCB) as shown below.
The circuit board is designed using KiCad 5.0. I had a first series made by PCBWay. The standard copper layer used by PCBWay is 1 oz/ft2 and according to the Online Trace Width Calculator the trace width for the High Power (HP) traces should then be about 2mm.

Bill Of Material (BOM)


#ElementDescriptionPrice
1DONOFF PCB© by Willem Aandewiel6,00
1B420C1500 (Round)D1 – Bridge rectifier 1.5A 420VAC0,25
11N4007D2 – Diode 1000V 1A0,05
11N 5352BG USD3 – Zener diode 017AA 15V 5W0,25
14N 35U1 – Optocoupler0,30
12 Watt Metal 150KR4 – Metallic film resistor 2W, 5% 150K-ohm0,15
2Metallic 220 ohmsR3,R6 – Metallic film resistor 1/2W 220 ohm0,20
1Metal 6k8 ohmsR7 – Metallic film resistor 1/4W 6800 ohm0,10
2Metal 10K ohmsR2,R5 – Metallic film resistor 1/4W 10K-ohm0,20
1VDR-0.6 460RV1 – Varistor Rm 7.5mm 0.6W 460VAC = JVR14N751K0,30
1RUBY 100PX47MT78C2 – Elco Radial 47 uF RM 3.5 105*C 2000H 20%0,30
1MMK 220N 400C1 – Film Capacitor 220nF 400V 100*C0,30
2LAKL 1.5 2 5.08J1,J3 – Phoenix Screw terminal 2-pole RM 5.08mm 90*1,25
1LAKL 2 2.54J2 – Phoenix Screw terminal 2-pole RM 2.54mm 90*0,60
1KTR 1.0AFuse 5x20mm Slow Blow 1,000A0,55
1PL 112000F1 – Fuse holder 5x20mm max 6.3A/250V0,30
1AC to 3.3v DC PS1 – Hi-Link HLK-5M03 or Mean well IRM-017,40
1ESP-01U2 – ESP8266 module ESP-01 black edition (1MB)5,90
Total cost of all parts (excl. housing) is less than €25,-

Putting it all together

Building a DONOFF is easiest if you do the following steps in order.
Make sure you have all the right parts before you start!

Step 1

The High-Power traces on the PCB are only 1.5 mm wide. To meet the rated current of ~1 amp I omitted the solder mask on these traces. This makes it possible to cover them with a layer of solder, which increases the maximum current. It is imperative that you do too!

Step 2

Solder the lowest parts first. These are R1, R2, R5, D1 and U1.
Make sure that D1 and U1 are placed correctly. The “+” of D1 opposite the markings on the PCB. U1 has a small mark (dot) next to pin 1 or a small groove on the side where pin 1 is. Align pin 1 with the 1 on the silkscreen.
The resistors have no polarity, so it doesn't matter how you place them.

Step 3

Place R4 but make sure you fix it slightly above the PCB (see picture), because this is a part that gives off a lot of heat. The more air that surrounds R4, the better it can dissipate this heat. The temperature of R4 rises about 15°C above the ambient temperature!

Step 4
Now place the diode D2 and the resistors R3, R6 and R7 upright.
Try to place them in such a way that the chance of them making contact with other parts is as small as possible. The polarity of D2 is important! The end on the side of the white stripe on D2 connects to the square pad on the PCB.
It is always a good idea to insulate the connections with shrink tubing.

Step 5

Solder D3 vertically to the PCB. Polarity is important!
The connection on the side of the white stripe on D3 must be connected to the square path. Here too it is best to provide the long connection with a piece of shrink tubing!

Step 6

Now place F1 (fuse holder), RV1 (varistor) and C2. Make sure the white stripe on C2 (–) is on the side of the white semicircle on the silkscreen!

Step 7

Solder Q1 with the metal 'back' facing C2. To lower the profile of the DONOFF dimmer you can bend Q1 slightly towards C2. And again, some shrink tubing over Q1 will reduce the chance of a short circuit and reduce the chance of you being electrocuted!

Step 8

Now place the 2×4 header for the ESP-01 and the three screw terminals for Mains-In, LED-Out and the Ext.Switch.

Step 9

Finally, solder C1 and PS1 to the PCB.
You are done!
The DONOFF is ready to plug the ESP-01 into the 2×4 header.
As I mentioned earlier, this project is very dangerous because of the high voltages and the many exposed parts that carry this high voltage. Therefore it is necessary to set the DONOFF dimmer a suitable housing before you connect it to the mains!

Rapping it all up

I cut an extension cord to 1/3 and then connected the plug to MAINS IN and connected the contra plug to LED OUT.

Add an External switch

The external switch connection is isolated from the mains and connected to the low voltage part (3v3) of DONOFF, so it does not matter much what kind of cord you use to connect the external switch.

Since this example is a foot switch, I opted for a robust switch and housing.
Current Page 13. build DONOFF 1. Introduction 2. Project Objectives 3. The Electronics 4. Mains AC to DC 5. MOSFET control circuit 6. optocoupler circuit 7. ESP8266 Microprocessor 8. 3v3 DC power supply 9. The firmware 10. Upload Firmware 11. First time startup 12. telnet server 13. build DONOFF Posted by Website Willem Aandewiel (1955) has a background in electronics and digital techniques. However, most of his working life he has worked in automation where he has worked in just about all disciplines from programmer to project leader and project manager. Willem was one of the first Dutchmen with a micro-computer (KIM-1, 1976) at a time when the PC had yet to be invented. Nowadays he is mainly concerned with the design and production of small electronic circuits with microprocessors. His 'mission in life' is to make people enthusiastic about making their own electronic circuits, microcomputers and programming.

Comments

Webwinkelkeur Kiyoh Trustpilot Opencircuit