Attiny10 to switch Mosfet

This is not necessarily an Arduino IDE programming question, but more of a circuit feasibility question.

I want to use a DS3231 RTC clock IC to switch the power to a Pi Pico. The Pico is a handheld battery powered device that I want to completely cut power to (and therefore all peripherals) when an alarm is set. I want two options for triggering the alarm. The first option would be the Pico just checking if the alarm has been triggered, for example if the device is being used for other things, so I don't want it to power off, but when it detects the alarm has gone off, it will interrupt the working script and display alert or sound buzzer.

The second option, when setting the alarm, it will put one of its pins low, which in this case im showing an ATTINY10 connected to, which will inform attiny10 that it wants to cut power to Pico until alarm goes off, when this alarm goes off, pico powers on, checks and sees that alarm has gone off and buzzer or alert on screen is fired.

Below is a my hand drawn circuit. I've had issues switching directly with a P-channel mosfet. eg. using 3.3v to switch 4.2v. So I was thinking the gate on P-channel mosfet will be pulled up, otherwise using 3.3v to switch N-channel mosfet to pull P-mosfet gate to ground. I have not breadboard tested any of this.

My question is the ATTINY10 a good candidate for this, or are there discrete components I could do the same thing with?

Is using a N-channel mosfet to switch the P-channel the right choice here, or would a transistor work better in place of the N-channel mosfet.

I am just in the stage of asking: "will this work? Is this the best way to do this?" On this project, any input appreciated.

And just for fun, asked ChatGPT if it could write me code for ATTINY10 to do this, this is what it came up with:

write me assembly code for attiny10. Attiny10 is normally in poweroff mode. If there is a pin change on PB1 or PB3, Arduino Wakes up and runs this code: if PB1 is High, and PB3 is high, PB2 is high. if PB1 is low, and pb3 is high, pb2 is high. if pb1 is low, and pb3 is low, pb2 is low.

.include "tn10def.inc"

.equ F_CPU = 1000000    ; Assuming a 1 MHz clock frequency

ldi r16, (1 << PB1) | (1 << PB3)  ; Configure PB1 and PB3 as inputs
out DDRB, r16

ldi r16, (1 << PCIE)   ; Enable Pin Change Interrupt
out GIMSK, r16

ldi r16, (1 << PCINT1) | (1 << PCINT3)  ; Enable Pin Change Interrupt for PB1 and PB3
out PCMSK, r16

sei  ; Enable global interrupts

sleep:
  sleep                  ; Go to sleep, waiting for a pin change interrupt
  rjmp sleep             ; Continue sleeping after wake-up

PCINT0_vect:
  in r16, PINB          ; Read the input state of PORTB into register r16

  ; Check conditions and set PB2 accordingly
  sbrs r16, PB1          ; Skip the next instruction if PB1 is low
  sbrc r16, PB3          ; Skip the next instruction if PB3 is low
  sbr  r16, PB2          ; Set PB2 high if PB1 is low and PB3 is high
  cbr  r16, PB2          ; Clear PB2 if PB1 is low and PB3 is low

  out PORTB, r16         ; Update the output state of PORTB
  reti                   ; Return from interrupt

Now that I'm looking at it, it looks like the ATTINY10 could just be replaced with an OR gate...

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.