SparkFun Simultaneous RFID Reader - M6E Nano with ESP32 Thing

I want to connect my ESP32 Thin to M6E Nano RFID Reader board. The getting started Guide is only describing the procedure of connection for Arduino and USB to serial adapters. So I loaded the examples from the Arduino library to the Esp32. But the ESP 32 don’t Support SOftware Serial so I tried to connect via Hardware Serial. I connected GPIO17(TX) to Pin 3 and GPIO16(RX) to Pin 2 and Change the Use of the SoftwareSerial in the Demo Code to Serial2 (the Hardwareserial). Now I don’t get a connection to the board. It’s printing the Board is not Responding. I also tried to change Rx and Tx and I also tried to use the mounting places for the USB to serial converter. But I had no success until now. The power supply is working and the power LED of the board is shining red. I also tried every position of The HW/SW switch.

So how can I get the Arduino samples to work with the ESP32.

Arduino Code is down below.

Thank’s in advance.

/*
  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
*/

#include <HardwareSerial.h>

#include "SparkFun_UHF_RFID_Reader.h" //Library for controlling the M6E Nano module
RFID nano; //Create instance

void setup()
{
  Serial.begin(115200);
  while (!Serial); //Wait for the serial port to come online
  Serial2.begin(38400);
  while (!Serial2); //Wait for the serial port to come online
  if (setupNano(38400) == false) //Configure nano to run at 38400bps
  {
    Serial.println(F("Module failed to respond. Please check wiring."));
    while (1); //Freeze!
  }

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

  nano.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

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

void loop()
{
  if (nano.check() == true) //Check to see if any new data has come in from module
  {
    byte responseType = nano.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 = nano.getTagRSSI(); //Get the RSSI for this tag read

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

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

      byte tagEPCBytes = nano.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 (nano.msg[31 + x] < 0x10) Serial.print(F("0")); //Pretty print
        Serial.print(nano.msg[31 + x], HEX);
        Serial.print(F(" "));
      }
      Serial.print(F("]"));

      Serial.println();
    }
    else if (responseType == ERROR_CORRUPT_RESPONSE)
    {
      Serial.println("Bad CRC");
    }
    else
    {
      //Unknown response
      Serial.print("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 setupNano(long baudRate)
{
  nano.begin(Serial2); //Tell the library to communicate over software 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
  //softSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
  //while (softSerial.isListening() == false); //Wait for port to open

  //About 200ms from power on the module will send its firmware version at 115200. We need to ignore this.
  while (Serial2.available()) Serial2.read();

  nano.getVersion();

  if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE)
  {
    //This happens if the baud rate is correct but the module is doing a ccontinuous read
    nano.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
    Serial2.begin(115200); //Start software serial at 115200

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

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

    delay(250);
  }

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

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

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

  return (true); //We are ready to rock
}

I have successfully connected the Nano to ESP32. Also Serial2, same way as you did. I connected the RX to pin 17, TX to pin 16, GND to GND and the Nano VCC to VUSB. As I use the serial connection pins, I set the switch on the NANO to HW-UART.

One aspect I run into was the level converter. As the Nano is providing 5V output, I only wanted 3V3 on the ESP RX-pin. I used an external bi-directional level converter from Sparkfun. That did not work well with the Nano. I ended up with 2 resistors on the Nano TX line. The 10K was connected to GND, the other side to 4k7 and pin 16 (rx). The other side of the 4k7 to the TX from the Nano. No need to have a level converter (up) on the Nano RX line as the ESP32 is sending 3v3. The Nano responded well to that.

I tried connecting same esp32 with the m6e nano but no luck. Can anyone provide the test code for esp32 and m6e??

Attached a version that I have just created and tested on ESP32 thing

Download attached file, change extension from .txt to .zip and extract the example1.ino

In the top of the sketch is information about how to connect the wires and the UART switch.

example1.zip (2.25 KB)

paulvha:
Attached a version that I have just created and tested on ESP32 thing

Download attached file, change extension from .txt to .zip and extract the example1.ino

In the top of the sketch is information about how to connect the wires and the UART switch.

Hi Paul,

I am following the exact recommendation from you to read RFID using ESP32 and SRTR. But I am still not successful. In the Serial monitor, I have the following message. On the one side of the 4k7 Register, I can measure 5V (Tx SRTR) and on the other side of 4k7 register, I can measure 3.3V. Which problems can you imagine for my case? Can you please share your project with detailed elaboration incl photos of the hardware setup (may be in other platforms like you tube)?

03:03:38.144 → ets Jun 8 2016 00:22:57

03:03:38.144 →

03:03:38.144 → rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

03:03:38.177 → configsip: 0, SPIWP:0xee

03:03:38.177 → clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

03:03:38.177 → mode:DIO, clock div:1

03:03:38.177 → load:0x3fff0018,len:4

03:03:38.177 → load:0x3fff001c,len:1216

03:03:38.177 → ho 0 tail 12 room 4

03:03:38.177 → load:0x40078000,len:9720

03:03:38.177 → ho 0 tail 12 room 4

03:03:38.177 → load:0x40080400,len:6352

03:03:38.177 → entry 0x400806b8

03:03:42.295 → Module failed to respond. Please check wiring.

hi

Attached some pictures

I am running into the same problems in this thread. My system is using an ESP32 dev kit and I tried both the sparkfun level shifter and the voltage divider fix in this thread and neither worked.

I tried using the Universal Reader Assistant software and that worked when I used the 5V logic level setting on my serial reader. However, when I used 3.3V logic and an external power source I could get it to connect to the software but whenever I tried running a continues read it would run into an error saying it received the wrong op code. The level shifter and voltage divider fixes did not help with this issue either.

Anyone have any advice on how to fix these issues especially the ESP32 problem ?

you need to power the M6E with 5V.(use the VUSB) it is very sensitive to strong enough power supply. I always connect an extra LIPO battery to the Nano directly and even then. The level shifter will not work, you need to use a resistor / voltage divider on the TX line from the Nano as on the picture.

paulvha:
hi

Many Many Many Thanks! It works for me now!

I have not enough words to than you. Very happy now!

Best regards,

Paul

Attached some pictures

Hi, on the same topic.

I have ESP-WROOM-32 and I try to connect it to the reader and I get a message again and again that the reader is not responding.

My essays are from the reader to ESP are so -

VCC - 5V

GND - GND

TX0–2RESISTOR (RESISTOR = 4.7K - P16, RESISTOR = 10K - GND)

RX1 - P17

The switch in the reader is HW.

And in addition I connected an external POWER to the reader.

I tried using logic converter instead of resistors and it also does not work.

I’m trying to run the example of the code you brought here and yet I always get the message that the reader is not responding.

Can anyone guess what the problem is?

can you share pictures and the sketch ?

Hi, here are pictures of the connections.

I use the sketch you gave here in the comments above.

I have tried every possible way also on logic converter and for some reason it still does not work.

C:\Users\melod\Downloads\IMG_5554.jpg

From France another image with caption to make it clearer

The resistor voltage divider does not look to be correct. On side of the 10K should be indeed be connect to GND. Then connect to the other side of the 10K to the 510 + 5.1K AND to pin 16. Now connect the TX from the Nano to the other side of 510 + 5.1K. This way you have voltage divider of (5V / 15.6k) * 10K

I fixed the connection just like you said and it still does not work. Is there another problem that could be?

I will attach a picture of the new connections

hmmm… let’s try a couple of things

Power: Power the Nano from the ESP32 (5v). Do NOT use GND next to 5V, it should read CMD. As long as it is transmitting the 5V from USB should be enough. Make sure the power led is on.

sketch: share exactly the sketch that you use.

Sketch : just before calling NanoSerial.begin() add a line: nano.enableDebugging(Serial); This will cause debug messaging. Share the printed outcome

measure: if you happen to have a multi-meter, can you measure if there is any voltage on pin 16 and 17 (AC or DC) when the sketch is running

Wiring: would not be the first time that the small connector of the wires do not make the right contact. They can wear-out quickly. Double check they connect well, maybe push them aside a bit to make sure they connect.

soldering : double check there is not short circuit between the soldering of the pins on the board.

Hi, thanks for the reply.

It took me a while to answer direction and I wanted to buy the multi meter to check the voltages because something here I am probably missing.

I went through all your comments and acted on them and still the module does not respond.

I will attach a picture of the connections I made + the measurements in multi meters.

The code I used is example1 that you posted here to the forum.

I will attach a picture with the addition of the line you requested.

If there are more suggestions for solving the problem, maybe something I am doing wrong?

Nothing wrong that I can see. Can you send a zip-file with the sketch (.ino) in it? I will try it on my ESP32…

Hi thanks for the reference.

Upload the code here.

Awaiting your response, thanks!

example1.zip (2.25 KB)