Saturday, 13 April 2013 16:47

Arduino与Stronglink SL018 RFID模块

Written by
Rate this item
(0 votes)

Stronglink SL018 RFID module

眾多RFID模块中,Stronglink SL018是我找到最便宜的模块且支持读取及写入。SL018 使用了I2C接口(只使用两条信号线)与外界沟通,支持的RFID卡包括MIFARE Classic 1K, MIFARE Classic 4K 和 MIFARE Ultralight,频率则是13.56MHz。以下是SL018规则说明:
Model
MIFARE Module SL018
Frequency
13.56MHz
Protocol
ISO14443A
Tag supported
Ultralight, NTAG203, MIFARE Mini, MIFARE™ Classic 1K, MIFARE™ Classic 4K, FM11RF08
Interface
I2C
Supply voltage
4.4 - 7.0VDC
Dimension
65 × 45 mm
由于Marc Boon已经编写好了SL018用于 Arduino 程序库(Library)Arduino与SL018进行沟通将会变得非常的容易,只须几行代码,就能读取RFID卡的UID了。 

 
测试Stronglink SL018
测试SL018是否正常工作可以说是非常的简单,只要供电5V至SL018模块就行了,当然这不包括测试I2C接口。
Stronglink SL018 pinout
  • +5V及Gnd分别连接Pin4和Pin5,然後通电
  • SL018侦察到MIFARE RFID卡,L3 LED将会转亮
  • 对地(Gnd)测量Pin1(TAG),将会得到3V
  • 将MIFARE RFID卡移开,L3 LED又熄了
简单的说,如果不需要认证,只使用一片SL018模块,通Pin1(TAG)输出,就可以控制电子设备了。
 
 
安装SL018程序库
  • 下载SL018程序库,此程序库也支持SL030 RFID模块
  • 解压ZIP文件(RFIDuino-master.zip)
  • 只需要SL018文件夹,将之拷贝到 arduino的libraries文件夹,如图:
