M7E Hecto not working with Arduino

^Like suggested above, solder the wires or headers and try it then (with the other 2 changes as well) :wink:

Hello,

I’ve really tried everything, and I’ve been stuck for two weeks now.

It seems there’s an issue with the module initialization.

When the ESP32 requests the firmware version from the RFID M7 E HECTO reader, it either responds with incorrect data or doesn’t respond at all.

/*
  Reading multiple RFID tags, simultaneously!
  By: Nathan Seidle @ SparkFun Electronics
  Date: October 3rd, 2016
  https://github.com/sparkfun/Simultaneous_RFID_Tag_Reader

  Constantly reads and outputs any detected tags.

  If using the Simultaneous RFID Tag Reader (SRTR) shield, ensure the serial slide
  switch is in the 'SW-UART' position.
*/

// Library for controlling the RFID module
#include "SparkFun_UHF_RFID_Reader.h"
#include <HardwareSerial.h>

// Define custom pins for UART2 (on the Makerfabs ESP32 UWB DW3000)
// To avoid conflicts with the USB serial port (GPIO1 and GPIO3), we use different pins here.
#define RFID_RX_PIN 16  // GPIO16 used as RX (should be connected to the module's TX)
#define RFID_TX_PIN 17  // GPIO17 used as TX (should be connected to the module's RX)

#define moduleType ThingMagic_M7E_HECTO
// Define the baud rate for communication with the RFID module
#define rfidBaud 115200 

// Create the RFID module object
RFID rfidModule;

// Use ESP32's UART2 for communication with the RFID module
HardwareSerial rfidSerial(2);

// Select the module type

void setup() {
  Serial.begin(115200);
  while (!Serial); // Wait for the serial port to be active

  Serial.println("=== Initializing RFID Module ===");
  if (setupRfidModule(rfidBaud) == false) {
    Serial.println(F("The module did not respond. Check the wiring."));
    while (1); // Stop the program
  }
  
  Serial.println("RFID module successfully initialized.");

  // Set the region
  rfidModule.setRegion(REGION_EUROPE); 
  Serial.println("RFID region set to europe
![Capture d’écran 2025-02-10 à 21.49.18|690x108](upload://2j7Ydk6X9GY1bHiRWqQpoUEzZfK.png)
.");
  
  // Set the read power
  rfidModule.setReadPower(500); // 5.00 dBm
  Serial.println("Read power set to 500 (5.00 dBm).");
  
  Serial.println(F("Press any key to start scanning tags."));
  while (!Serial.available()); // Wait for user input
  Serial.read(); // Ignore the entered character
  
  Serial.println("Starting RFID scan...");
  rfidModule.startReading(); // Start reading tags
}

void loop() {
  if (rfidModule.check() == true) { // Check if new data is available
    Serial.println(F("Entered loop"));
    byte responseType = rfidModule.parseResponse(); // Parse the response
    if (responseType == RESPONSE_IS_KEEPALIVE) {
      Serial.println(F("Scanning (keep-alive)..."));
    }
    else if (responseType == RESPONSE_IS_TAGFOUND) {
      int rssi = rfidModule.getTagRSSI();         // Get RSSI
      long freq = rfidModule.getTagFreq();        // Get frequency
      long timeStamp = rfidModule.getTagTimestamp(); // Get timestamp
      byte tagEPCBytes = rfidModule.getTagEPCBytes(); // Get EPC size

      Serial.print(F("Tag found -> rssi["));
      Serial.print(rssi);
      Serial.print(F("] freq["));
      Serial.print(freq);
      Serial.print(F("] time["));
      Serial.print(timeStamp);
      Serial.print(F("] epc["));
      for (byte x = 0; x < tagEPCBytes; x++) {
        if (rfidModule.msg[31 + x] < 0x10) {
          Serial.print(F("0")); // Proper formatting
        }
        Serial.print(rfidModule.msg[31 + x], HEX);
        Serial.print(F(" "));
      }
      Serial.println(F("]"));
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE) {
      Serial.println("CRC Error");
    }
    else if (responseType == RESPONSE_IS_HIGHRETURNLOSS) {
      Serial.println("High return loss, check the antenna!");
    }
    else {
      Serial.println("Unknown error");
    }
  }
}

// RFID module setup function
boolean setupRfidModule(long baudRate) {
  Serial.println("Configuring the RFID module...");
  rfidModule.begin(rfidSerial, moduleType); // Start communication on the serial port

  // Check if the module is already connected
  rfidSerial.begin(baudRate);
  delay(100); // Wait for the port to open

  // Ignore initial bytes sent by the module
  while (rfidSerial.available()) {
    int discarded = rfidSerial.read();
    Serial.print("Ignored byte: ");
    Serial.println(discarded, HEX);
  }

  Serial.println("Retrieving firmware version...");
  rfidModule.getVersion();

  if (rfidModule.msg[0] == ERROR_WRONG_OPCODE_RESPONSE) {
    // If the module is continuously reading
    rfidModule.stopReading();
    Serial.println(F("Module is continuously reading. Stop requested..."));
    delay(1500);
  }
  else {
    Serial.println("Module is not in continuous reading mode, configuring baud rate...");
    rfidSerial.begin(115200); // Restart at 115200
    rfidModule.setBaud(baudRate); // Change the module baud rate
    rfidSerial.begin(baudRate);    // Restart with the new baud rate
    delay(250);
  }

  Serial.println("Testing connection...");
  rfidModule.getVersion();
  if (rfidModule.msg[0] != ALL_GOOD) {
    Serial.println(F("Connection test failed."));
    return false;
  }
  
  Serial.println("Connection test successful.");
  rfidModule.setTagProtocol(); // Set tag protocol (GEN2)
  Serial.println("Tag protocol set (GEN2).");
  rfidModule.setAntennaPort(); // Configure antenna port
  Serial.println("Antenna port configured.");
  
  Serial.println("RFID module setup complete.");
  return true;
}

Your diagram still shows reversed wiring for IO16 & 17…17/Rx on the ESP32 side goes to Tx on the M7E, ensure this is wired up right

Are things soldered? Share a photo of the actual setup/wiring

I have connected my M6E to an ESP32 thing today.

Hardware

RFID  ESP32 
-----------
GND   GND
VCC   5V / VUSB
TX    16 / RX (*1)
RX    17 / TX

Note *1) As I have an M6E, I had to include a resistor bridge as level-down shifter. The M7E does not need that as it is 3v3.

Note 2) The M6E (and I expect the M7E) is very sensitive to good power. Thus after connecting USB-plug, the M6E would not respond. I had to remove and reconnect the VCC to the M6E. Press reset and it all worked again. Not removing the USB connector, but just uploading a new sketch… it all worked.

