Open B1SHQP opened 9 years ago
I found that you do not need SoftwareSerial at all. This code works, its basic but does read the supplied tags:
int incomingdata = 0;
boolean started = false; unsigned char raw[15]; int characters[15]; int dataLen; String hexnumber;
void setup() { Serial.begin(9600); Serial1.begin(9600); } void loop() {
if (Serial1.available() > 0)
{
// the incoming data is an array of 13 numbers
// the numbers are actually ASCII integers for ABDCDEF1234567890
// so we have to convert the ints to ASCII as a concatenated string
// thne we have to convert teh HEX string to decimal integer
// the decimal integer is our RFID tag number
incomingdata = Serial1.read();
characters[dataLen] = incomingdata;
dataLen++;
Serial.print(dataLen);
Serial.print(" ");
Serial.println(incomingdata);
delay(10);
if (dataLen > 13)
{
for (int i = 0; i < dataLen; ++i)
{
String letter = ConvertToASCII(characters[i]);
//Serial.print(letter);
if (i > 3 && i < 11)
{
hexnumber = hexnumber + letter;
}
}
Serial.println();
Serial.println(hexnumber);
Serial.println(ConvertToDecimal(hexnumber);
dataLen = 0;
hexnumber = "";
}
}
}
int ConvertToDecimal(String hexnumber) { int out; char dtm[8]; dtm[0] = hexnumber[0]; dtm[1] = hexnumber[1]; dtm[2] = hexnumber[2]; dtm[3] = hexnumber[3]; dtm[4] = hexnumber[4]; dtm[5] = hexnumber[5]; dtm[6] = hexnumber[6]; dtm[7] = hexnumber[7];
sscanf( dtm, "%x", &out );
return out; }
String ConvertToASCII(int letter) { if (letter == 48) {return "0";} if (letter == 49) {return "1";} if (letter == 50) {return "2";} if (letter == 51) {return "3";} if (letter == 52) {return "4";} if (letter == 53) {return "5";} if (letter == 54) {return "6";} if (letter == 55) {return "7";} if (letter == 56) {return "8";} if (letter == 57) {return "9";} if (letter == 65) {return "A";} if (letter == 66) {return "B";} if (letter == 67) {return "C";} if (letter == 68) {return "D";} if (letter == 69) {return "E";} if (letter == 70) {return "F";}
{return "";}
}
is this stile valid with the current version of the software-serial library? please retest! and maybe close here.
HI there
I hope you can help.
I have a LinkIt ONE kit. I purchased the 125Khz RFID module - UART SKU: RFR101A1M.
I have downloaded the Seeed-Studio/RFID_Library files.
I have found the SoftwareSerial libraries in the core Arduino libraries.
However when I compile I get the following error:
error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
The LinkIt ONE board is 260Mhz.
Has anyone got compatible SoftwareSerial libraries
OR
Some other library and examples that works with the 125Khz RFID module - UART SKU: RFR101A1M on the LinkIt ONE board .
Thanks
Andrew Bishop