Power on off with ds323rtc

excuse my English

I need on and off the Arduino twice a day, for one minute.
It can be made in the manner as shown below?
which library should I use?
I can not use the SQW pin.

There is no such thing as a DS323 - do you mean DS3231? Have you read the datasheet
if so, because it explains the time-of-day alarms

image

yeah I thought DS3231
I looked datasheet does not represent

Alarms
The DS3231 contains two time-of-day/date alarms.
Alarm 1 can be set by writing to registers 07h to 0Ah.
Alarm 2 can be set by writing to registers 0Bh to 0Dh.
The alarms can be programmed (by the alarm enable
and INTCN bits of the control register) to activate the
INT
/SQW output on an alarm match condition. Bit 7 of
each of the time-of-day/date alarm registers are mask
bits (Table 2). When all the mask bits for each alarm
are logic 0, an alarm only occurs when the values in
the timekeeping registers match the corresponding val

ues stored in the time-of-day/date alarm registers. The
alarms can also be programmed to repeat every second,
minute, hour, day, or date. Table 2 shows the possible
settings. Configurations not listed in the table will result
in illogical operation

You are pretty close with your design idea.
It needs 2 transistors. A P-channel MOSFET that acts a "high side" power switch.
Its gate is pulled high to turn it off.
When the DS3231 Interrupt line goes low, that turns the P-channel on.
The Arduino then drives a simple NPN on to hold the gate low and does whatever the arduino does. When done, it stops driving the NPN, letting the pullup resistor pull the gate high and turn off again.
The NPN is needed so that the pullup resistor voltage does not power the Arduino thru an IO pin's protection diode.
Need to us a Low Rds, Logic Level P-channel FET. A thru hole part could be:

CrossRoads thanks for help
I experiment with libraries.
Alarms works if it works Arduino.
I can not leave the alarm set to the RTC.
Can anyone help me with an example?

I can not use the SQW pin.

The alarm of the DS3231 is read on the SQW pin after it is set to be an interrupt and the alarms are enabled. What do you mean that you can not use the SQW pin? Are you using the square wave output for something else in your program?

The library I use, and recommend for the DS3231 is the JChristensen library DS3232 which works with the DS3231. GitHub - JChristensen/DS3232RTC: Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks

Here is an example using that library to enable the alarms, read and reset them.

#include <DS3232RTC.h>    //http://github.com/JChristensen/DS3232RTC
#include <Time.h>         //http://www.arduino.cc/playground/Code/Time  
#include <Wire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)

tmElements_t tm;
const byte rtcAlarmPin = 8;//pin read by polling, could be set up an an external interrupt on pin2/3

void setup(void)
{
  pinMode(rtcAlarmPin,INPUT_PULLUP);
  Serial.begin(115200);
  Serial.println("DS3231RTC Alarm Test");
  setSyncProvider(RTC.get);   // the function to get the unix time from the RTC
  if(timeStatus() != timeSet) 
    Serial.println("Unable to sync with the RTC");
  else
    Serial.println("RTC has set the system time");
  Serial.println(); 

  //enable alarm interrupts on match;also sets status flags A1F,A2F
  RTC.alarmInterrupt(1,1);//enable alarm 1 interrupt A1IE
  RTC.alarmInterrupt(2,1);//enable alarm 2 interrupt A2IE

  //enable or disable the square wave output,
  // no square wave (NONE) sets ITCN bit=1  
  //enables alarm interrupt on square wave pin set from A1F, A2F
  //digitalRead with INPUT_PULLUP; LOW is alarm interrupt
  RTC.squareWave(SQWAVE_NONE);


  /*Alarm_Types defined in RTC3232.h.............................................
   
   ALM1_EVERY_SECOND 
   ALM1_MATCH_SECONDS
   ALM1_MATCH_MINUTES     //match minutes *and* seconds
   ALM1_MATCH_HOURS       //match hours *and* minutes, seconds
   ALM1_MATCH_DATE        //match date *and* hours, minutes, seconds
   ALM1_MATCH_DAY         //match day *and* hours, minutes, seconds
   ALM2_EVERY_MINUTE 
   ALM2_MATCH_MINUTES     //match minutes
   ALM2_MATCH_HOURS       //match hours *and* minutes
   ALM2_MATCH_DATE       //match date *and* hours, minutes
   ALM2_MATCH_DAY        //match day *and* hours, minutes
   */
  //setAlarm Format (Alarm_Type, seconds, minutes, hours, date(or day))
  RTC.setAlarm(ALM2_EVERY_MINUTE, 0,0,0,0);
  RTC.setAlarm(ALM1_MATCH_SECONDS,30,0,0,0);

  RegisterDump();

}
void loop()
{
  TimeDateDisplay();
  Serial.print("rtcAlarmPin   ");
  Serial.println(digitalRead(rtcAlarmPin));//resets with status reset
  Serial.print("Alarm1 status  ");
  Serial.println(RTC.alarm(1));//reads and resets status
  Serial.print("Alarm2 status  ");
  Serial.println(RTC.alarm(2));//reads and resets status
  Serial.println();
  delay(5000);
}

