-1

I had already completed a Setup of DS1302 on my Raspberry Pi 3B+ and fortunately its working just fine.

I also already solved the Problem of Turning On and Off the USB Port using "uhubctl".

https://github.com/mvp/uhubctl

The Problem was How can I use my RTC Module (DS1302) to Turn On and Off at Specific Time.

  • (1( Well one stupid way is ask the Rpi to check the RTC every second, and execute a specific program at a specific time. (2) For smarter RTC, such as DS3231, you can program the RTC to interrupt Rpi when the time comes. Ref: https://raspberrypi.stackexchange.com/questions/135258/can-i-turn-on-and-off-my-raspberry-pi-3b-on-a-specific-time – tlfong01 Feb 08 '22 at 06:08
  • turn what on and off at a specified time? – jsotola Feb 08 '22 at 06:46
  • USB Port specifically – Little Intoxicated Feb 08 '22 at 07:15
  • What is the purpose of turning the usb port on/off at a specific time? – CoderMike Feb 08 '22 at 10:46
  • I'd like to turn off my at least my Arduino to save power as I am using Solar Panel in my Project. I figured it was good. since all my sensors are connected to Arduino. – Little Intoxicated Feb 08 '22 at 10:48
  • 1
    If the RTC is correctly setup there is NO NEED to do anything. It sets system clock - just use cron. – Milliways Feb 08 '22 at 21:47

1 Answers1

2

The simplest way is to synchronize the clock of the Pi with your RTC and simply use cron. Depending on how much your pi diverges, you can sync the clock of the pi from time to time in cron too.

Typically, that would look like :

#M   H  dom mon dow cmd
 0   *   *   *   *  rtc-pi
 0  12   *   *   *  script_to_turn_on
 5  12   *   *   *  script_to_turn_off

--- addition---

For those that have a DS1302, it may be obvious that rtc-pi is the program that interfaces with the DS1302 module. It is not in the standard repositories, but can be obtained from (among others) https://zedt.eu/storage/2014/07/rtc-pi-20140727.zip. For other versions of the RTC (like the DS1307) the command would be hwclock, which can be downloaded from https://github.com/Seeed-Studio/pi-hats.git

Ljm Dullaart
  • 2,491
  • 9
  • 15
  • Thanks. Already did that. It works just fine. Many Thanks – Little Intoxicated Feb 09 '22 at 01:39
  • Maybe I'm a little intoxicated also, but this answer does not seem to address the question, stated obtusely as, "How can I use my RTC Module (DS1302) to Turn On and Off at Specific Time." Blinking my way through the alcoholic fog, I can only assume that the OP was referring to the uhubctl to turn his USB ports on & off. IoW, this answer has nothing to do with the RTC. Of course, the OP did accept this answer, but can you explain what the command rtc-pi is? – Seamus Feb 11 '22 at 18:54
  • rtc-pi is the program that interfaces with the DS1302. Basically, you can set an initial time on the clock module and set the time on the pi from the clock module. – Ljm Dullaart Feb 12 '22 at 22:40
  • And so rtc-pi is not an actual program that's available from anywhere? ... apt-cache search rtc-pi doesn't show anything by that name. BTW, You get a notification when anyone posts a comment here because this is your answer. But if you reply to a comment here, you must add their handle for them to get a notification; e.g. @seamus in my case. – Seamus Feb 13 '22 at 09:46
  • @Seamus: didn't know about the need for the handle. Sorry about that. I added some comment about interfacing with the RTC modules. – Ljm Dullaart Feb 14 '22 at 12:11