Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

PN532 Breakout Board Powerdown & Wake up
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PN532 Breakout Board Powerdown & Wake up

by Adafan101 on Thu Sep 19, 2019 5:50 pm

Hello, I'm looking for help with Adafruit PN532 Breakout board.

I'm looking for a way to power down the the breakout board, but nothing seems to work. I have looked through the source code given to us and I can only find #definePN532_COMMAND_POWERDOWN (0x16) in the Adafruit_PN532.h

I was wondering if anybody can help me find a way to Power it down?

Adafan101
 
Posts: 6
Joined: Thu Sep 19, 2019 5:41 pm

Re: PN532 Breakout Board Powerdown & Wake up

by mikeysklar on Thu Sep 19, 2019 11:04 pm

Have you tried the suggestion from this post (it is dated 2015):

viewtopic.php?f=22&t=70344

PN532.cpp modification:
Code: Select all | TOGGLE FULL SIZE
bool PN532::shutDown(){
pn532_packetbuffer[0] = PN532_COMMAND_POWERDOWN;
pn532_packetbuffer[1] =  WAKEUPSOURCE; //(0x20, for SPI) (0x28 for SPI and RF detectionThe wakeup source(s) you want too use
pn532_packetbuffer[2] = 0x01; // To eneable the IRQ, 0x00 if you dont want too use the IRQ
DMSG("Shutting down RF module");

if(HAL(writeCommand)(pn532_packetbuffer, 3))
return pn532_packetbuffer[1];

delay(2);   //Delay to make sure the module is off.
return (0 < HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer)));
}


PN532.h modification:
Code: Select all | TOGGLE FULL SIZE
boolean shutDown(void);

mikeysklar
 
Posts: 1655
Joined: Mon Aug 01, 2016 8:10 pm

Re: PN532 Breakout Board Powerdown & Wake up

by Adafan101 on Sat Sep 28, 2019 7:30 pm

It did not work for me. I put it in and it seems it gives me this:

'class Adafruit_PN532' has no member named 'shutDown'

I put it in the Adafruit_PN532.cpp

Adafan101
 
Posts: 6
Joined: Thu Sep 19, 2019 5:41 pm

Re: PN532 Breakout Board Powerdown & Wake up

by JeremysIon on Mon Sep 30, 2019 2:14 am

I also are trying to put PN532 NFC reader to sleep or total sleep (RST pin?) but with no luck..

The PN532_COMMAND_POWERDOWN in Adafruit_PN532.h has no implementation.

? How to put the NFC module to sleep? Passive reader consumes 60mA all the time, but with RST pin hi/low i got 8-12mA and it still read the card... can not make sense of it..

JeremysIon
 
Posts: 13
Joined: Sun Apr 02, 2017 4:50 am

Re: PN532 Breakout Board Powerdown & Wake up

by JeremysIon on Wed Oct 02, 2019 5:17 am

well...
Using SPI in Arduino Nano.

I wrote to Adafruit_PN532 library like this:
Code: Select all | TOGGLE FULL SIZE
bool Adafruit_PN532::goToSoftSleep(void) {
   pn532_packetbuffer[0] = PN532_COMMAND_POWERDOWN;
   pn532_packetbuffer[1] = PN532_WAKEUPSOURCE;  // #define PN532_WAKEUPSOURCE                   (0x20)
   sendCommandCheckAck(pn532_packetbuffer, 1);
   delay(20);
}


and after readPassiveTargetID has timed out (still consuming 60mA), this function drops the current comsumption to 12mA...
Still not in soft-sleep..

JeremysIon
 
Posts: 13
Joined: Sun Apr 02, 2017 4:50 am

Re: PN532 Breakout Board Powerdown & Wake up

by JeremysIon on Wed Oct 02, 2019 9:29 am

With Elechouse's PN532 board there is RSTPD_N on the back and if I LOW this pin, the NFC module stops reading, LED on board shuts down and the readPassiveTargetID starts to give "TIMEOUT!".

How to wake this back to live?

JeremysIon
 
Posts: 13
Joined: Sun Apr 02, 2017 4:50 am

Re: PN532 Breakout Board Powerdown & Wake up

by adafruit_support_mike on Wed Oct 02, 2019 12:37 pm

I’m afraid we don’t know that board. Your best bet would be to check with the maker.

adafruit_support_mike
 
Posts: 61407
Joined: Thu Feb 11, 2010 2:51 pm

Re: PN532 Breakout Board Powerdown & Wake up

by JeremysIon on Sat Oct 05, 2019 11:03 am

One more thing, please.

I instanciate nfc class in the code at the beginnig:

Code: Select all | TOGGLE FULL SIZE
#define PN532_SCK  (5)
#define PN532_MISO (6)
#define PN532_MOSI (7)
#define PN532_SS   (8)
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);


but what if i Want the delete the object and release the PINs.
I can not just "delete nfc" and the reinstaticate it..

I need to free the PINS in sleepMode for power saver and the in wake up, make the module alive again.
I ground (low) the RSTPDN" in the back of the module for short period of time. This save A LOT of current,
and " nfc.SAMConfig();" brings it back to live in wakeUp..