void TimeDateDisplay(void)
{
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(' ');
  Serial.print(month());
  Serial.print("/");
  Serial.print(day());
  Serial.print("/");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits) // utility function for TimeDateDisplay prints preceding colon and leading 0
{
  Serial.print(':');
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void RegisterDump(){
  Serial.print("Register");
  Serial.print("\t");
  Serial.println("Bit Values");
  Serial.println();
  for (int a = 0x00; a < 0x13; a++)
  {
    byte b=readNVRAM(a);
    Serial.print("0X");
    if(a<16)
      Serial.print("0");
    Serial.print(a, HEX);
    Serial.print("\t");
    //Serial.print("\t");
    for (int i = 7; i > -1; i--)//routine for printing full 8 bits, leading zeros
    {

      Serial.print((b >> i) & 0X01);//shift and select first bit
    }
    Serial.println();
    //delay(100);
  }
  Serial.println();
}

byte readNVRAM(byte location)
// retrieves data from DS1307 NVRAM location
{
  byte result;
  Wire.beginTransmission(RTC_ADDR);
  Wire.write(location); 
  Wire.endTransmission();  
  Wire.requestFrom(RTC_ADDR, 1);//only 1 byte, does not need wire.available
  result = Wire.read();
  return result;
}

sorry for the late reply.

Thank you for your help it works. :slight_smile:

Hi
Sorry for asking about a thread of last year. I am a newbie and very interested in what is descripted in this thread. I am building a feeder for pheasants triggered exactly at sunrise and sunset (my gratitude to forumites Bricolo and Etibou). As a low power device, I opted for a pro mini working twice 10 seconds each day. The rest of the time, I want to power it off, hence my great interest in this thread.

If You can please help me, I am unsure of how to design how to sink down via a NPN the gate of the Mosfet, as descripted by Mr Crossroads.

Elements : pro mini, PCF8563 RTC, TPS782 Voltage Regulator 3,3V, NDP6020P p Mosfet, P2N222a transistor.
.
As You can see on the picture, the RTC sends via INT/SQW a low interrupt to the p Mosfet gate, that way closing the fet and powering the arduino. As the duration of the interrupt is short (don't know how long), immediately, the Arduino should ASAP trigger via pin 7 a NPN to keep sinking the gate low as long as the arduino is doing its tasks.

What I am unsure of is how to properly sink the gate low ??

Formerly, the INT/SQW applied a high impedance (3 V, 2AAA) with a pull up (10K) linked to the VIN of the battery (3 AAA cells). So, the sinking of the gate should also overcome this pull up.
Is my using only a 10K resistor (R4) enough ?

Marginally, as a newbie, I am always wondering which resistors picking, mostly copying though I am supposed to know the Ohm law. If You can please check the other resistors ? And any nonsenses ?
I hope that opting for a P2N222a transistor is correct ?

Thanks a lot for Your valuable contribution in this forum and Your advices.

[quote author Crossroads] "You are pretty close with your design idea.
It needs 2 transistors. A P-channel MOSFET that acts a "high side" power switch.
Its gate is pulled high to turn it off.
When the DS3231 Interrupt line goes low, that turns the P-channel on.
The Arduino then drives a simple NPN on to hold the gate low and does whatever the arduino does. When done, it stops driving the NPN, letting the pullup resistor pull the gate high and turn off again.
The NPN is needed so that the pullup resistor voltage does not power the Arduino thru an IO pin's protection diode.
Need to us a Low Rds, Logic Level P-channel FET. A thru hole part could be:
http://www.digikey.com/product-detail/en/NDP6020P/NDP6020P-ND/1055922"

Hi
Sorry for asking about a thread of last year. I am a newbie and very interested in what is descripted in this thread. I am building a feeder for pheasants triggered exactly at sunrise and sunset (my gratitude to forumites Bricolo and Etibou). As a low power device, I opted for a pro mini working twice 10 seconds each day. The rest of the time, I want to power it off, hence my great interest in this thread.

If You can please help me, I am unsure of how to design how to sink down via a NPN the gate of the Mosfet, as descripted by Mr Crossroads.

Elements : pro mini, PCF8563 RTC, TPS782 Voltage Regulator 3,3V, NDP6020P p Mosfet, P2N222a transistor.
.
As You can see on the picture, the RTC sends via INT/SQW a low interrupt to the p Mosfet gate, that way closing the fet and powering the arduino. As the duration of the interrupt is short (don't know how long), immediately, the Arduino should ASAP trigger via pin 7 a NPN to keep sinking the gate low as long as the arduino is doing its tasks.

What I am unsure of is how to properly sink the gate low ??

Formerly, the INT/SQW applied a high impedance (3 V, 2AAA) with a pull up (10K) linked to the VIN of the battery (3 AAA cells). So, the sinking of the gate should also overcome this pull up.
Is my using only a 10K resistor (R4) enough ?

Marginally, as a newbie, I am always wondering which resistors picking, mostly copying though I am supposed to know the Ohm law. If You can please check the other resistors ? And any nonsenses ?
I hope that opting for a P2N222a transistor is correct ?

Thanks a lot for Your valuable contribution in this forum and Your advices.

[/quote]