Arduino Photoresistor Relay Control with PCF8591 Module

Relay controlled by light intensity can be implemented using Arduino UNO compatible board. In this case Keyestudio UNO R3 and AD/DA module with PCF8591 chip. Similar simpler design is available here. On this particular module a photoresistor and a potentiometer were added  to 2 separate analog inputs of the converter thus eliminated the need to add additional external components. Data transfer between Arduino and the A/D module is done via I2C interface. Attached Arduino sketch converts  analog readings from those 2 channels and compares potentiometer trigger level with photoresistor output and turns one of the four relays on the shield ON/OFF if the trigger level is reached. The sensitivity can be adjusted by  rotating the potentiometer. In the next figure you can see a design schematic.

Arduino Photoresistor Relay Control with PCF8591 Module Schematic

I’ve noticed that there are several variants of the PCF8591 module available. On some of these boards the pin out is slightly different. For example SDA and SCL lines are located in different places. Also the onboard photoresistor can be connected to other analog channels. In this case the attached code should be modified accordingly.

Arduino-Photoresistor-Relay-Control-with-PCF8591-Module-Board