So I edited the SF Example .ino for the Photon and compiled without error. The Photon accepts it and then shortly after reseting it goes into Cloud Not Connect Mode (SOLID GREEN RGB).
Code:
#include "UHF_RFID_Reader.h" //Library for controlling the M6E Nano module
RFID nano; //Create instance
// #define BUZZER1 9
// #define BUZZER2 10
void setup()
{
Serial.begin(115200);
// pinMode(BUZZER1, OUTPUT);
// pinMode(BUZZER2, OUTPUT);
//digitalWrite(BUZZER2, LOW); //Pull half the buzzer to ground and drive the other half.
while (!Serial);
Serial.println();
Serial.println("Initializing...");
if (setupNano(38400) == false) //Configure nano to run at 38400bps
{
Serial.println("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 cause USB port to brown out
//Max Read TX Power is 27.00 dBm and may cause temperature-limit throttling
}
void loop()
{
Serial.println(F("Press a key to scan for a tag"));
while (!Serial.available()); //Wait for user to send a character
Serial.read(); //Throw away the user's character
byte myEPC[12]; //Most EPCs are 12 bytes
byte myEPClength;
byte responseType = 0;
while (responseType != RESPONSE_SUCCESS)//RESPONSE_IS_TAGFOUND)
{
myEPClength = sizeof(myEPC); //Length of EPC is modified each time .readTagEPC is called
responseType = nano.readTagEPC(myEPC, myEPClength, 500); //Scan for a new tag up to 500ms
Serial.println(F("Searching for tag"));
}
//Beep! Piano keys to frequencies: http://www.sengpielaudio.com/KeyboardAndFrequencies.gif
// tone(BUZZER1, 2093, 150); //C
// delay(150);
// tone(BUZZER1, 2349, 150); //D
// delay(150);
// tone(BUZZER1, 2637, 150); //E
// delay(150);
//Print EPC
Serial.print(F(" epc["));
for (byte x = 0 ; x < myEPClength ; x++)
{
if (myEPC[x] < 0x10) Serial.print(F("0"));
Serial.print(myEPC[x], HEX);
Serial.print(F(" "));
}
Serial.println(F("]"));
}
//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
}