How to regnosie weekday and weekend of the day

Dear all

I am using Arduino uno and mcp7940 N RTC module.I could able to display RTC date and time. Now i am trying to implement timeswitch application. where we i wanted to run on the relay in weekdays and turnoff
during weekends

For example mon- Fri could set various timing where as Sat- Sun should for relay should be deactivated.
I would like to know how can i display Mon-FRI based on the day ??

How weekdays in RTC module help to decide which days running.

Oftentimes the RTC library will get that information for you - take a look in the examples or the .h file. Which one are you using?

How weekdays in RTC module help to decide which days running.

What is the problem ? The RTC library (which one are you using ?) will almost certainly be able to get the day of the week as a number between 0 and 6 or 1 and 7

From that very tutorial you linked to...


So at a guess...

// Get the DOW    (MCP7940_I2C, REG_RTCWKDAY, 1);
byte dow = I2c.receive();

The 7940N supports day of the week internally in the RTCWKDAY register.

It won't tell you that today is a Wednesday, for example. However, the day of the week is incremented by 1 at midnight.

So if you set the time and date on your RTC on a Monday, you can tell the RTC that the weekday is 1, for example.

The RTC will then set weekday to 2 on Tuesday, 3 on Wednesday etc. So when it's the weekend the RTCWKDAY register will have either a 6 or a 7 in the 3 WKDAY bits.

Of course, you could have a Saturday as day 1 if you wanted. The RTC doesn't care. It just increments the number at midnight and wraps back round from a 7 to a 1.