Sketch does not run on arduino pro mini clone when starting with external power

I have one of those cheap arduino pro mini clones off ebay and I’m having trouble getting it to work with external power.

I have a RFID reader (over i2c) and a rotary encoder, and it’s supposed to send data over bluetooth that Processing can pick up.

But the sketch, or the RFIDreader doesn’t start when i plug in the external power supply (5V connected to RAWpin)

If I plug in the USBcable, the sketch and the reader starts, and i can unplug the cable and everything runs smooth over bluetooth.

But how can I make it run without plugging the USB-cable in and out? Some issues with the reset?
I’ve seen people having this trouble, but havent found a solution

Tried to wire Rx to ground with a 10k resistor, but it didn’t work either


#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <Encoder.h>

// If using the breakout with SPI, define the pins for SPI communication.
#define PN532_SCK  (2)
#define PN532_MOSI (3)
#define PN532_SS   (4)
#define PN532_MISO (5)
int state=0;
// If using the breakout or shield with I2C, define just the pins connected
// to the IRQ and reset lines.  Use the values below (2, 3) for the shield!
#define PN532_IRQ   (5)
#define PN532_RESET (6)  // Not connected by default on the NFC Shield

int pushButton = 4;
Encoder myEnc(2, 3);
long oldPosition  = -999;

// Uncomment just _one_ line below depending on how your breakout or shield
// is connected to the Arduino:

// Use this line for a breakout with a SPI connection:
//Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);

// Use this line for a breakout with a hardware SPI connection.  Note that
// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
// hardware SPI SCK, MOSI, and MISO pins.  On an Arduino Uno these are
// SCK = 13, MOSI = 11, MISO = 12.  The SS line can be any digital IO pin.
//Adafruit_PN532 nfc(PN532_SS);

// Or use this line for a breakout or shield with an I2C connection:
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

void setup(void) {
  pinMode(pushButton, INPUT_PULLUP);

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  // Set the max number of retry attempts to read from a card
  // This prevents us from waiting forever for a card, which is
  // the default behaviour of the PN532.
  // configure board to read RFID tags
  Serial.println("Waiting for an ISO14443A card");

void loop(void) {
    long newPosition =;
  if (newPosition != oldPosition) {
    if (newPosition < oldPosition){

    if (newPosition > oldPosition){

    oldPosition = newPosition;
  int buttonState = digitalRead(pushButton);
  // print out the state of the button:
  delay(1);        // delay in between reads for stability
  if (buttonState==0){
  boolean success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };	// Buffer to store the returned UID
  uint8_t uidLength;				// Length of the UID (4 or 7 bytes depending on ISO14443A card type)
  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
  if (success) {
  if (state==0){
    for (uint8_t i=0; i < uidLength; i++) 
      Serial.print("0x");Serial.print(uid[i], HEX); 
  else if (state==1)
    // PN532 probably timed out waiting for a card

Isolated the problem to the RFID reader. There's something going on in the setup

Blink sketch and rotary encoder library works fine on its own.