This is working for me. I get data when I upload sketch https://electrosome.com/em-18-rfid-reader-arduino-uno/
int count = 0; // count = 0
char input[12]; // character array of size 12
boolean flag = 0; // flag =0
void setup()
{
Serial.begin(9600); // begin serial port with baud rate 9600bps
}
void loop()
{
if(Serial.available())
{
count = 0;
while(Serial.available() && count < 12) // Read 12 characters and store them in input array
{
input[count] = Serial.read();
count++;
delay(5);
}
Serial.print(input); // Print RFID tag number
if((input[0] ^ input[2] ^ input[4] ^ input[6] ^ input[8] == input[10]) &&
(input[1] ^ input[3] ^ input[5] ^ input[7] ^ input[9] == input[11]))
Serial.println("No Error");
else
Serial.println("Error");
}
}
Above code only work for hardware serial but I need to read multiple port to read many RFIDS
I found this link https://docs.arduino.cc/tutorials/communication/TwoPortReceive
I don't get reader data when I upload below sketch
#include <SoftwareSerial.h>
// software serial #1: RX = digital pin 10, TX = digital pin 11
SoftwareSerial portOne(10, 11);
// software serial #2: RX = digital pin 8, TX = digital pin 9
// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
SoftwareSerial portTwo(8, 9);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// Start each software serial port
portOne.begin(9600);
portTwo.begin(9600);
}
void loop() {
// By default, the last initialized port is listening.
// when you want to listen on a port, explicitly select it:
portOne.listen();
Serial.println("Data from port one:");
// while there is data coming in, read it
// and send to the hardware serial port:
while (portOne.available() > 0) {
char inByte = portOne.read();
Serial.write(inByte);
}
// blank line to separate data from the two ports:
Serial.println();
// Now listen on the second port
portTwo.listen();
// while there is data coming in, read it
// and send to the hardware serial port:
Serial.println("Data from port two:");
while (portTwo.available() > 0) {
char inByte = portTwo.read();
Serial.write(inByte);
}
// blank line to separate data from the two ports:
Serial.println()