Light sensor switches

A. The simple analogue light sensor switch.

Made a simple light sensor to control an USB outlet to work at day light only. Power source is a small 60 W solar cell system:

The light sensor controls the power to the USB socket that provides power to the 12 V USB socket. The schematic for the light sensor switch with pot.meter to adjust the LDR threshold levels:

The LDR 5K Light Dependent Resistor and the 50K pot.meter sets the trig and threshold levels for the bright/dark relation for the SE555N comparator inputs. The BC639 transistor is able to sink 1 A to source the 12 V / 1A USB socket.

B. The smart plug with light sensor.

Made a light sensor using a modified Sonoff S26 smart plug with a BH1750 light sensor.

Inside the Sonoff S26 smart plug the I/O pins GPIO4 and GPIO5 are available for the I2C communication with the BH1750 light sensor, and is wired as shown above. A small Ø3.5 mm hole was made in the smart plug front cover part to let the light reach the BH1750 sensor chip.

The GY-302 PCB with the BH1750 light sensor was clued on the rear side of the front cover. The initial flashing of the ESP8266 went on as for the adaptive smart plug project. I added a small web side to set the light levels for turning the smart plug output on and off. The scale has 240 steps, but the Lux values are power 2 of the step values:

The maximum  light level of 57600 lux is chosen ( max step value 240*240 ), because the highest value I could measure was 54613 lux using a Klarus A1 pocket light.  The light levels settings are saved in the ESP8266 internal flash memory. The Arduino source can be found here: Smart light plug .

C. The light sensor with ESP32-S2 mini and deep sleep during output off.

TBD