Working with Sparkfun m6e nano and Arduino mega2560 to read tags

I have a project for engineering in school where my partner and I are using this rfid reader to detect tags on a cornhole board. We will be using rfid tags sewn into the sacks, and based on distance a sack will be given a score. 3 points for in the hole, 1 point on the board, and 0 off the board. We have tags off amazon from this link; Amazon.com. We are unaware if the problem is within the tags we are trying to use or our code. Any help would be much appreciated on how to make the module start reading tags.

i am having a similar problem, pls show wiring setup

1 Like

Share a photo of your wiring and setup

What antenna, power source, and dB are you using?

1 Like

Hello Russell, I just wanted to thank you for your response. I am not using a onboard antenna as on the sparkfun website it says the on-board antenna can read 1-2 feet. For the power source, I am currently using my macbook usb port to power the arduino and full project. The power light is on for the arduino mega2560 and m6e nano so I think it should be fine. For the end project I will be using a 12V battery for power. Finally, for dB, the tags I purchased on amazon do not state a dB value, only this; * Memory and Protocolz: 96 bits EPC, 512 bits User memory; EPC global C1 Gen2 and ISO18000-6C compliant, 860-960mhz. However, my partner and I also purchased UHF RFID H3 Tags - 30mm x 16mm (Adhesive) which should be coming in soon for testing. I can send a picture of the wiring setup tomorrow in class, but I will also describe it for now. I connected 5V (arduino) to 5V (m6e nano) and ground to ground. Then RX–> TX1 and TX–> RX. Let me know if this is the correct setup. When the new tags arrive I can also test those. Once again, thank you for your interest.

Currently I am using 5V (arduino) to 5V (m6e nano) and ground to ground. Then RX–> TX1 and TX–> RX. I have also tried configuring them to the D pins on the mega, but no luck.

For the Mega you’ll need to adjust the pin #s used; see the blurb here Simultaneous RFID Tag Reader Hookup Guide - SparkFun Learn

Can you share what error message you get or what is not working ?

I am continuously getting the message “module failed to respond, please check wiring.” I originally 5V (arduino) to 5V (m6e nano) and ground to ground. Then RX–> TX1 and TX–> RX. I have also tried configuring them to the D pins on the mega, but no luck. Following the guide on their website, today I will try to wire from pin 2 on the shield to pin D11.

I have just tried it and it worked.

M6E     MEGA2560
GND     GND
VCC     5V
RX      TX3 (pin 14)
TX      RX3 (pin 15)

Example1 : changed lien 28 / 29 to

//#define rfidSerial softSerial // Software serial (eg. Arudino Uno or SparkFun RedBoard)
#define rfidSerial Serial3 // Hardware serial (eg. ESP32 or Teensy)

Ps. you also use Serial1 but on some MEGA2560 clones RX-1 and TX-1 print are switched incorrectly

Uploading: image.jpg…


Here is my setup that is not currently working. I will send another message with the code of the example I am trying

/*
Reading multiple RFID tags, simultaneously!
By: Nathan Seidle @ SparkFun Electronics
Date: October 3rd, 2016
GitHub - sparkfun/Simultaneous_RFID_Tag_Reader: Evaluation board for the ThingMagic UHF RFID Module for use with 860 to 920MHz RFID Tags

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;

// 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(15, 14); //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 Serial3 // Hardware serial (eg. ESP32 or Teensy)

// 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 115200
// #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
rfidSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
delay(100); //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 (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

I followed this wire schematic by the way

If possible can you share the code that you are using, we are still getting the error message “the module failed to respond”

1- You need to solder female headers to your board the jumper wire to those. Sticking jumper wires into the holes will not work because you are not getting a sufficient or stable electrical connection to the board.

2- Your RX and TX wires are shorted together by the breadboard.

Attached the sketch as txt document.

YellowDog is correct about the HW connections. Below a picture of the setup that I have used:

example1_serial3.txt (5.9 KB)

Thanks for the help, I got everything working. Do you have any antenna recommendations for my project

Thanks for the help, my partner and I are new to these types of projects and didn’t know using a breadboard wouldn’t draw a good connection

I always recommend this one (note you’ll need these 2 also Interface Cable RP-SMA to U.FL - 100mm & Interface Cable for RP-TNC to RP-SMA - 1m) because it makes range mostly a non-issue