This instructable will guide how to make an Ceiling Fan Speed Regulator using Triac Phase angle control method. Triac is conventionally controlled by Atmega8 standalone arduino configured chip. Wemos D1 mini adds WiFi functionality for this regulator.
1. Both local and wifi controlled (Push button & Smartphone wifi).
2. State saving feature to resume fan speed level even after power interruption.
3. Low speed fan cut off (avoiding overheat of Fan stator).
4. LED Indication feedback for button push and speed level.
5. Standalone cheap Atmega8 DIY board rather than Arduino Uno R3.
6. Without snubber capacitor and resistor can be used as dimmer for AC incandescent bulbs.
BE CAUTIONED THAT THIS PROJECT INVOLVES WORKING WITH DIRECT AC 220V WHICH IS HIGHLY DANGEROUS.
Step 1: Parts Needed
LEVEL : ADVANCED
1. ATMEGA8 or ATMEGA8A 28 Pin Chip + 28 Pin IC Base
2. AT24C32 EEPROM + 8 Pin IC Base
3. Berg strip
4. 1k Network resistor + 10 LEDs or 10 channel bar LED
5. 10uF 25V Electrolytic capacitor
6. Hookup wires
7. 5 X 10k resistor
8. 3 X 2N2222 Transistor
9. 22pf + 16mhz crystal
10. 2 X 120k 2W Resistor
12. 4N35 Optocoupler
13. 2way terminal block
14. BT136 Triac
15. MOC3021 Optocoupler + IC Base
16. 1k resistor
17. 0.01uF X Rated AC Capacitor (Snubber circuit)
18. 47ohm 5W resistor (Snubber circuit)
19. 2 X 390ohm 2W resistor
21. Perf board (As required size)
22. Dupont F-F connectors
23. 4 X Push button
24. Wooden box (Enclosure)
25. Wemos d1 mini
Step 2: Testing Circuit
The circuit has 4 speed control carefully chosen. Pins 13, A0, A1, A2, A3 shows status of speed. Pin 13 blinks whenever push button is pressed or Wemos pulse is received.
Pin2 is input from zero cross detector
Pin3 is drive to triac optocoupler
Atmega8 standalone version runs on 16mhz external crystal.
Push buttons with parallel headers for Wemos, trigger a pulse to pin7 and pin8 for increasing or decreasing of fan speed. These pins are pulled up.
Schematic has own Zero cross detector for each channel. Each channel i.e each fan has seperate Atmega8 standalone. Standard configuration of MOC3021 driving Triac. Snubber circuit added for this inductive load.
Pin A0 is showing lowest speed for the fan is driven through a transistor to MOC3021 to ensure very low speed to AC fan is avoided.
I2C EEPROM saves the speed whenever corresponding speed level is changed.
Step 3: Schematic and Soldering
Find the attached schematic and design your layout or do an etched PCB from my previous instructable.
I have used this type of board for easy soldering.
Since I am controlling two fans I have used 2 boards as shown. A 10 channel bar LED for feedback and status purposes.
As shown in the picture push buttons are soldered to dupont for easy connection to male header in perfboard.
A network resistor of 1k is used to drive 5 status LEDs
Since 220VAC zerocross detector is in same perfboard of Atmega8 enough spacing was given and at the back (copper area) is hot glued preventing exposure of 220V.
Step 4: Burning HEX File
Configure the Atmega8 chip for using with Arduino IDE following this excellent article.
Once Arduino Optiboot loader is installed on Atmega8, just plug out the Atmega328p chip and plug in the new Atmega8 bootloader burned chip into the Arduino Uno R3 board 28 pin socket taking into account the pin notch.
Then download the Burn.zip file extract it to a folder. Right click 'bet.bat' file and click Edit and open batch file in notepad and change COM5 to your corresponding active arduino COM port, which can easily be seen from "devmgmt.msc" from Run command.
Then close notepad and run bet.bat file
Avrdude will burn hex file to Atmega8
Step 5: Realtime Test
After soldering and uploading the code, have tested the circuit in real time application and found good output.
Step 6: Configuring Wemos D1 Mini
For Wifi configuration I have used EspEasy firmware which is are fine piece of work.
Basically pins D6 and D7 generates the pulse for 300ms to the base of transistor
Use this link and burn the firmware to Wemos D1 Mini.
Using this link we can Increase http://192.168.4.1/control?cmd=Pulse,13,1,300
Using this link we can Decrease http://192.168.4.1/control?cmd=Pulse,12,1,300
The above links will work right after burning firmware to Wemos
Later if Access Point information is added to Espeasy, make sure to use the desiganated IP address in the place of 192.168.4.1 in the above link.
In the event of making this an IOT device configure accordingly in Espeasy protocol selection.
Step 7: Using Android App to Control
HTTP Shortcuts android app allows to control the fan speed as shown in attached pictures.
Step 8: Final Mounting
I used an acrylic glass front and wooden box back. Wooden box is secured to wall using two screws and anchor use this link as guide to install.
Follow this instructable to install a box flushed with wall for a good finish.
If any queries pls contact me @
Whatsapp - +91 8870255444