Arduino self-shutdown with latch circuit only works for short timeouts

Hey all! I've been working for a while on my first Arduino project, which is a talking toy based on the DFPlayer and an Arduino Nano (clone). As I was sketching it out, I soon realized that between the two boards, the power consumption in standby would eat through a 3-4 AA/AAA battery pack in about a day, so I researched how to make the whole thing shutdown entirely after a timeout period. I found this solution on StackExchange and implemented it pretty much as it's presented there, with a 2N7000 NFET and a IRFU9024 PFET. In addition, I have two TTP233 touch button breakout boards, one that controls the latch circuit and one that goes to the Arduino to trigger the MP3 player (just want it to play a random file). The touch buttons are connected in series directly to the VCC and GND lines, being the only ones always-on. The one that controls the PFET is jumper set to connect to GND when pressed.

I worked progressively through the project, starting with jumper wires, to breadboards and, finally, a PCB testboard. This is my first electronics project ever, so my soldering is pretty bad, but I eventually managed to make it work. Sort of. I initially started with a 3 AA 1.5V battery pack, but then realised that, after all the soldering and adding the speaker, it appeared like the Arduino wasn't getting enough power, so I upgraded to 4 AAA batteries, which seems to fit all the components nicely (except the TTP233, which says no more than 5.5 V, but I figured it's safe).

The main problem is that, at every step, I would just test short timeout periods, of 10-20 seconds, and they would work ok. When I arrived at a fully soldered board, however, things started acting weird for anything more than 10 seconds, and multiple tries. Most often, as the timer expired, the boards flickered briefly and then powered back up right away. Sometimes they would shutdown after another timeout period passed, sometimes not at all (or at least not after tens of seconds, or a few minutes).

I am now trying to figure out if this is a software problem, or a hardware one. As far as hardware goes, the only thing I can think of is that the TTP233 buttons somehow interfere with the latch circuit. I didn't use a resistor between the on/off one and the PFET, for instance. This is the code I use (sorry if it's not formatted right, new here):

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 9); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);
const int powerPin = 2;     
const int button = 3;
int playstate = 0;
const unsigned long timeout = 60000;
unsigned long startMillis;
unsigned long currentMillis;

void setup()
  pinMode(powerPin, OUTPUT);
  digitalWrite(powerPin, HIGH);
  pinMode(button, INPUT);
  pinMode(13, OUTPUT);
  startMillis = millis();

void loop()
  currentMillis = millis();
  if (currentMillis - startMillis > timeout) {
      digitalWrite(powerPin, LOW); 
  int nextplay = random(0, 14);
  playstate = digitalRead(button);  
  if(playstate == HIGH) {; 

Simple tests are best.

I would remove the TTP233 button and use a simple hookup wire.

I completely missed the code brackets, sorry. That is the whole code, though.

Simple tests are best.

I would remove the TTP233 button and use a simple hookup wire.

Definitely. The circuit assumes a completely passive push button physical switch, not something that takes power.

Thanks for the suggestion. I replaced the on/off TTP233 with a basic push button and the timeout issue disappeared.

Since the other touch button also draws power, I imagine it must have something to do with their high/low setting. The control button is set to active high and lights up the onboard LED when activated, while the on/off one is set to active low and has the LED turned on when inactive. I'm going to remove that LED to see if it changes anything.

Would a resistor between the FET and the TTP233 influence anything?

I don't think a resistor will help.

Perhaps another M2 MosFet. It would be connected the same way as M2 (including the 10K and 100) but instead of connecting to GPIO it would go to 9V

Ok, I tested my LED theory and it seems to be correct. I removed the LED from the active low TTP233 touch button and the issue is gone. I think the LED drew too much power while the button should have been in standby, so what should have been a few microamps of quiescent current turned into something large enough to mess with the FETs.

Thanks for pointing me in the right direction!