SL018 Library
 
  • 打开arduino软件
  • 单击File>Examples>SL018,看到SL018例子(如图表示安装成功
Stronglink SL018 examples
 
 
 
上载(Upload)Sketch至Arduino
SL018程序库自带了示范例子,用此例子上载至Arduino来测试最好不过了。
  • Arduino连接电脑
  • 打开arduino软件
  • 单击File>Examples>SL018>UID,是的,就UID为例子吧!
  1. #include <Wire.h>
  2. #include <SL018.h>
  3. SL018 RFID;
  4. int led = 13;
  5.  
  6. void setup()
  7. {
  8. pinMode (LED, OUTPUT);
  9. Wire.begin ();
  10. Serial.begin (19200);
  11. Serial.println("Show me your tag"); // prompt for tag
  12. }
  13.  
  14. void loop ()
  15. {
  16. rfid.seekTag () / / start the seek mode
  17. while (! rfid.available ()) / / wait until detected tag
  18. Serial.println (rfid.getTagString ()); / / print some id
  19. }

上面的例子上载至Arduino後,可以与SL018沟通了。代码是不是很简单?

 
 
 SL018模块与Arduino连接
SL018的Pin1,Pin2(SDA)Pin3(SLC),分别连接至Arduino的A3,A4及A5
SL018
Arduino
1(TAG) 
A3 (Analog 3)
2 (SDA)
A4 (Analog 4)
3 (SLC)
A5 (Analog 5)
4 (VCC)
VCC
5 (GND)
GND
 
 
SL018模块与Arduino沟通
这里我们使用Arduino软件自带的串口监视器(Serial Monitor)来监视与测试
  • 根据以上方式,连接SL018至Arduino
  • 打开Arduino软件,然後运行Serial Monitor
  • 当SL018侦察到MIFARE RFID卡,L3 LED将会转亮,同时Serial Monitor将显示此RFID卡的UID,如图:
Show your tag
 
 
 
认证开关
改进上面的代码,形成了需要认证後才能决定开与关。以下代码使用RFID通过後LED会亮,三秒后将会自动熄。 

#include <Wire.h>
#include <SL018.h>

SL018 rfid;

int led = 13;  // Pin 13 has an LED connected on most Arduino boards
String cardUID;
 

void setup()
{

  pinMode(led, OUTPUT);  // initialize the digital pin as an output.

  Wire.begin();
  Serial.begin(19200);

  Serial.println("Show me your tag"); // prompt for tag
}

void loop()
{
  rfid.seekTag();  // start seek mode
  
  while(!rfid.available());  // wait until tag detected
  cardUID = rfid.getTagString();
  Serial.println( cardUID);  // print tag id
  if ( cardUID == "0467CB11E20280") {
     digitalWrite(led, HIGH);   // turn the LED on
     delay(3000);  //wait for 3 seconds
     digitalWrite(led, LOW);   // turn the LED off
  }
}

 

RFID读取与写入示范
接下来是一个比较复杂的示范,功能包括:
  • 读取UID
  • 读取RF卡内的全部信息
  • 写入两字节(2 Bytes)至RF卡
这里使用由SL018程序库自带的sl018demo例子作示范,同样的使用Serial Monitor来监视与测试,baud rate必须设成19200。一切就绪后,开始测试了:
 
在Serial Monitor输入?将会显示所有令,如图
Help
 
a 命指令
是一个切换指令,当Auto read on时,只要 SL018侦察到RF卡在範围内,将会自动读取UID(s 指令)和列出RF卡的全部信息(r 指令)
 
d 指令
是一个切换指令,用于调试。当Debug on时,Serial Monitor将列出执行指令以及由SL018获得的信息
 
s 指令
读取与列出RF卡的UID
Seek UID
 
r 指令
读取与列出RF卡的全部信息
Read Data
 
w 指令
写入两个字节
Write string AB to RFID card
Read 20072 times Last modified on Tuesday, 23 April 2013 21:58
More in this category: Arduino读取键盘 »

101 comments

  • Comment Link gkjotCow Saturday, 30 May 2020 08:28 posted by gkjotCow

    free antivirus software 2019 avast free antivirus 2019 https://xantivirusx.com/ - avira free antivirus free dating websites sex dating https://onlinedatingwow.com/ - xname lname dating bhg sweepstakes win vehicle sweepstakes https://supersweepstakesx.com/ - publishers clearing house sweepstakes

  • Comment Link lkarsCow Friday, 29 May 2020 06:42 posted by lkarsCow

    free norton antivirus download 2019 eset antivirus https://xantivirusx.com/ - eset antivirus kate gosselin dating show dating women over age 50 https://onlinedatingwow.com/ - vh1 dating naked unblurred fish bowl sweepstakes sweepstakes 2017 https://supersweepstakesx.com/ - hgtv sweepstakes central

  • Comment Link evrvfCow Wednesday, 27 May 2020 09:00 posted by evrvfCow

    free antivirus download [url=https://xantivirusx.com/] best free antivirus for windows 10[/url] https://xantivirusx.com/ - antivirus bumble dating site [url=https://onlinedatingwow.com/] dating sites[/url] https://onlinedatingwow.com/ - best dating sites sweepstakes fanatics [url=https://supersweepstakesx.com/] hgtv dream home 2020 sweepstakes[/url] https://supersweepstakesx.com/ - bassmaster fish with randy howell sweepstakes

  • Comment Link xhlnmCow Sunday, 24 May 2020 04:25 posted by xhlnmCow

    francine niyonsaba testosterone condition side effects of testosterone injections Induject-250 amp function of testosterone foods that increase testosterone

    testosterone levels by age symptoms of low testosterone in men [url=https://pharm-usa-official.com/testosterone.php ] testosterone levels[/url] testosterone in women testosterone replacement therapy

    https://pharm-usa-official.com/testosterone.php - testosterone cypionate

  • Comment Link tswafCow Saturday, 23 May 2020 01:46 posted by tswafCow

    best testosterone boosters 2020 male hormones testosterone supplements low testosterone icd 10 testosterone nation

    testosterone patches for men what is the best testosterone booster [url=https://pharm-usa-official.com/testosterone.php ] testosterone cypionate[/url] do women have testosterone testosterone cream

    https://pharm-usa-official.com/testosterone.php - testosterone

  • Comment Link vqxthBaw Friday, 22 May 2020 09:12 posted by vqxthBaw

    generic levitra levitra pills levitra online online levitra buy levitra

    levitra 20 levitra online [url=https://drugstoreonliner.com/#]levitra price [/url] levitra online levitra cost

    https://drugstoreonliner.com/ - levitra coupon

  • Comment Link bvxqsCow Thursday, 21 May 2020 04:38 posted by bvxqsCow

    where is testosterone produced testosterone foods best testosterone supplements for men symptoms of low testosterone in men testosterone injection sites

    testosterone gel what is the best testosterone booster [url=https://pharm-usa-official.com/testosterone.php ] testosterone levels[/url] testosterone side effects in men testosterone meaning

    https://pharm-usa-official.com/testosterone.php - testosterona

  • Comment Link pkhdnBaw Wednesday, 20 May 2020 12:44 posted by pkhdnBaw

    levitra coupon levitra levitra dosage levitra 20mg levitra pills

    order levitra vardenafil levitra [url=https://drugstoreonliner.com/#]cheap levitra [/url] viagra vs cialis generic levitra online

    https://drugstoreonliner.com/ - levitra coupon

  • Comment Link rzjhkCow Wednesday, 20 May 2020 03:53 posted by rzjhkCow

    symptoms of low testosterone granite testosterone how to increase testosterone low testosterone warnings for testosterone propionate

    testosterone side effects in men testosterone replacement therapy [url=https://pharm-usa-official.com/testosterone.php ] testosterone supplements[/url] testosterone is produced by testosterone in women

    https://pharm-usa-official.com/testosterone.php - testosterone cypionate

  • Comment Link iccodCow Tuesday, 19 May 2020 10:53 posted by iccodCow

    tadalafil side effects tadalafil 10mg prix tadalafil 20mg tadalafil generic generic cialis tadalafil 20 mg from india

    generic cialis tadalafil 20mg tadalafil citrate [url=https://supertadalafil.com/ ] tadalafil dosage[/url] tadalafil generic usa generic cialis tadalafil 20mg

    https://supertadalafil.com/ - tadalafil generic

    tadalafil vs sildenafil tadalafil 20mg prix generic cialis tadalafil tadalafil tablets cialis tadalafil

    tadalafil biogaran tadalafil liquid [url=https://xtadalafilx.com/ ] tadalafil cialis[/url] tadalafil 5mg vardenafil vs tadalafil

    https://xtadalafilx.com/ - generic tadalafil

  • Comment Link kxanxCow Monday, 18 May 2020 05:07 posted by kxanxCow

    tadalafil 40 mg tadalafil side effects tadalafil reviews what is tadalafil buy tadalafil 20mg price

    tadalafil lilly side effects for tadalafil [url=https://supertadalafil.com/ ] tadalafil 20 mg[/url] tadalafil vs vardenafil vardenafil vs tadalafil

    https://supertadalafil.com/ - cheap tadalafil

    tadalafil 40 mg tadalafil online canadian pharmacy tadalafil dosage what is tadalafil tadalafil prix

    liquid tadalafil tadalafil 10mg [url=https://xtadalafilx.com/ ] tadalafil liquid[/url] tadalafil biogaran prix tadalafil 5mg prix

    https://xtadalafilx.com/ - tadalafil cialis

  • Comment Link rwmpuBaw Monday, 18 May 2020 00:11 posted by rwmpuBaw

    adele weight loss medi weight loss weight loss programs diet plan weight loss shakes

    how to reduce weight golo weight loss scam [url=https://weight-loss-blogs.com/#]apple cider vinegar weight loss [/url] rachael ray weight loss randy jackson weight loss

    https://weight-loss-blogs.com - chrissy metz weight loss

  • Comment Link lomnhCow Sunday, 17 May 2020 05:05 posted by lomnhCow

    cialis generic cialis tadalafil tadalafil 20 mg prix tadalafil reviews tadalafil en ligne tadalafil vs viagra

    cialis vs tadalafil generic tadalafil generic [url=https://supertadalafil.com/ ] tadalafil generic[/url] tadalafil generique en pharmacie tadalafil cost

    https://supertadalafil.com/ - tadalafil generic

    tadalafil vs viagra cialis vs tadalafil generic tadalafil reviews tadalafil 20mg tadalafil online canadian pharmacy

    cialis generic tadalafil buy tadalafil online [url=https://xtadalafilx.com/ ] tadalafil 20mg[/url] what is tadalafil tadalafil biogaran

    https://xtadalafilx.com/ - tadalafil 20 mg

  • Comment Link ccxniCow Saturday, 16 May 2020 05:11 posted by ccxniCow

    side effects for tadalafil interactions for tadalafil buy tadalafil online tadalafil biogaran 20 mg prix tadalafil generic usa

    mylan tadalafil sildenafil vs tadalafil [url=https://supertadalafil.com/ ] tadalafil 20mg[/url] tadalafil mylan tadalafil 20 mg prix

    https://supertadalafil.com/ - tadalafil 5mg

    tadalafil cost cvs tadalafil en ligne tadalafil 5mg tadalafil online canadian pharmacy adcirca tadalafil

    tadalafil cost side effects for tadalafil [url=https://xtadalafilx.com/ ] buy tadalafil online[/url] tadalafil canadian pharmacy tadalafil cost

    https://xtadalafilx.com/ - cheap tadalafil

  • Comment Link 카지노사이트 Friday, 15 May 2020 10:40 posted by 카지노사이트

    I as well as my friends have been going through the best information on the blog and then then got a terrible feeling I never expressed respect to you for those secrets. My women became joyful to see all of them and already have in fact been loving them. I appreciate you for indeed being quite considerate and for getting this form of really good subjects most people are really eager to discover. My sincere regret for not saying thanks to sooner.

  • Comment Link 바카라사이트 Friday, 15 May 2020 10:32 posted by 바카라사이트

    I¡¦ve read several good stuff here. Definitely price bookmarking for revisiting. I surprise how a lot attempt you set to create one of these magnificent informative website.

  • Comment Link 카지노사이트 Friday, 15 May 2020 10:20 posted by 카지노사이트

    My coder is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the costs. But he’s tryiong none the less. I’ve been using WordPress on various websites for about a year and am worried about switching to another platform. I have heard very good things about blogengine.net. Is there a way I can import all my wordpress posts into it? Any help would be really appreciated!

  • Comment Link 바카라사이트 Friday, 15 May 2020 10:10 posted by 바카라사이트

    My wife and i have been really joyous that Edward could conclude his investigations from your precious recommendations he had while using the site. It is now and again perplexing to simply continually be giving for free information which some other people have been selling. We really take into account we’ve got the writer to appreciate because of that. The entire illustrations you’ve made, the straightforward blog menu, the friendships you will make it possible to instill – it is all astounding, and it’s really assisting our son in addition to us do think that subject matter is interesting, which is really pressing. Thank you for all!

  • Comment Link dnpihCow Friday, 15 May 2020 01:45 posted by dnpihCow

    generic cialis tadalafil 20mg generic for cialis tadalafil liquid tadalafil tadalafil powder tadalafil 10 mg

    tadalafil lilly 5mg prix tadalafil avis [url=https://supertadalafil.com/ ] tadalafil generic[/url] tadalafil cost cvs tadalafil lilly 5mg prix

    https://supertadalafil.com/ - tadalafil generic

    tadalafil 5mg prix tadalafil 20mg tadalafil 5mg tadalafil dosage tadalafil prix en pharmacie

    tadalafil online canadian pharmacy tadalafil avis [url=https://xtadalafilx.com/ ] tadalafil 20mg[/url] tadalafil powder tadalafil mylan

    https://xtadalafilx.com/ - tadalafil 20 mg

  • Comment Link vjpnyCow Thursday, 14 May 2020 04:06 posted by vjpnyCow

    tadalafil canadian pharmacy cialis generic cialis tadalafil cialis tadalafil tadalafil pronunciation tadalafil for women

    cialis vs tadalafil generic tadalafil citrate [url=https://supertadalafil.com/ ] tadalafil reviews[/url] buy cialis ebay find tadalafil generic tadalafil

    https://supertadalafil.com/ - tadalafil 20mg

    tadalafil 20 tadalafil pronunciation generic tadalafil tadalafil en ligne tadalafil reviews

    tadalafil tablets 20 mg tadalafil prix [url=https://xtadalafilx.com/ ] cheap tadalafil[/url] tadalafil lilly 5mg prix tadalafil powder

    https://xtadalafilx.com/ - tadalafil liquid

Leave a comment

Back to Top