The estimated reading time for this post is 104 seconds
Hello again everyone, thanks to my dad’s suggestion, I’d like to use Arduino to turn on and turn off a lamp or any 220 V device at certain times of the week.
So for example:
-on Monday I want my lamp lights at 8.15 till 9.40, in the afternoon from 17.10 at 17.45.
-on Tuesday, at 9.20 a.m. 10.50 a.m.
-on Wednesdays from 10.00 a.m. to 11.00 a.m. and in the afternoon from 15.10 at 15.45
and so on, until Sunday
To do this I got the chip DS1307:it’s a very cheap RTC (real-time clock) that allows you to keep track of time and date.
It also has a buffer battery which ensures the functioning of the internal clock in the absence of external power.
It is possible to communicate with the chip via I2C Protocol, so we can use the Wire library.
The connection between arduino and the chip is very simple, as shown in the picture below:
To summarize:
Arduino Pin | PIN DS1307 |
5 V | 5 V |
GND | GND |
Analog pin 4 | SDA |
Analog pin 5 | SCL |
Connections between Arduino and the chip will vary depending on the model of Arduino (Uno, leonardo, etc).
In fact the PIN SDA (data line) and SCL (clock line) differ above:
Board | I2C/TWI pins |
Uno, Ethernet | A4 (SDA), A5 (SCL) |
Mega2560 | 20 (SDA), 21 (SCL) |
Leonardo | 2 (SDA), 3 (SCL) |
Due | 20 (SDA), 21 (SCL), SDA1, SCL1 |
In the next post we will see how to handle date and time, and how you can use this information when we want to turn on a device.
Bye!!!