paulvha:
I have a Sparkfun ESP32 Thing and used the Expressif ESP32 version 2.0.7. Took example1, selected Serial2 connected the wires, compiled and it all worked in one go. The only aspect is that now in 2.0.7 also an EPC variable is defined for a completely different part of code. To quickly overcome that in the top of the file ‘SparkFun_UHF_RFID_Reader.h’ do an ‘#undef EPC’.
I have tried to use your sketch but the USBSerial / TestSerial & SWAPSERIAL are regularly mixed with each other and did not make sense to me. First, try the sketch below to keep it simple
Wires on the serial FTDI connector :
M6E Sparkfun ESP32
GND GND
VCC VUSB
RX TX(17)
RX(16)—!
TX --------- 5k6 —!— 10K — GND (the output is 5V while the ESP32 pin can handle 3v3, hence the voltage divider)
Sketch used :
/*
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
*/
#include “SparkFun_UHF_RFID_Reader.h” //Library for controlling the M6E Nano module
// if you plan to use softserial: initalize that here, else comment it out the 2 lines
//#include <SoftwareSerial.h> //Used for transmitting to the device
//SoftwareSerial softSerial(2, 3); //RX, TX
// define the serial port to use (E.g. softSerial, Serial1 etc)
#define NanoSerial Serial2
/////////////////////////////////////////////////////////////
/* define Region for Nano to operate
- This will select the correct unlicensed frequency to use
- in you area. Valid options :
- REGION_INDIA REGION_JAPAN REGION_CHINA
- REGION_KOREA REGION_AUSTRALIA REGION_NEWZEALAND
- REGION_NORTHAMERICA REGION_EUROPE REGION_OPEN
*////////////////////////////////////////////////////////////
#define NANOREGION REGION_NORTHAMERICA
//***************************************************
// NO CHANGES NEEDED BEYOND THIS POINT *
//***************************************************
RFID nano; //Create instance
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for the serial port to come online
Serial.println(F(“Example1: constant read”));
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(NANOREGION); //Set to the right region
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(NanoSerial); //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
NanoSerial.begin(baudRate); //For this test, assume module is already at our desired baud rate
while(!NanoSerial); //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(NanoSerial.available()) NanoSerial.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 if (nano.msg[0] != ALL_GOOD)
{
//The module did not respond so assume it’s just been powered on and communicating at 115200bps
NanoSerial.begin(115200); //Start software serial at 115200
nano.setBaud(baudRate); //Tell the module to go to the chosen baud rate. Ignore the response msg
NanoSerial.begin(baudRate); //Start the 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
}
Thanks, I’ll order one of those then. This one right? https://www.amazon.com/SparkFun-PID-139 … 148&sr=8-1
Ok I’ll give that #undef EPC a try as well.
Yes I saw that thread! You’re incredibly helpful.
I did exactly that, used your Example 1 sketch with the voltage divider from the Nano’s Tx to the ESP’s Rx only I used a 4k7 instead of a 5k6. I’ve give the 5k6 a try now.