├── .gitattributes ├── .github └── workflows │ ├── stale.yml │ └── sync_issues.yml ├── .gitignore ├── .gitlab-ci.yml ├── .travis.yml ├── LICENSE ├── README.md ├── SeeedRFID.cpp ├── SeeedRFID.h ├── examples └── RFID_UART │ └── RFID_UART.ino ├── keywords.txt └── library.properties /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues and PRs' 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 4 * * *' 7 | 8 | jobs: 9 | stale: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout repository 14 | uses: actions/checkout@v4 15 | 16 | - name: Checkout script repository 17 | uses: actions/checkout@v4 18 | with: 19 | repository: Seeed-Studio/sync-github-all-issues 20 | path: ci 21 | 22 | - name: Run script 23 | run: ./ci/tools/stale.sh 24 | env: 25 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 26 | -------------------------------------------------------------------------------- /.github/workflows/sync_issues.yml: -------------------------------------------------------------------------------- 1 | name: Automate Issue Management 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - edited 8 | - assigned 9 | - unassigned 10 | - labeled 11 | - unlabeled 12 | - reopened 13 | 14 | jobs: 15 | add_issue_to_project: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Add issue to GitHub Project 19 | uses: actions/add-to-project@v1.0.2 20 | with: 21 | project-url: https://github.com/orgs/Seeed-Studio/projects/17 22 | github-token: ${{ secrets.ISSUE_ASSEMBLE }} 23 | labeled: bug 24 | label-operator: NOT -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | build: 2 | tags: 3 | - nas 4 | script: 5 | - wget -c https://files.seeedstudio.com/arduino/seeed-arduino-ci.sh 6 | - chmod +x seeed-arduino-ci.sh 7 | - bash $PWD/seeed-arduino-ci.sh test 8 | 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | 2 | language: generic 3 | dist: bionic 4 | sudo: false 5 | cache: 6 | directories: 7 | - ~/arduino_ide 8 | - ~/.arduino15/packages/ 9 | 10 | before_install: 11 | - wget -c https://files.seeedstudio.com/arduino/seeed-arduino-ci.sh 12 | 13 | script: 14 | - chmod +x seeed-arduino-ci.sh 15 | - cat $PWD/seeed-arduino-ci.sh 16 | - bash $PWD/seeed-arduino-ci.sh test 17 | 18 | notifications: 19 | email: 20 | on_success: change 21 | on_failure: change 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Xiaobo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RFID Library [![Build Status](https://travis-ci.com/Seeed-Studio/RFID_Library.svg?branch=master)](https://travis-ci.com/Seeed-Studio/RFID_Library) 2 | ============ 3 | 4 | 125Khz RFID library for Arduino. 5 | 6 | This library only support TTL RS232 serial port. 7 | 8 | ![125Khz RFID Reader](https://statics3.seeedstudio.com/images/product/gr125k.jpg) 9 | 10 | 11 | [Grove - 125KHz RFID Reader 12 | ](https://www.seeedstudio.com/s/Grove-125KHz-RFID-Reader-p-1008.html) 13 | 14 | 15 | 16 | When read the data from some RFID card, you will get data like `00 91 6f 0b f5`. 17 | 18 | Example: 19 | ``` 20 | your card number: 0009531147 21 | that your data : 00 91 6f 0b f5 22 | ``` 23 | **Notice, f5 is the check bit** 24 | 25 | `f5 = 00^91^6f^0b` 26 | 27 | 28 | #### Pins 29 | 30 | 1. VCC support 3.3 ~ 5V 31 | 2. TX, RX connect to Arduino or Seeeduino 32 | 3. T1, T2 is the Signal port for RFID antenna 33 | 4. W0, W1 is for wiegand protocol, but this library not support yet. 34 | 35 | ``` 36 | +-----------+ 37 | ++++++++----|VCC T1|---- 38 | | +++++----|GND T2|---- 39 | | | |++----|TX SER|---- 40 | | | | ----|RX LED|---- 41 | | | | ----|W0 BEEP|---- 42 | | | | ----|W1 GND|---- 43 | | | | +-----------+ 44 | | | \___________________________________ 45 | | |_____________________________ | 46 | | | | 47 | | + + + + + + + + + + + + + + + + 48 | | | | | | | | | | | | | | | | | | 49 | | | | | | | | | | | | | | | | | | 50 | | +-----------------|-|-|-|-|-|-|-|--|-|-|-|-|-|-|-|-+ 51 | | | x-x-x-x-x-x-x-x x-x-x-x-x-x-x-x | 52 | | | xxx | 53 | | +--------+ xxx --- --- ............. | 54 | | | | | - x + | ' | ||\ |.-. ' + 55 | | | | ^ --- --- | |__|| \|._. | x 56 | | | | <+++> ARDUINO '.............' + 57 | | +--------+ V | 58 | | | _____ ++-++ xx | 59 | | | <_____> +-O-+ xx | 60 | | | ++-++ xx | 61 | | |+--++-- | 62 | | ||||++-- +---------------------+ | 63 | | |+--++-- | | | 64 | | | | | | 65 | | ++------+ +---------------------+ | 66 | | ++ | + 67 | | ++ | +-+ +-+ x 68 | | ++------+ +-+ +-+ x-x-x-x-x-x x-x-x-x-x-x + 69 | | +-------------------------|-|-|-|-|-|-|-|-|-|-|-|--+ 70 | | | | | | | | | | | | | | 71 | | | | | | | | | | | | | | 72 | | + + + + + + + + + + + + 73 | |____________________________________________| 74 | 75 | ``` 76 | 77 | ### Usage 78 | Connecting RFID Reader RX, TX to Arduino pin headers. 79 | 80 | `RX <--> 10` 81 | `TX <--> 11` 82 | 83 | ```c 84 | // RFID_UART.ino 85 | 86 | #include 87 | #include 88 | 89 | #define RFID_RX_PIN 10 90 | #define RFID_TX_PIN 11 91 | 92 | #define TEST 93 | 94 | SeeedRFID RFID(RFID_RX_PIN, RFID_TX_PIN); 95 | RFIDdata tag; 96 | 97 | void setup() { 98 | Serial.begin(57600); 99 | Serial.println("Hello, double bk!"); 100 | } 101 | 102 | void loop() { 103 | if(RFID.isAvailable()){ 104 | tag = RFID.data(); 105 | Serial.print("RFID card number: "); 106 | Serial.println(RFID.cardNumber()); 107 | #ifdef TEST 108 | Serial.print("RFID raw data: "); 109 | for(int i=0; i 125 | #include 126 | 127 | #define RFID_RX_PIN 10 128 | #define RFID_TX_PIN 11 129 | 130 | #define RFID2_RX_PIN 12 131 | #define RFID2_TX_PIN 13 132 | 133 | 134 | SeeedRFID RFID(RFID_RX_PIN, RFID_TX_PIN); 135 | RFIDdata tag; 136 | 137 | SeeedRFID RFID2(RFID2_RX_PIN, RFID2_TX_PIN); 138 | RFIDdata tag2; 139 | 140 | void setup() { 141 | Serial.begin(9600); 142 | RFID.listen(); //first, we listen for data on reader #1 143 | } 144 | 145 | void loop() { 146 | 147 | if(RFID.isAvailable()){ 148 | tag = RFID.data(); 149 | Serial.print("RFID card number: "); 150 | Serial.println(RFID.cardNumber()); 151 | RFID2.listen(); //now start listening for data on reader #2 152 | } 153 | 154 | if(RFID2.isAvailable()){ 155 | tag2 = RFID2.data(); 156 | Serial.print("RFID2 card number: "); 157 | Serial.println(RFID2.cardNumber()); 158 | RFID.listen(); //then we listen to reader #1 again... 159 | } 160 | } 161 | 162 | ``` 163 | 164 | For more information please visit [wiki]([wiki](http://wiki.seeedstudio.com/Grove-125KHz_RFID_Reader/)). 165 | 166 | ---- 167 | 168 | This library is written by [Ye Xiaobo][Github Homepage] for seeed studio
169 | and is licensed under [The MIT License](https://github.com/yexiaobo-seeedstudio/RFID_Library/blob/master/LICENSE).
170 | 171 | Contributing to this software is warmly welcomed. You can do this basically by
172 | [forking](https://help.github.com/articles/fork-a-repo), committing modifications and then [pulling requests](https://help.github.com/articles/using-pull-requests) (follow the links above
173 | for operating guide). Adding change log and your contact into file header is encouraged.
174 | Thanks for your contribution. 175 | 176 | Seeed Studio is an open hardware facilitation company based in Shenzhen, China.
177 | Benefiting from local manufacture power and convenient global logistic system,
178 | we integrate resources to serve new era of innovation. Seeed also works with
179 | global distributors and partners to push open hardware movement.
180 | 181 | 182 | [RFID Image]: http://www.seeedstudio.com/wiki/images/6/6a/RFID.jpg 183 | [Github Homepage]: https://github.com/yexiaobo-seeedstudio 184 | 185 | 186 | 187 | [![Analytics](https://ga-beacon.appspot.com/UA-46589105-3/RFID_Library)](https://github.com/igrigorik/ga-beacon) 188 | -------------------------------------------------------------------------------- /SeeedRFID.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SeeedRFID.cpp 3 | A library for RFID moudle. 4 | 5 | Copyright (c) 2008-2014 seeed technology inc. 6 | Author : Ye Xiaobo(yexiaobo@seeedstudio.com) 7 | Create Time: 2014/2/20 8 | 9 | The MIT License (MIT) 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in 19 | all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | */ 29 | 30 | /************************************************************************** 31 | Pins 32 | ==== 33 | 34 | 1. VCC support 3.3 ~ 5V 35 | 2. TX, RX connect to Arduino or Seeeduino 36 | 3. T1, T2 is the Signal port for RFID antenna 37 | 4. W0, W1 is for wiegand protocol, but this library not support yet. 38 | 39 | ``` 40 | +-----------+ 41 | ----|VCC T1|---- 42 | ----|GND T2|---- 43 | ----|TX SER|---- 44 | ----|RX LED|---- 45 | ----|W0 BEEP|---- 46 | ----|W1 GND|---- 47 | +-----------+ 48 | ``` 49 | ***************************************************************************/ 50 | 51 | #include 52 | #include "SeeedRFID.h" 53 | #include "Arduino.h" 54 | 55 | SeeedRFID::SeeedRFID(int rxPin, int txPin) { 56 | _rfidIO = new SoftwareSerial(rxPin, txPin); 57 | _rfidIO->begin(9600); 58 | 59 | // init RFID data 60 | _data.dataLen = 0; 61 | _data.chk = 0; 62 | _data.valid = false; 63 | 64 | _isAvailable = false; 65 | _type = RFID_UART; 66 | } 67 | 68 | SeeedRFID::~SeeedRFID() { 69 | } 70 | 71 | 72 | boolean SeeedRFID::checkBitValidationUART() { 73 | if (5 == _data.dataLen && (_data.raw[4] == _data.raw[0]^_data.raw[1]^_data.raw[2]^_data.raw[3])) { 74 | _data.valid = _isAvailable = true; 75 | return true; 76 | } else { 77 | _data.valid = _isAvailable = false; 78 | return false; 79 | } 80 | } 81 | /* 82 | boolean SeeedRFID::listen() 83 | { 84 | _rfidIO->listen(); 85 | } 86 | */ 87 | boolean SeeedRFID::read() { 88 | 89 | _isAvailable = false; 90 | 91 | if (_data.dataLen != 0) { 92 | _data.dataLen = 0; 93 | } 94 | 95 | while (_rfidIO->available()) { 96 | _data.raw[_data.dataLen++] = _rfidIO->read(); 97 | #ifdef DEBUG 98 | Serial.println("SeeedRFID:read() function, and the RFID raw data: "); 99 | for (int i = 0; i < _data.dataLen; ++i) { 100 | Serial.println(); 101 | Serial.print(_data.raw[i], HEX); 102 | Serial.print('\t'); 103 | } 104 | Serial.println(); 105 | #endif 106 | delay(10); 107 | } 108 | 109 | return SeeedRFID::checkBitValidationUART(); 110 | } 111 | 112 | boolean SeeedRFID::isAvailable() { 113 | switch (_type) { 114 | case RFID_UART: 115 | return SeeedRFID::read(); 116 | break; 117 | case RFID_WIEGAND: 118 | return false; 119 | break; 120 | default: 121 | return false; 122 | break; 123 | } 124 | } 125 | 126 | RFIDdata SeeedRFID::data() { 127 | if (_data.valid) { 128 | return _data; 129 | } else { 130 | // empty data 131 | RFIDdata _tag; 132 | return _tag; 133 | } 134 | } 135 | 136 | unsigned long SeeedRFID::cardNumber() { 137 | // unsigned long myZero = 255; 138 | 139 | unsigned long sum = 0; 140 | if (0 != _data.raw[0]) { 141 | // _data.raw[0] = _data.raw[0] & myZero; 142 | sum = sum + _data.raw[0]; 143 | sum = sum << 24; 144 | } 145 | // _data.raw[1] = _data.raw[1] & myZero; 146 | sum = sum + _data.raw[1]; 147 | sum = sum << 16; 148 | 149 | unsigned long sum2 = 0; 150 | // _data.raw[2] = _data.raw[2] & myZero; 151 | sum2 = sum2 + _data.raw[2]; 152 | sum2 = sum2 << 8; 153 | // _data.raw[3] = _data.raw[3] & myZero; 154 | sum2 = sum2 + _data.raw[3]; 155 | 156 | sum = sum + sum2; 157 | 158 | #ifdef DEBUG 159 | Serial.print("cardNumber(HEX): "); 160 | Serial.println(sum, HEX); 161 | Serial.print("cardNumber: "); 162 | Serial.println(sum); 163 | #endif 164 | 165 | return sum; 166 | } 167 | -------------------------------------------------------------------------------- /SeeedRFID.h: -------------------------------------------------------------------------------- 1 | /* 2 | SeeedRFID.h 3 | A library for RFID moudle. 4 | 5 | Copyright (c) 2008-2014 seeed technology inc. 6 | Author : Ye Xiaobo(yexiaobo@seeedstudio.com) 7 | Create Time: 2014/2/20 8 | 9 | The MIT License (MIT) 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in 19 | all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | */ 29 | 30 | /************************************************************************** 31 | Pins 32 | ==== 33 | 34 | 1. VCC support 3.3 ~ 5V 35 | 2. TX, RX connect to Arduino or Seeeduino 36 | 3. T1, T2 is the Signal port for RFID antenna 37 | 4. W0, W1 is for wiegand protocol, but this library not support yet. 38 | 39 | ``` 40 | +-----------+ 41 | ----|VCC T1|---- 42 | ----|GND T2|---- 43 | ----|TX SER|---- 44 | ----|RX LED|---- 45 | ----|W0 BEEP|---- 46 | ----|W1 GND|---- 47 | +-----------+ 48 | ``` 49 | ***************************************************************************/ 50 | 51 | #ifndef SeeedRFID_H 52 | #define SeeedRFID_H 53 | 54 | #include 55 | #include "Arduino.h" 56 | 57 | struct RFIDdata { 58 | int dataLen; 59 | byte chk; 60 | boolean valid; 61 | unsigned char raw[5]; 62 | }; 63 | 64 | enum RFIDType { 65 | RFID_UART, 66 | RFID_WIEGAND 67 | }; 68 | 69 | class SeeedRFID { 70 | private: 71 | SoftwareSerial* _rfidIO; // software serail 72 | RFIDdata _data; 73 | boolean _isAvailable; 74 | RFIDType _type; 75 | boolean checkBitValidationUART(); 76 | boolean read(); 77 | public: 78 | SeeedRFID(int rxPin, int txPin); 79 | ~SeeedRFID(); 80 | 81 | boolean isAvailable(); 82 | RFIDdata data(); 83 | //boolean listen(); 84 | unsigned long cardNumber(); 85 | //void listen(); 86 | }; 87 | 88 | #endif //__SeeedRFID_H__ 89 | -------------------------------------------------------------------------------- /examples/RFID_UART/RFID_UART.ino: -------------------------------------------------------------------------------- 1 | // RFID_UART.ino 2 | 3 | #include 4 | #include 5 | 6 | #define RFID_RX_PIN 10 7 | #define RFID_TX_PIN 11 8 | 9 | // #define DEBUG 10 | // #define TEST 11 | 12 | SeeedRFID RFID(RFID_RX_PIN, RFID_TX_PIN); 13 | RFIDdata tag; 14 | 15 | void setup() { 16 | Serial.begin(57600); 17 | Serial.println("RFID Test.."); 18 | } 19 | 20 | void loop() { 21 | if (RFID.isAvailable()) { 22 | tag = RFID.data(); 23 | Serial.print("RFID card number: "); 24 | Serial.println(RFID.cardNumber()); 25 | #ifdef TEST 26 | Serial.print("RFID raw data: "); 27 | for (int i = 0; i < tag.dataLen; i++) { 28 | Serial.print(tag.raw[i], HEX); 29 | Serial.print('\t'); 30 | } 31 | #endif 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map for SeeedRFIDLib 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SeeedRFID KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | data KEYWORD2 16 | isAvailable KEYWORD2 17 | cardNumber KEYWORD2 18 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Grove - 125KHz RFID Reader 2 | version=1.0.0 3 | author=Seeed Studio 4 | maintainer=Seeed Studio 5 | sentence=Arduino library to control Grove - 125KHz RFID Reader. 6 | paragraph=Arduino library to control Grove - 125KHz RFID Reader. 7 | category=Communication 8 | url=https://github.com/Seeed-Studio/RFID_Library 9 | architectures=* --------------------------------------------------------------------------------