RFID Works Independently, but Stops Working When Sending Data via LoRa

Hello, I am facing an issue when running an RFID card with LoRa Heltec (ESP32 with LoRa and screen). It works perfectly, reading the card and displaying the result on the screen. However, when I add the functionality to send this data via LoRa, it fails to send and does not even read the card.
I used this code:
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <LoRa.h> // إضافة مكتبة LoRa

// OLED Display Configuration
#define OLED_SDA 4
#define OLED_SCL 15
#define OLED_RST 16
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

// RFID Configuration
#define SS_PIN 5
#define RST_PIN 22
MFRC522 mfrc522(SS_PIN, RST_PIN);

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);

// LoRa Configuration
#define LORA_SS 18
#define LORA_RST 14
#define LORA_DIO0 26

void setup() {
Serial.begin(115200); // بدء الاتصال التسلسلي

// Initialize SPI for both RFID and OLED
SPI.begin();

// Initialize RFID
mfrc522.PCD_Init();

// Initialize OLED Display
pinMode(OLED_RST, OUTPUT);
digitalWrite(OLED_RST, LOW);
delay(20);
digitalWrite(OLED_RST, HIGH);
Wire.begin(OLED_SDA, OLED_SCL);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("OLED Initialization Failed!");
    while (true);
}

// Display initial message
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(20, 25);
display.print("No Card");
display.display();

}

void loop() {
display.clearDisplay();
display.setCursor(20, 25);
display.setTextSize(2);

// عرض "No Card" إذا لم تكن هناك بطاقة
display.print("No Card");

// التحقق من وجود بطاقة جديدة
if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
    Serial.println("Card Detected");  // عرض "Card Detected" في Serial Monitor
    display.clearDisplay();
    display.setCursor(20, 25);
    display.print("Card Detected");

    // تفعيل LoRa بعد اكتشاف البطاقة فقط
    LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO0);
    if (!LoRa.begin(915E6)) {  // تأكد من التردد المناسب (915 MHz في هذا الكود)
        Serial.println("LoRa Initialization Failed!");
        while (true);
    }
    Serial.println("LoRa Initialized");

    // إرسال البيانات عبر LoRa
    LoRa.beginPacket();
    LoRa.print("Card Detected");
    LoRa.endPacket();
    Serial.println("Sent via LoRa");

} else {
    Serial.println("No Card");  // عرض "No Card" في Serial Monitor إذا لم تكن هناك بطاقة
}

display.display();  // تحديث الشاشة
delay(1000); // تحديث كل ثانية

}

And this is the error message :

11:56:12.129 -> No Card

11:56:13.197 -> No Card

11:56:14.221 -> No Card

11:56:15.248 -> Card Detected

11:56:15.284 -> LoRa Initialization Failed!

I moved your topic to an appropriate forum category @fatimamoh

In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

No reply for 2 days and that's unusual.
Please post schematics, not Fritzing, all according to How to get the best out of this forum - Development Tools / IDE 1.x - Arduino Forum

there are a number of Heltec ESP32 modules with onboard Lora and display - which is yours? give a link ?
the code of post 1 is unreadable - have another go at posting it using code tags </>, e.g. select < CODE/ > and paste the code or text where it says “type or paste code here”

how have you connected and powered the RFID reader?

what pin are you using for the RFID CS (Chip Select)
Lora is using GPIO18 - RFID CS must be different

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.