trigger my relay to close

I have seen many of this similar questions about the RTC. I'm currently trying to setup my Arduino to trigger my relay to close on monday and wednesday at 5pm -5:10pm.
I know I have to use
now.dayOfTheWeek() will return you the weekday number
and now.hour() will return you the hour
set a pin

Anyone ever setup date and time with the RTC on the ardunio?

Arduino
Adafruit PCF8523 Real Time Clock
8 Channel DC 5V Relay Module
Led

You just have to follow this simple logic, in C-ish pseudocode:

if (day_of week == Monday || day_of_week == Wednesday)
{
  if (time_of_day >= 1700 && time_of_day <= 1710)
  {
    relay_on();
  }
}

How you get the time and how you drive the relay will depend on your hardware and on the library (if any) that you'll be using for the RTC. If your relay is bistable, the logic is a bit different: you'll have to turn it on at 1700 and turn it off at 1710.

Have you written any code yet? How is it working right now?

I'm still trying learn this. I have been watching videos on learn C coding. This look like OR and == is equal.

Don't watch videos. Read books.

1 Like

I got this book Arduino Cookbook

And write your own sketches to reinforce what you read/learn.

1 Like

If I have a simple RTC sketch to run, I set the time by loading the set time example sketch first. Then I load my sketch which only reads the RTC.

Well.. almost... in fact I now wrote my own purely time setting sketch. It also has commands to manipulate the RTC registers if I need that...

Once it's set, it shouldn't need changing until the battery dies in about 10 years.

Do I practice C language and the Arduino tutorial too

Good. Also the many C++ tutorial websites.

Any book you can suggest

Needs differ, I have, "C++ Primer, 4th Edition", Lippman, Lajoie, Moo.

It may be more than you need to start out...