Software
Took the original example1 from Sparkfun and made some changes on 2 places. It then worked as it should. They are indicated with ‘paulvha REMOVED’ and ‘paulvha ADDED.’ The sketch is attached as text-file.
RFID_ESP32.txt (6.5 KB)

Hello,

I tried what you suggested:

• Keeping the ESP32 connected to the computer,

• I unplugged the cable from the ESP32 that was connected to VCC on the RFID reader,

• I pressed RST for 10 seconds,

• Then I reconnected the cable and uploaded your code.

However, I still get the same error : Module failed to respond. Please check wiring.

(Note : I do not solder the cables to the ESP32 in case I need to move them.)

To check the power supply, I took some voltage measurements of the M7 E Hecto:

Between GND and VCC : 4.80V

Between RXI and GND : 2.49V

Between TXO and GND : 2.49V

Note that I am not using a standard ESP32, but an ESP32 DWM3000.

I don’t think this is the cause of the issue, but I wanted to mention it.



weird…
did you use my complete sketch (and thus also the changes in the function setupRfidModule(long baudRate)?
Is the orange wire connected to pin 16 ?

I looked at the solder on the RFID. I hope the connections are still working.

Leaving the pins loose in the holes on the esp32 side makes the connection very shoddy…if you’re worried about needing to move things around you can just solder some headers onto the esp32 board instead of direct wires…or even put a M/F wires on the esp32 side and then you can arrange them however you’d like

The RFID side of connections looks like it might work; if you know a friend that is skilled at soldering you might bug them for a favor. If you have a multimeter I’d test them for continuity and/or reflow the joints a bit

The orange wire is connected to pin 16.

I performed a continuity test for each wire, and all connections were successful .

Here is the code I uploaded :

/*
  Reading multiple RFID tags, simultaneously!
  By: Nathan Seidle @ SparkFun Electronics
  Date: October 3rd, 2016
  https://github.com/sparkfun/Simultaneous_RFID_Tag_Reader

  Constantly reads and outputs any tags heard

  If using the Simultaneous RFID Tag Reader (SRTR) shield, make sure the serial slide
  switch is in the 'SW-UART' position
*/

// Library for controlling the RFID module
#include "SparkFun_UHF_RFID_Reader.h"

// Create instance of the RFID module
RFID rfidModule;

// !!!!!!!!!!!! paulvha REMOVED
// By default, this example assumes software serial. If your platform does not
// support software serial, you can use hardware serial by commenting out these
// lines and changing the rfidSerial definition below
//#include <SoftwareSerial.h>
//SoftwareSerial softSerial(2, 3); //RX, TX

// Here you can specify which serial port the RFID module is connected to. This
// will be different on most platforms, so check what is needed for yours and
// adjust the definition as needed. Some examples are provided below
//#define rfidSerial softSerial // Software serial (eg. Arudino Uno or SparkFun RedBoard)
//#define rfidSerial Serial1 // Hardware serial (eg. ESP32 or Teensy)
// !!!!!!!!!!!!! paulvha END

// !!!!!!!!!!!!! paulvha ADDED
#include <HardwareSerial.h>
#define RFID_RX_PIN 16  // GPIO16 used as RX (should be connected to the module's TX)
#define RFID_TX_PIN 17  // GPIO17 used as TX (should be connected to the module's RX)
HardwareSerial rfidSerial(2);
// !!!!!!!!!!!!! paulvha END

// Here you can select the baud rate for the module. 38400 is recommended if
// using software serial, and 115200 if using hardware serial.
//#define rfidBaud 38400
#define rfidBaud 115200

// Here you can select which module you are using. This library was originally
// written for the M6E Nano only, and that is the default if the module is not
// specified. Support for the M7E Hecto has since been added, which can be
// selected below
//#define moduleType ThingMagic_M6E_NANO
#define moduleType ThingMagic_M7E_HECTO

void setup()
{
  Serial.begin(115200);
  while (!Serial); //Wait for the serial port to come online

  if (setupRfidModule(rfidBaud) == false)
  {
    Serial.println(F("Module failed to respond. Please check wiring."));
    while (1); //Freeze!
  }

  rfidModule.setRegion(REGION_NORTHAMERICA); //Set to North America

  rfidModule.setReadPower(500); //5.00 dBm. Higher values may caues USB port to brown out
  //Max Read TX Power is 27.00 dBm and may cause temperature-limit throttling

  Serial.println(F("Press a key to begin scanning for tags."));
  while (!Serial.available()); //Wait for user to send a character
  Serial.read(); //Throw away the user's character

  rfidModule.startReading(); //Begin scanning for tags
}

void loop()
{
  if (rfidModule.check() == true) //Check to see if any new data has come in from module
  {
    byte responseType = rfidModule.parseResponse(); //Break response into tag ID, RSSI, frequency, and timestamp

    if (responseType == RESPONSE_IS_KEEPALIVE)
    {
      Serial.println(F("Scanning"));
    }
    else if (responseType == RESPONSE_IS_TAGFOUND)
    {
      //If we have a full record we can pull out the fun bits
      int rssi = rfidModule.getTagRSSI(); //Get the RSSI for this tag read

      long freq = rfidModule.getTagFreq(); //Get the frequency this tag was detected at

      long timeStamp = rfidModule.getTagTimestamp(); //Get the time this was read, (ms) since last keep-alive message

      byte tagEPCBytes = rfidModule.getTagEPCBytes(); //Get the number of bytes of EPC from response

      Serial.print(F(" rssi["));
      Serial.print(rssi);
      Serial.print(F("]"));

      Serial.print(F(" freq["));
      Serial.print(freq);
      Serial.print(F("]"));

      Serial.print(F(" time["));
      Serial.print(timeStamp);
      Serial.print(F("]"));

      //Print EPC bytes, this is a subsection of bytes from the response/msg array
      Serial.print(F(" epc["));
      for (byte x = 0 ; x < tagEPCBytes ; x++)
      {
        if (rfidModule.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print
        Serial.print(rfidModule.msg[31 + x], HEX);
        Serial.print(F(" "));
      }
      Serial.print(F("]"));

      Serial.println();
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE)
    {
      Serial.println("Bad CRC");
    }
   // else if (responseType == RESPONSE_IS_HIGHRETURNLOSS)
   // {
    //  Serial.println("High return loss, check antenna!");
    //}
    else
    {
      //Unknown response
      Serial.println("Unknown error");
    }
  }
}

//Gracefully handles a reader that is already configured and already reading continuously
//Because Stream does not have a .begin() we have to do this outside the library
boolean setupRfidModule(long baudRate)
{
  rfidModule.begin(rfidSerial, moduleType); //Tell the library to communicate over serial port

  //Test to see if we are already connected to a module
  //This would be the case if the Arduino has been reprogrammed and the module has stayed powered

  // !!!!!!! paulvha REMOVED
  //rfidSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
  //delay(100); //Wait for port to open
  // !!!!!!! paulvha END
  
  // !!!!!!! paulvha ADDED
  rfidSerial.begin(baudRate, SERIAL_8N1, RFID_RX_PIN, RFID_TX_PIN);
  while(!rfidSerial); //Wait for port to open
  //! !!!!!! paulvha END
  
  //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this.
  while (rfidSerial.available())
    rfidSerial.read();

  rfidModule.getVersion();

  if (rfidModule.msg[0] == ERROR_WRONG_OPCODE_RESPONSE)
  {
    //This happens if the baud rate is correct but the module is doing a ccontinuous read
    rfidModule.stopReading();

    Serial.println(F("Module continuously reading. Asking it to stop..."));

    delay(1500);
  }
  else
  {
    //The module did not respond so assume it's just been powered on and communicating at 115200bps
    rfidSerial.begin(115200); //Start serial at 115200

    rfidModule.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg

    rfidSerial.begin(baudRate); //Start the serial port, this time at user's chosen baud rate

    delay(250);
  }

  //Test the connection
  rfidModule.getVersion();
  if (rfidModule.msg[0] != ALL_GOOD)
    return false; //Something is not right

  //The module has these settings no matter what
  rfidModule.setTagProtocol(); //Set protocol to GEN2

  rfidModule.setAntennaPort(); //Set TX/RX antenna ports to 1

  return true; //We are ready to rock
}

It can’t be a good connection on the ESP32 side if they are just floating in the PTH holes…I promise. There is barely any passive tension. …but this is actually good news! Solder some headers, or some other wiring arrangement, and re-try

I am running low on ideas.
Run the sketch below to make sure the RX and TX are working with a simple echo test. Only connect a single wire between pin 16 and 17.


#include <HardwareSerial.h>
#define RFID_RX_PIN 16  // GPIO16 used as RX (should be connected to the module's TX)
#define RFID_TX_PIN 17  // GPIO17 used as TX (should be connected to the module's RX)
HardwareSerial SerialTest(2);

void setup() {
  Serial.begin(115200);
  while (!Serial); //Wait for the serial port to come online
  
  Serial.print(F("Test Serial port"));
}

void loop() {
  TestPort(38400);
  TestPort(115200);
}

void TestPort(int speed)
{

  while (Serial.available())
    Serial.read();
    
  Serial.print(F("\nConnect TX-Pin: "));
  Serial.print (RFID_TX_PIN);
  Serial.print(" and RX-pin: ");
  Serial.print (RFID_RX_PIN);
  Serial.println(" together.");
  Serial.print("Press <ENTER> to begin testing on speed: ");
  Serial.println(speed);
  
  while (!Serial.available());
  
  SerialTest.begin(speed, SERIAL_8N1, RFID_RX_PIN, RFID_TX_PIN);
  while (!SerialTest);
  
  while (SerialTest.available())
    SerialTest.read();
  
  Serial.println("Sending : Test SerialPort at the speed set");
  
  SerialTest.println("Test SerialPort at the speed set");
  delay(100);
  
  if (SerialTest.available()) {
    Serial.print("Received: ");
    while (SerialTest.available())
      Serial.print((char)SerialTest.read());
  }
 }

if that does not work, try if you have another MCU. And double check the connection/soldering as earlier indicated.

I’ve solidified the connection by soldering header pins on the RFID reader and the ESP32.
But while debugging, I noticed that :
Firmware version (displayed byte by byte):

23:20:09.993 → Byte 0: 0x01
23:20:09.993 → Byte 1: 0x00
23:20:09.993 → Byte 2: 0x03
23:20:09.993 → Byte 3: 0x1D
23:20:09.993 → Byte 4: 0x0C
23:20:09.993 → Byte 5: 0xC2
23:20:10.025 → Byte 6: 0x00
23:20:10.025 → Byte 7: 0xA4
23:20:10.025 → Byte 8: 0x60
23:20:10.025 → Byte 9: 0x00

Complete content of rfidModule.msg[]:

23:20:10.025 → Byte 0: 0x01 Byte 1: 0x00 Byte 2: 0x03 Byte 3: 0x1D Byte 4: 0x0C Byte 5: 0xC2 Byte 6: 0x00 Byte 7: 0xA4 Byte 8: 0x60 Byte 9: 0x00

In rfidModule.msg [ ] there is only the firmware version, without a status code.

The library is supposed to place a first byte in rfidModule.msg[0] to indicate whether the firmware version is correct or not.

But in my case, in rfidModule.msg[ ], there is only the firmware version.

Did you try my sketch for echo?

The msg - buffer in the Sparkfun driver is used for BOTH sending and receiving messages.

The first 5 bytes is reflecting the REQUEST for version info : FF 00 03 1D 0C
The first byte has been overwritten with an 0x01 (ERROR_COMMAND_RESPONSE_TIMEOUT) because there was no responds

The version responds from the M7E should be something like :
FF 14 03 00 00 14 12 08 00 30 00 00 02 20 19 06 10 01 09 01 11 00 00 00 10 BC 91

There is NO check whether the version info is correct or not, there is only a check that the exchange happened correctly: 00 00 on spot 4 and 5 in the responds example above. These bytes are the first bytes of the responds stored in the msg buffer.

The other 5 bytes seems to be left over from earlier messages (like setting the baudrate)

In beginning of function setupRfidModule() add a line : rfidModule.enableDebugging(Serial);
You can then see what information is send and what the responds is.
I had once in the past an MCU with timing issues and did not work unless debug was enabled.

1 Like

Hi,

I would like to sincerely thank you for your valuable help!

Initially, I performed an echo test on the RX 16 and TX 17 pins of the ESP32. Data transmission was working fine, but reception was not. After several attempts, I tested other pins and found that pins 22 and 23 allowed for a functional echo.

I then reconfigured my code with these new pins, uploaded the program again, and this time, everything works perfectly! :tada:

/*
  Reading multiple RFID tags, simultaneously!
  By: Nathan Seidle @ SparkFun Electronics
  Date: October 3rd, 2016
  https://github.com/sparkfun/Simultaneous_RFID_Tag_Reader

  Constantly reads and outputs any tags heard

  If using the Simultaneous RFID Tag Reader (SRTR) shield, make sure the serial slide
  switch is in the 'SW-UART' position
*/

// Library for controlling the RFID module
#include "SparkFun_UHF_RFID_Reader.h"

// Create instance of the RFID module
RFID rfidModule;

// !!!!!!!!!!!! paulvha REMOVED
// By default, this example assumes software serial. If your platform does not
// support software serial, you can use hardware serial by commenting out these
// lines and changing the rfidSerial definition below
//#include <SoftwareSerial.h>
//SoftwareSerial softSerial(2, 3); //RX, TX

// Here you can specify which serial port the RFID module is connected to. This
// will be different on most platforms, so check what is needed for yours and
// adjust the definition as needed. Some examples are provided below
//#define rfidSerial softSerial // Software serial (eg. Arudino Uno or SparkFun RedBoard)
//#define rfidSerial Serial1 // Hardware serial (eg. ESP32 or Teensy)
// !!!!!!!!!!!!! paulvha END

// !!!!!!!!!!!!! paulvha ADDED
#include <HardwareSerial.h>

#define RESET_PIN 13
#define RFID_RX_PIN 22 // GPIO16 used as RX (should be connected to the module's TX)
#define RFID_TX_PIN 23  // GPIO17 used as TX (should be connected to the module's RX)
HardwareSerial rfidSerial(1);
// !!!!!!!!!!!!! paulvha END

// Here you can select the baud rate for the module. 38400 is recommended if
// using software serial, and 115200 if using hardware serial.
//#define rfidBaud 38400
#define rfidBaud 115200

// Here you can select which module you are using. This library was originally
// written for the M6E Nano only, and that is the default if the module is not
// specified. Support for the M7E Hecto has since been added, which can be
// selected below
//#define moduleType ThingMagic_M6E_NANO
#define moduleType ThingMagic_M7E_HECTO

void setup()
{
  delay(3000);
  Serial.begin(115200);

  while (!Serial); //Wait for the serial port to come online


  if (setupRfidModule(rfidBaud) == false)
  {
    Serial.println(F("Module failed to respond. Please check wiring."));
    while (1); //Freeze!
  }

  rfidModule.setRegion(REGION_NORTHAMERICA); //Set to North America

  rfidModule.setReadPower(500); //5.00 dBm. Higher values may caues USB port to brown out
  //Max Read TX Power is 27.00 dBm and may cause temperature-limit throttling

  Serial.println(F("Press a key to begin scanning for tags."));
  while (!Serial.available()); //Wait for user to send a character
  Serial.read(); //Throw away the user's character

  rfidModule.startReading(); //Begin scanning for tags
}

void loop()
{
  if (rfidModule.check() == true) //Check to see if any new data has come in from module
  {
    byte responseType = rfidModule.parseResponse(); //Break response into tag ID, RSSI, frequency, and timestamp

    if (responseType == RESPONSE_IS_KEEPALIVE)
    {
      Serial.println(F("Scanning"));
    }
    else if (responseType == RESPONSE_IS_TAGFOUND)
    {
      //If we have a full record we can pull out the fun bits
      int rssi = rfidModule.getTagRSSI(); //Get the RSSI for this tag read

      long freq = rfidModule.getTagFreq(); //Get the frequency this tag was detected at

      long timeStamp = rfidModule.getTagTimestamp(); //Get the time this was read, (ms) since last keep-alive message

      byte tagEPCBytes = rfidModule.getTagEPCBytes(); //Get the number of bytes of EPC from response

      Serial.print(F(" rssi["));
      Serial.print(rssi);
      Serial.print(F("]"));

      Serial.print(F(" freq["));
      Serial.print(freq);
      Serial.print(F("]"));

      Serial.print(F(" time["));
      Serial.print(timeStamp);
      Serial.print(F("]"));

      //Print EPC bytes, this is a subsection of bytes from the response/msg array
      Serial.print(F(" epc["));
      for (byte x = 0 ; x < tagEPCBytes ; x++)
      {
        if (rfidModule.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print
        Serial.print(rfidModule.msg[31 + x], HEX);
        Serial.print(F(" "));
      }
      Serial.print(F("]"));

      Serial.println();
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE)
    {
      Serial.println("Bad CRC");
    }
   // else if (responseType == RESPONSE_IS_HIGHRETURNLOSS)
   // {
    //  Serial.println("High return loss, check antenna!");
    //}
    else
    {
      //Unknown response
      Serial.println("Unknown error");
    }
  }
}

//Gracefully handles a reader that is already configured and already reading continuously
//Because Stream does not have a .begin() we have to do this outside the library
boolean setupRfidModule(long baudRate)
{
  /*
  pinMode(RESET_PIN, OUTPUT);
  digitalWrite(RESET_PIN, LOW); // Pull low to reset
  delay(100); // Keep it low for 100ms
  digitalWrite(RESET_PIN, HIGH); // Release reset
*/
  rfidModule.enableDebugging(Serial);
  Serial.println("1");
  rfidModule.begin(rfidSerial, moduleType); //Tell the library to communicate over serial port
  Serial.println("2");

  //Test to see if we are already connected to a module
  //This would be the case if the Arduino has been reprogrammed and the module has stayed powered

  // !!!!!!! paulvha REMOVED
  //rfidSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
  //delay(100); //Wait for port to open
  // !!!!!!! paulvha END
  
  // !!!!!!! paulvha ADDED
  rfidSerial.begin(baudRate, SERIAL_8N1, RFID_RX_PIN, RFID_TX_PIN);
  Serial.println("3");
  while(!rfidSerial); //Wait for port to open
  //! !!!!!! paulvha END
  
  //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this.
  while (rfidSerial.available())
    rfidSerial.read();

  Serial.println("4");
  rfidModule.getVersion();
  Serial.println("5");

  if (rfidModule.msg[0] == ERROR_WRONG_OPCODE_RESPONSE)
  {
    //This happens if the baud rate is correct but the module is doing a ccontinuous read
    rfidModule.stopReading();

    Serial.println(F("Module continuously reading. Asking it to stop..."));

    delay(1500);
  }
  else
  {
    Serial.println("6");
  //The module did not respond so assume it's just been powered on and communicating at 115200bps
    rfidSerial.begin(115200); //Start serial at 115200

    rfidModule.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg

    rfidSerial.begin(baudRate); //Start the serial port, this time at user's chosen baud rate

    delay(250);
  }

  //Test the connection
  rfidModule.getVersion();
  Serial.println("7");
  if (rfidModule.msg[0] != ALL_GOOD)
  {  
    Serial.println("8");
    return false; //Something is not right
  }

  Serial.println("9");
  //The module has these settings no matter what
  rfidModule.setTagProtocol(); //Set protocol to GEN2

  rfidModule.setAntennaPort(); //Set TX/RX antenna ports to 1

  return true; //We are ready to rock
}

A huge thank you to all of you for your advice and support!

2 Likes

Cool. great to hear it now works.

1 Like