@ CountChocula - many thanks, I've checked and check again to see if the reality of the circuits are the same - not to say that there is something still amiss, I will check again :-) I've replaced the mosfet and resistors and I get the same result so I guess that rules it out (this is on a PCB so the wiring is identical). Good idea to have a manual play with the voltage levels on the mosfet directly, I will do this. I haven’t heard of pin states being preserved at the point on going into LOW POWER mode but I will try to read up on this - the MCU I'm using is the ATMEGA1284P.
@ Peabody - also many thanks, the voltage on SWT2 is indeed 3V3, on the other side of the gate resistor it is more like 3V (these voltages are the same on both boards as are the measured resistance of both resistors). I will copy the test code I'm using below on both boards which set all pins LOW and as INPUTS which hopefully deals with the possibility you mention?
#include "LowPower.h"
const uint8_t pSWT = 19; // Mosdfet to switch periferal power
void setup() {
pinMode(pSWT, OUTPUT);
delay (3000);
digitalWrite (pSWT, LOW);
delay (3000);
digitalWrite (pSWT, HIGH);
delay (3000);
setPinsForSleep ();
delay (3000);
powerOff();
}
void loop() {}
void powerOff()
{
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
delay (10); //Time to settle
}
void setPinsForSleep ()
{
digitalWrite (0, LOW);
digitalWrite (1, LOW);
digitalWrite (2, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, LOW);
digitalWrite (7, LOW);
digitalWrite (8, LOW);
digitalWrite (9, LOW);
digitalWrite (10, LOW);
digitalWrite (11, LOW);
digitalWrite (12, LOW);
digitalWrite (13, LOW);
digitalWrite (14, LOW);
digitalWrite (15, LOW);
digitalWrite (16, LOW);
digitalWrite (17, LOW);
digitalWrite (18, LOW);
//digitalWrite (19, LOW); // 3V3 POWER SWITCH
digitalWrite (20, LOW);
digitalWrite (21, LOW);
digitalWrite (22, LOW);
digitalWrite (23, LOW);
digitalWrite (24, LOW);
digitalWrite (25, LOW);
digitalWrite (26, LOW);
digitalWrite (27, LOW);
digitalWrite (28, LOW);
digitalWrite (29, LOW);
digitalWrite (30, LOW);
digitalWrite (31, LOW);
digitalWrite (32, LOW);
pinMode(0, INPUT);
pinMode(1, INPUT);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);
pinMode(13, INPUT);
pinMode(14, INPUT);
pinMode(15, INPUT);
pinMode(16, INPUT);
pinMode(17, INPUT);
pinMode(18, INPUT);
//pinMode(19, INPUT);
pinMode(20, INPUT);
pinMode(21, INPUT);
pinMode(22, INPUT);
pinMode(23, INPUT);
pinMode(24, INPUT);
pinMode(25, INPUT);
pinMode(26, INPUT);
pinMode(27, INPUT);
pinMode(28, INPUT);
pinMode(29, INPUT);
pinMode(30, INPUT);
pinMode(31, INPUT);
pinMode(32, INPUT);
}