Devices & Components
Arduino Uno Rev3
The wall cord
Jumper wires (generic)
Breadboard (generic)
USB-A to B Cable
Relay Module (Generic)
The led light bulb
DS3231M - ±5ppm, I2C Real-Time Clock
Software & Tools
Arduino IDE
Project description
Code
The code
arduino
this is the code you need to run this complicated piece of smart tech.
1#include <DS3231.h> 2 3int Relay = 4; 4 5DS3231 rtc(SDA, SCL); 6Time t; 7 8const int OnHour = 07; 9const int OnMin = 15; 10const int OffHour = 07; 11const int OffMin = 20; 12 13void setup() { 14 Serial.begin(115200); 15 rtc.begin(); 16 pinMode(Relay, OUTPUT); 17 digitalWrite(Relay, LOW); 18 //rtc.setTime(21,10,00);//set your time and date by uncomenting these lines 19 //rtc.setDate(26,6,2018); 20} 21 22void loop() { 23 t = rtc.getTime(); 24 Serial.print(t.hour); 25 Serial.print(" hour(s), "); 26 Serial.print(t.min); 27 Serial.print(" minute(s)"); 28 Serial.println(" "); 29 delay (1000); 30 31 if(t.hour == OnHour && t.min == OnMin){ 32 digitalWrite(Relay,HIGH); 33 Serial.println("LIGHT ON"); 34 } 35 36 else if(t.hour == OffHour && t.min == OffMin){ 37 digitalWrite(Relay,LOW); 38 Serial.println("LIGHT OFF"); 39 } 40}
Downloadable files
The schematic
The schematic

The schematic
The schematic

Documentation
The junction box
This is the box that you will house your outlet and electrical for the socket and the relay.
The junction box

The junction box
This is the box that you will house your outlet and electrical for the socket and the relay.
The junction box

Comments
Only logged in users can leave comments