Arduino mega驱动UHF RFID读取RSSI值
RSSI(Received Signal Strength Indicator)是接收信号的强度指示,它的实现是在反向通道基带接收滤波器之后进行的。RSSI技术是通过接收到的信号强弱测定信号点与接收点的距离,进而根据相应数据进行定位计算的一种定位技术。现在通过代码得到RSSI值。
硬件:
1、soliddigi Uart TTL UHF RFID module
2、902~928MHz 5dBi RFID Antenna
3、soliddigi Arduino mega
读取RSSI使用Uart RFID控制指令集中的Command Inventory with RSSI指令,
Arduino代码如下:
- //RFID reads the tag by Arduino mega
- unsigned int status = 0;
- unsigned char val,RSSI,Tag_num,I,Q;
- unsigned char SCMD[] = {0x43,0x03,0x01};
- unsigned char Rcard[12];
- unsigned char Freq[3];
- void setup()
- {
- Serial.begin(115200);
- Serial1.begin(115200);
- }
- void loop()
- {
- if (status == 0)
- Serial1.write(SCMD,3);
- delay(500);
- if (Serial1.available() > 0) {
- val = Serial1.read();
-
- switch(status) {
- case 0: // parse 0x44
- if (val == 0x44)
- {status = 1; /*Serial.print(val);*/}
- break;
- case 1: //parse 0x16
- if (val == 0x16)
- {status = 2; /*Serial.print(val);*/}
- else if (val == 0x05)
- {Serial.println("No Tag read");
- status = 22; /*Serial.print(val);*/}
- break;
- case 2:
- if (val > 0)
- {status = 3; Tag_num = val;
- Serial.print("Tag_num = ");
- Serial.println(Tag_num,HEX);}
- break;
- case 3:
- RSSI = val; I = (val&0x0F)*2; Q = (val>>4)*2;
- Serial.print("RSSI = ");
- Serial.println(RSSI,HEX);
- status = 4;
- break;
- case 4:
- case 5:
- case 6:
- Freq[status - 4] = val;
- status ++;
- // Serial.print(val);
- break;
- case 7:
- if (val == 0x0E)
- {status = 8; /*Serial.print(val);*/}
- break;
- case 8:
- if (val == 0x30)
- {status = 9; /*Serial.print(val);*/}
- break;
- case 9:
- if (val == 0x00)
- {status = 10;/* Serial.print(val);*/}
- break;
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- Rcard[status - 10] = val;
- status ++;
- // Serial.print(val);
- if (status == 22) status = 0;
- break;
-
- case 22:
- if (val == 0x00) {status = 23; /*Serial.print(val);*/}
- break;
- case 23:
- if (val == 0x00) {status = 24; /*Serial.print(val);*/}
- break;
- case 24:
- if (val == 0x00) {status = 0; /*Serial.print(val);*/}
- break;
- default:
- break;
- }
- }
- }
复制代码
RSSI值赋给一个变量,从Arduino的serial port可见:
更多操作指令,请参考 Uart RFID 控制指令集:
TTL UART/USB Long Range UHF RFID reader Module (ISO18000-6C EPC G2) UART Protocol
http://www.soliddigi.com/download/showdownload.php?id=54&lang=en