Flyback Converter Design
The Flyback converter will provide a 120 VAC to 5VDC power conversion. The ESP32 requires 3.3V power input. Therefore a Low-dropout regulator (LDO) will be used to convert 5V to 3.3V for the microcontroller to use. This linear regulator would also reduce ripples created by the flyback converter and provide a clean power supply for our controller to use.
There are many ways to convert AC to DC, but the Flyback converter is the most popular and cost-efficient way to do so. Plus, the flyback transformer will provide isolation between AC and DC. This isolation helps to reduce noise propagating between AC and DC and Electromagnetic interference.
ESP 32 has WiFi, Bluetooth, capacitance touch sensor, ADC, DAC and hall effect sensor functionality built-in and yet sells around $5 per chip. Even with the WiFi PCB antenna build-in, it only cost me $5.88 each.
Switching the light
The light switching would be a high voltage rating relay. The microcontroller would control this relay base on the sensors reading and WiFi communication sent from the cloud server.
In this project, I am trying to test a temperature sensor and a motion sensor. The reliability of the sensor reading under an AC present environment would be investigated.
Schamtics and PCB file are in Github