JeremysIon
 
Posts: 13
Joined: Sun Apr 02, 2017 4:50 am

Re: PN532 Breakout Board Powerdown & Wake up

by JeremysIon on Sun Oct 06, 2019 5:42 am

Above Sleep() function works sort of with Adafruit libary

Code: Select all | TOGGLE FULL SIZE
bool Adafruit_PN532::GotoSleep(void) {   
  pn532_packetbuffer[0] = PN532_COMMAND_POWERDOWN;
  sendCommandCheckAck(pn532_packetbuffer, 1);
  return 0;   
}


but it still leaveas 18mA when the ATmega328p is totally sleep (0.6mA without the PN532).
If I disconnect the RSTO pin compleately, system does not seem to even need it, the power consumption is 13mA.

Code: Select all | TOGGLE FULL SIZE
nfc.GotoSleep();
 power_spi_disable();

JeremysIon
 
Posts: 13
Joined: Sun Apr 02, 2017 4:50 am

Re: PN532 Breakout Board Powerdown & Wake up

by JeremysIon on Wed Oct 09, 2019 3:56 am

Halfway SOLUTUION IS HERE!

1. Modify the Adafruit_PN532.cpp & Adafruit_PN532.h files as follows by ADDING somewhere fit:

Adafruit_PN532.cpp ADD:
Code: Select all | TOGGLE FULL SIZE
uint32_t Adafruit_PN532::writeRegister(uint16_t address, uint8_t value) {
   pn532_packetbuffer[0] = PN532_COMMAND_WRITEREGISTER;
   pn532_packetbuffer[1] = address >> 8;
   pn532_packetbuffer[2] = address & 0xff;
   pn532_packetbuffer[3] = value;

   if (!sendCommandCheckAck(pn532_packetbuffer, 4))
      return 0;

   return 1;
}


Adafruit_PN532.h ADD:
Code: Select all | TOGGLE FULL SIZE
uint32_t writeRegister(uint16_t address, uint8_t value);


2. Just after initialization, change the default standby mode to Power down like this :
Code: Select all | TOGGLE FULL SIZE
nfc.SAMConfig(); 
Serial.println("Waiting for an ISO14443A Card ...");
nfc.writeRegister(0x02FC,0x02);


3. In your code when you are putting the system into Sleep, call
Code: Select all | TOGGLE FULL SIZE
nfc.SAMConfig(); 


== PN532 module will go to Soft-powerpown mode and my multimeter dropped form 80mA to 4.8mA.
Boards power LED consumes about 2mA anyhow just ...CUT THE POWER LED OFF!
Use sharp knife and just cut the small lead to LED that comes form the BIG VCC bus..
After this, power consumption drops form 4.8mA to 1.55mA!!!


4. In yout system WakeUp procedure, just call
Code: Select all | TOGGLE FULL SIZE
 nfc.SAMConfig();

again and PN532 is alive to read passive Tags in a heart beat.

Still no good enough!


If I after SAMConfig command, set the GPIO pins of SPI-interface to INPUT

Code: Select all | TOGGLE FULL SIZE
pinMode(PN532_SCK, INPUT_PULLUP);
pinMode(PN532_MISO, INPUT_PULLUP);
pinMode(PN532_MOSI, INPUT_PULLUP);
pinMode(PN532_SS, INPUT_PULLUP);


the power consumption drops from 1.55mA to 0.4mA! but I do not know how to restore from that point on..

JeremysIon
 
Posts: 13
Joined: Sun Apr 02, 2017 4:50 am

Re: PN532 Breakout Board Powerdown & Wake up

by TI994A on Sun Jul 26, 2020 4:01 am

Hello,

I know this thread might be a little old, but has anyone been able to power down the PN532 with the Circuit Python library with an I2C interface?

I'm trying to use call_function with the COMMAND_POWERDOWN after writing to an NFC successfully to turn it off.

pn532.call_function(_COMMAND_POWERDOWN, response_length=2, params=[0x80], timeout=2)

Also, since _COMMAND_POWERDOWN is not defined for some reason, I use 0x16. Do I need to import something else in my code?
response = pn532.call_function(0x16, response_length=2, params=[0x80], timeout=2)
It returns 0x00.

Anyone know where is 0x16 for powering down defined in the NFC data sheet? I can't seem to find it.
https://www.nxp.com/docs/en/nxp/data-sh ... 532_C1.pdf

Here's my abbreviated code:
pn532 = PN532_I2C(i2c, debug=False, reset=None, req=None)
ic, ver, rev, support = pn532.firmware_version
pn532.SAM_configuration()
uid = pn532.read_passive_target(timeout=1)
nfc_prog_result = pn532.ntag2xx_write_block(block_num, block_data)
response = pn532.call_function(0x16, response_length=2, params=[0x80], timeout=2)

Any suggestions would be great!

Thanks in advance
Brian

TI994A
 
Posts: 12
Joined: Mon Jun 29, 2020 2:59 pm

Please be positive and constructive with your questions and comments.