RFID MFRC522 reader doesn't read tag when connected solely to power adapter

Hi! I’m trying to send data, when an RFID Reader reads a tag, from one Arduino to another (Using I2C protocal).

So the Arduino UNO that the RFID reader is connected to transmits data to the second Arduino just fine when it’s connected to the USB serial port. But when I try to hook it up to a power adapter (I’ve tried 5V 1A, 9V 1A, 12V 2A) solely and try the reader to read a tag, it doesn’t scan anything. But starts working just fine when I connect it back to the USB serial port.

I don’t understand the problem of why the RFID reader only scans tags when its connected to the USB serial port and not when solely on an adapter. It’s not an issue of the reader not being properly connected otherwise the reader wouldn’t even work on a USB port. Here’s the code I wrote:

MASTER ARDUINO UNO(The Arduino the MFRC522 RFID Reader is connected to):

#include <SPI.h>
#include <MFRC522.h>
#include <FileIO.h>
#include <Wire.h>

#define RST_PIN 9 // Configurable, see typical pin layout above
#define SS_PIN 10 // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

void setup() {

Serial.begin(9600); // Initialize serial communications with the PC
Wire.begin(); // join i2c bus (address optional for master)
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
pinMode(50,INPUT);

}

void loop() {

// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}

String content= “”;
byte letter;
for (byte i=0; i<mfrc522.uid.size;i++)
{

content.concat(String(mfrc522.uid.uidByte < 0x10 ? “0”: " "));
_ content.concat(String(mfrc522.uid.uidByte , HEX));_
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) ==“F0 E8 17 7C”)
{
* Wire.beginTransmission(8); // transmit to device #8*
* Wire.write(“TAG DETECTED”);*
* Wire.endTransmission(); // stop transmitting*

}
SLAVE ARDUINO (Where data is being transmitted):
#include <Wire.h>
void setup() {
* Wire.begin(8); // join i2c bus with address #8*
* Wire.onReceive(receiveEvent); // register event*
* Serial.begin(9600); // start serial for output*
}
void loop() {
* delay(100);*
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
* while ( Wire.available()) { // loop through all but the last*
* char c = Wire.read(); // receive byte as a character*
* Serial.print(c); // print the character*

* }*

}

Read the how to use this forum sticky post to find out how to post code correctly, look at what you have posted.

Have you connected the ground of the two Arduinos together?

Sorry about that! I'm new to this forum. Will take care in the future.
And no, the second Arduino is connected via USB cable to my pc so that data transferred from the first Arduino (The one that the RFID reader is connected to) can be seen on the serial monitor. Basically, the RFID Reader's 3.3V pin is connected to the Arduino's 3.3V pin and its ground pin to the GND pin on the Arduino and the Arduino itself is powered by an adapter.

In which case you are going to have to explain that wiring in a lot more detail, that means a schematic and a photograph.

Most of the time when things do not work off batteries it is because their is not a contiguous ground signal.