SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By bluefruit1992
#199459
Hello :)

I'm having an issue connecting SparkFun's Simultaneous RFID Reader to my Adafruit Feather M0 Bluefruit LE.

Here's my connections (I have the switch set to HW-UART):
Image
Higher quality image: https://imgur.com/a/8ZGW0XB

I'm using the example code SparkFun provides, with some modifications:

Adafruit says that I should be using hardware Serial over SoftwareSerial, and to use Serial1 (which corresponds to the TX/RX pins on the feather):

Here's the quote from their support:
As a first step, use the hardware Serial pins instead of a SoftwareSerial connection.

The Feather M0 handles USB communication internally, so its TX/RX pins are free to talk to other devices, and hardware Serial is always a better choice than SoftwareSerial if it's available. In code, you'd use the Serial1 interface.
SparkFun support sent me this information:
The Feather M0 is a 3.3V logic device and all of the serial lines on the Simultaneous RFID Reader are level shifted since the intended use for this is either with a standard, 5V Arduino like an Uno or through the serial header with a 5V USB-to Serial converter board like this Serial Basic Breakout (https://www.sparkfun.com/products/14050). As you can see in the schematic (https://cdn.sparkfun.com/datasheets/Sen ... Reader.pdf), Vcc needs to be above 3.3V and while you are doing that, there’s probably still an issue with your 3.3V serial lines from the Feather. At the very least, the TXO line going to your RX line on the Feather is at 5V so you run the risk of damaging that serial line. You may need to shift that voltage back down to 3.3v using either another level shifter (https://www.sparkfun.com/categories/361) or a voltage divider.
Here's the modified code:
Code: Select 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 tags heard

  If using the Simultaneous RFID Tag Reader (SRTR) shield, make sure the serial slide
  switch is in the 'SW-UART' position
*/
//
//#include <SoftwareSerial.h> //Used for transmitting to the device
//
//SoftwareSerial softSerial(2, 3); //RX, TX

#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

  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(Serial1); //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
  Serial1.begin(baudRate); //For this test, assume module is already at our desired baud rate
  while(!Serial1); //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(Serial1.available()) Serial1.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
    Serial1.begin(115200); //Start software serial at 115200

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

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

  //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 commented out the SoftwareSerial lines at the beginning, because I'm using hardware Serial, and replaced the areas that used softSerial with Serial1.

I'm definitely getting into the setupNano function (at least sometimes), as I'm occasionally getting the "Module failed to respond. Please check wiring" error in the Serial monitor.

Is there something wrong with my code, or is it just that I need a logic level converter?
By paulvha
#199466
I would indeed advice to use a logic level converter. Also because the nano-shield will provide +5V signal on TX output which could damage your Feather (max 3.3V). With a real serial port (serial1) you should be able to continue to use 115200 as a speed and no need to reduce to 38400.
By callen5914
#199592
I have a question related to this thread. I too am using the RFID product mentioned in this thread only I am using a Particle Electron with the logic level shifter 4 channel breakout sold on SFE. It works fine I suppose.

Question 1. Without voltage applied to the Arduino and only 3.3V applied to the Electron the power led lights up on the Rfid reader shield but it’s very dim. This leads me to think there might be voltage back feeding through the RX, TX channels to the SFE RedBoard. Is this normal?

Question 2. I can get the RFID shield to read tags all day using the PCB antenna. The second I connect the external antenna it works but not sustainably. It might last for a few minutes or seconds. The on board buzzer makes crappy noises sometimes and the tags only read in certain orientations. Just not reliable at all. The only way to recover is to remove voltage to the SFE RB and start over. What am I doing wrong?

I think it’s worth mentioning that I am using the exact code examples provided by the library from SFE.
By cjdeeble
#201451
For the Sparkfun M6E shield that I purchased, the RX and TX pins near the buzzer (below pin 2) are labeled to match the Arduino Uno pins (hence acts like a shield). Therefore, for those specific two pins (the ones below pin 2), the RX and TX lines are switched physically compared to the labels; thus connect the RX to the RX, and the TX to the TX. This only works if you have a 5V microcontroller. Otherwise you will need a level shifter if the operating voltage is different.

As a note, there is another set of serial pins at the top of the device. Those pins are physically configured to be set up like standard serial pins (i.e. RX to TX, and TX to RX, and again at 5V).