在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

用搭積木的方式自制一個NFC讀卡器

瑞科慧聯(RAK) ? 2022-07-28 14:17 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

地鐵刷卡、上下班門禁打卡、高鐵進站刷身份證、Apple Pay 購物……這些日常使用場景,都使用了 NFC 非接觸式識別和互聯技術,極大地方便了人們的生活。

不過,目前市面上常見的NFC無線讀卡器都使用 WIFI或藍牙進行數據傳輸,功耗較高、且傳輸距離有限。而如果采用 LoRaWAN?傳輸,則可以解決上述問題。事實上,基于 LoRaWAN?的 NFC 讀卡器優點突出:

1、LoRaWAN?的傳輸距離遠、接收靈敏度高、且功耗低

2、采用LoRaWAN?無線傳輸的讀卡器安裝部署方便

3、能使用電池供電、可持續使用半年以上。

本文將通過瑞科慧聯的模塊化開發套件 WisBlock 教大家快速搭建一個支持LoRaWAN?的無線讀卡器,讓這個讀卡器讀到電子標簽數據時,可以自動將數據上傳到 LoRaWAN?服務器上。WisBlock 其實是一個物聯網解決方案設計生態系統,由可拼接的模塊和易于使用的軟件工具組成,可加快物聯網產品生產周期、縮短上市時間。

搭建 LoRaWAN?NFC 讀卡器概述

本次搭建使用的硬件是瑞科慧聯(RAK)的 WisBlock 套件,MCU 選擇的是RAK4631WisBlock Core 模塊,該模塊采用強大的 Nordic nRF52840 MCU,可以支持藍牙 5.0(藍牙低能耗),以及 Semtech最新的 LoRa?收發器 SX1262,支持 LoRa?和藍牙兩種通信模式。

該 NFC 還選擇了 WisBlock 套件的 RAK13600 NFC 讀卡器模組,它使用的是 PN532芯片,可以支持 ISO/ICE 14443A/B 卡類型的讀寫,而且還搭配了一個蜂鳴器模組 RAK18001,當 NFC 刷卡有效時,蜂鳴器會發出響聲提醒。

對了,該 NFC 讀卡器的搭建還會使用到瑞科慧聯(RAK)的低代碼開發平臺 RUI3,它為 WisBlock 提供包含傳感器驅動接口、無線發送接口等豐富的 API接口函數,這樣我們只需要寫少量的應用代碼就可以完成此產品搭建了。

硬件電路搭建

硬件準備

首先我們需要準備 RAK4631 模塊、RAK5005-O 底板、RAK13600 NFC 讀卡器、RAK18001 蜂鳴器、兩張 ISO 14443B 卡、一根 LoRa?天線、一根 NFC天線、一個 Unify 外殼、一根藍牙天線(安裝在外殼內)。

RAK4631 模塊、RAK19007 底板、RAK13600 NFC 讀卡器等硬件準備RAK4631 模塊、RAK19007 底板、RAK13600 NFC 讀卡器等硬件準備

硬件組裝

把 RAK4631 模塊扣在 CPU SLOT 的位置,RAK13600 扣在 IO SLOT 的位置,RAK18001 扣在 SLOT A(或者SLOT B),并且使用螺絲把模組固定。

連接NFC天線、LoRa?天線、藍牙天線,并安裝至外殼中。硬件組裝完成之后就可以進行軟件設置。

軟件環境搭建

Arduino IDE中添加 RAK4631-R 開發板

打開 Arduino IDE,進入“文件 > 首選項”

打開 Arduino IDE打開 Arduino IDE

單擊圖中圖標,修改“附加開發板管理器網址”選項,將 RAK4631-R WisBlock Core 添加中 Arduino 開發板管理器中。

在 Arduino IDE上修改“附加開發板管理器網址”在 Arduino IDE上修改“附加開發板管理器網址”

現在復制這個 URL https://raw.githubusercontent.com/RAKWireless/RAKwireless-Arduino-BSP-Index/main/package_rakwireless.com_rui_index.json 并粘貼至下圖所示區域。如果已存在其他鏈接,將上述鏈接粘貼至新的一行。完成后,單擊“好”。

在Arduino IDE上粘貼復制好的URL在Arduino IDE上粘貼復制好的URL

重啟 Arduino IDE。 進入“工具 > 開發板:“RAK4631” > 開發板管理器”。

重啟Arduino IDE并執行操作重啟Arduino IDE并執行操作

在搜索框中輸入“RAK”,窗口會自動出現可用的RAKwireless WisBlock Core Boards,選擇“RAKwireless RUI nRF Boards”并安裝。

選擇并安裝 RAKwireless RUI nRF Boards選擇并安裝 RAKwireless RUI nRF Boards

BSP 安裝完成后,根據圖中路徑選擇 RAKwireless WisBlock Core模塊。

選擇 RAKwireless WisBlock Core 模塊選擇 RAKwireless WisBlock Core 模塊

安裝使用到的庫

現在安裝 RAK13600-PN532 庫和 Adafruit bus 庫:

安裝 RAK13600-PN532 庫安裝 RAK13600-PN532 庫

安裝 Adafruit bus 庫安裝 Adafruit bus 庫

代碼開發

LoRaWAN?部分的初始化,此函數可以初始化協議棧的所有參數,入網方式是OTAA,用戶需要根據自己的頻段,入網參數修改此宏定義,代碼中使用的頻段是 AS923。

/************************************* LoRaWAN band setting: RAK_REGION_EU433 RAK_REGION_CN470 RAK_REGION_RU864 RAK_REGION_IN865 RAK_REGION_EU868 RAK_REGION_US915 RAK_REGION_AU915 RAK_REGION_KR920 RAK_REGION_AS923 *************************************/ #define OTAA_BAND (RAK_REGION_AS923) #define OTAA_DEVEUI {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88} #define OTAA_APPEUI {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88} #define OTAA_APPKEY {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88} void lora_init()

蜂鳴器采用的是 PWM 控制,所以要記住在未使用蜂鳴器時,記得關閉輸出。

pinMode(BUZZER_CONTROL,OUTPUT); noTone(BUZZER_CONTROL);

NFC 芯片初始化代碼,采用 IIC 通信協議,初始化結束后,就可以使用 NFC的刷卡功能了。

nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { Serial.print("Didn't find PN53x board"); while (1); // halt } // Got ok data, print it out! Serial.print("Found chip PN5"); Serial.println((versiondata >> 24) & 0xFF, HEX); Serial.print("Firmware ver. "); Serial.print((versiondata >> 16) & 0xFF, DEC); Serial.print('.'); Serial.println((versiondata >> 8) & 0xFF, DEC); // Set the max number of retry attempts to read from a card // This prevents us from waiting forever for a card, which is // the default behaviour of the PN532. nfc.setPassiveActivationRetries(0xFF); //configure board to read RFID tags nfc.SAMConfig(); Serial.println("Waiting for an ISO14443A card");

每間隔 1 秒循環讀取是否有 NFC 卡存在,如果讀取 ID 成功,蜂鳴器會響 150 毫秒左右,然后發送卡 ID 到 LoRaWAN?服務器上。

void loop(void) { boolean success; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID uint8_t uidLength; // Length of the UID (4 or 7 bytes dep ending on ISO14443A card type) // Wait for an ISO14443B type cards (Mifare, etc.). When one is found // 'uid' will be populated with the UID, and uidLength will indicate // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight) success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength); if (success) { tone(BUZZER_CONTROL,4000); delay(150); noTone(BUZZER_CONTROL); Serial.println("Found a card!"); Serial.print("UID Length: "); Serial.print(uidLength, DEC); Serial.println(" byte s"); Serial.print("UID Value: "); for (uint8_t i = 0; i < uidLength; i++) { Serial.print(" 0x"); Serial.print(uid[i], HEX); } Serial.println(""); digitalWrite(ledPin1, HIGH); // LED turn on when input pin value is HIGH delay(150); digitalWrite(ledPin1, LOW); // /** Send the data package */ if (api.lorawan.send(uidLength, (uint8_t *) & uid, 2, true, 1)) { Serial.println("Sending is requested"); } else { Serial.println("Sending failed"); } // Wait 1 second before continuing delay(1000); } else { // PN532 probably timed out waiting for a card Serial.println("Timed out waiting for a card"); } }

數據日志

本地串口日志的信息如下所示:

RAK7268內置LoRaWAN?服務器日志:

備注:全部源代碼如下所示

/** @file iso14443a_uid.ino @author rakwireless.com @brief This example will attempt to connect to an ISO14443A card and read card UID @version 0.1 @date 2021-10-14 @copyright Copyright (c) 2021 **/ /**************************************************************************/ #include #include #include // Click here to get the library: http://librarymanager/All#RAK13600-PN532 /************************************* LoRaWAN band setting: RAK_REGION_EU433 RAK_REGION_CN470 RAK_REGION_RU864 RAK_REGION_IN865 RAK_REGION_EU868 RAK_REGION_US915 RAK_REGION_AU915 RAK_REGION_KR920 RAK_REGION_AS923 *************************************/ #define OTAA_BAND (RAK_REGION_AS923) #define OTAA_DEVEUI {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88} #define OTAA_APPEUI {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88} #define OTAA_APPKEY {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88} // If using the breakout or shield with I2C, define just the pins connected #define PN532_IRQ (WB_IO6) #define PN532_RESET (WB_IO5) // Not connected by default on the NFC Shield #define BUZZER_CONTROL WB_IO1 uint8_t ledPin1 = LED_GREEN; uint8_t ledPin2 = LED_BLUE; // Or use this line for a breakout or shield with an I2C connection: NFC_PN532 nfc(PN532_IRQ, PN532_RESET); void lora_init(); void setup(void) { Serial.begin(115200); pinMode(WB_IO2, OUTPUT); digitalWrite(WB_IO2, HIGH); pinMode(BUZZER_CONTROL,OUTPUT); noTone(BUZZER_CONTROL); // initialize the LED pin as an output pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); lora_init(); delay(300); while (!Serial) delay(10); Serial.println("Hello!"); nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { Serial.print("Didn't find PN53x board"); while (1); // halt } // Got ok data, print it out! Serial.print("Found chip PN5"); Serial.println((versiondata >> 24) & 0xFF, HEX); Serial.print("Firmware ver. "); Serial.print((versiondata >> 16) & 0xFF, DEC); Serial.print('.'); Serial.println((versiondata >> 8) & 0xFF, DEC); // Set the max number of retry attempts to read from a card // This prevents us from waiting forever for a card, which is // the default behaviour of the PN532. nfc.setPassiveActivationRetries(0xFF); //configure board to read RFID tags nfc.SAMConfig(); Serial.println("Waiting for an ISO14443A card"); } void loop(void) { boolean success; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type) // Wait for an ISO14443B type cards (Mifare, etc.). When one is found // 'uid' will be populated with the UID, and uidLength will indicate // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight) success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength); if (success) { tone(BUZZER_CONTROL,4000); delay(150); noTone(BUZZER_CONTROL); Serial.println("Found a card!"); Serial.print("UID Length: "); Serial.print(uidLength, DEC); Serial.println(" bytes"); Serial.print("UID Value: "); for (uint8_t i = 0; i < uidLength; i++) { Serial.print(" 0x"); Serial.print(uid[i], HEX); } Serial.println(""); digitalWrite(ledPin1, HIGH); // LED turn on when input pin value is HIGH delay(150); digitalWrite(ledPin1, LOW); // /** Send the data package */ if (api.lorawan.send(uidLength, (uint8_t *) & uid, 2, true, 1)) { Serial.println("Sending is requested"); } else { Serial.println("Sending failed"); } // Wait 1 second before continuing delay(1000); } else { // PN532 probably timed out waiting for a card Serial.println("Timed out waiting for a card"); } } void lora_init() { // OTAA Device EUI MSB first uint8_t node_device_eui[8] = OTAA_DEVEUI; // OTAA Application EUI MSB first uint8_t node_app_eui[8] = OTAA_APPEUI; // OTAA Application Key MSB first uint8_t node_app_key[16] = OTAA_APPKEY; if (!api.lorawan.appeui.set(node_app_eui, 8)) { Serial.printf("LoRaWan OTAA - set application EUI is incorrect! \r\n"); return; } if (!api.lorawan.appkey.set(node_app_key, 16)) { Serial.printf("LoRaWan OTAA - set application key is incorrect! \r\n"); return; } if (!api.lorawan.deui.set(node_device_eui, 8)) { Serial.printf("LoRaWan OTAA - set device EUI is incorrect! \r\n"); return; } if (!api.lorawan.band.set(OTAA_BAND)) { Serial.printf("LoRaWan OTAA - set band is incorrect! \r\n"); return; } if (!api.lorawan.deviceClass.set(RAK_LORA_CLASS_A)) { Serial.printf("LoRaWan OTAA - set device class is incorrect! \r\n"); return; } if (!api.lorawan.njm.set(RAK_LORA_OTAA)) // Set the network join mode to OTAA { Serial. printf("LoRaWan OTAA - set network join mode is incorrect! \r\n"); return; } if (!api.lorawan.join()) // Join to Gateway { Serial.printf("LoRaWan OTAA - join fail! \r\n"); return; } /** Wait for Join success */ while (api.lorawan.njs.get() == 0) { Serial.print("Wait for LoRaWAN join..."); api.lorawan.join(); delay(10000); } if (!api.lorawan.adr.set(true)) { Serial.printf ("LoRaWan OTAA - set adaptive data rate is incorrect! \r\n"); return; } if (!api.lorawan.rety.set(1)) { Serial.printf("LoRaWan OTAA - set retry times is incorrect! \r\n"); return; } if (!api.lorawan.cfm.set(1)) { Serial.printf("LoRaWan OTAA - set confirm mode is incorrect! \r\n"); return; } /** Check LoRaWan Status*/ Serial.printf("Duty cycle is %s\r\n", api.lorawan.dcs.get()? "ON" : "OFF"); // Check Duty Cycle status Serial.printf("Packet is %s\r\n", api.lorawan.cfm.get()? "CONFIRMED" : "UNCONFIRMED"); // Check Confirm status uint8_t assigned_dev_addr[4] = { 0 }; api.lorawan.daddr.get(assigned_dev_addr, 4); Serial.printf("Device Address is %02X%02X%02X%02X\r\n", assigned_dev_addr[0], assigned_dev_addr[1], assigned_dev_addr[2], assigned_dev_addr[3]); // Check Device Address Serial.println(""); }

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • nfc
    nfc
    +關注

    關注

    61

    文章

    1657

    瀏覽量

    182434
  • RAK
    RAK
    +關注

    關注

    0

    文章

    48

    瀏覽量

    2297
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    PAE 電鍍行車讀卡器,電鍍行業的得力助手

    主要是向大家推薦PAE電鍍行車讀卡器
    的頭像 發表于 06-24 14:53 ?113次閱讀

    汽車數字鑰匙新選擇:意法半導體ST25R系列車規NFC讀卡器

    意法半導體(STMicroelectronics)最新推出的ST25R500和ST25R501車規NFC讀卡器,不僅性能卓越,還專為汽車應用設計,滿足車聯網聯盟(CCC)和無線充電聯盟(WPC)的嚴格標準。那么,這兩款新品究竟有哪些亮點?它們如何助力汽車數字鑰匙和無線充電
    的頭像 發表于 06-24 14:02 ?732次閱讀
    汽車數字鑰匙新選擇:意法半導體ST25R系列車規<b class='flag-5'>NFC</b><b class='flag-5'>讀卡器</b>

    DD3118 高集成度讀卡器控制芯片數據手冊

    DD3118是款采用40納米低功耗技術制造的高性能、高集成度讀卡器控制芯?片,專為讀卡器設計。作為讀卡器的核心功能模塊,DD3118支持USB?3.0、SD ?3.0和eMMC?4.
    發表于 06-16 16:14 ?1次下載

    DD3118規格書|DD3118說明書|3.0讀卡器芯片規格書

    DD3118是款高性能、高度集成的讀卡器控制芯片,DD3118采用40nm低功耗技術制造,專為讀卡器或者讀卡方案設計的芯片。DD3118作為讀卡器
    發表于 06-12 17:40 ?0次下載

    MAX14502高速USB至SD讀卡器,提供旁路控制技術手冊

    MAX14502 USB轉SD? 卡讀卡器為支持全速USB通信(12Mbps)且帶有或兩SD卡插槽的便攜式設備,提供了將其升級為高速(480Mbps)USB卡
    的頭像 發表于 05-22 11:32 ?192次閱讀

    意法半導體ST25R系列NFC讀卡器新增車規產品

    意法半導體ST25R系列NFC讀卡器推出兩款喚醒速度和檢測距離俱佳的車規新產品,提升用戶體驗。ST25R500和ST25R501符合車聯網聯盟(CCC)和無線充電聯盟(Wireless Power Consortium)兩大標準的要求,目標應用瞄準汽車數字鑰匙、設備配對、
    的頭像 發表于 05-14 09:44 ?426次閱讀

    用于LEGIC Advant UID/序列號的NFC讀卡器,為什么無法讀取這些卡的UID/序列號?

    我目前正在開發小展示柜,其中 LEGIC Advant 卡 (CTC) 的 UID/序列號應由 NFC 閱讀讀取。在當前的設置中,我有
    發表于 04-02 08:07

    SD讀卡器芯片GL827L規格書

    SD讀卡器芯片GL827L規格書
    發表于 03-24 09:15 ?0次下載

    可以使用基于PN7642的Pegoda智能卡讀卡器根據CCC要求定制NFC應用嗎?

    我可以使用基于 PN7642 的 Pegoda 智能卡讀卡器根據 CCC 要求定制 NFC 應用?
    發表于 03-21 06:14

    液顯ID讀卡器C#小程序開發

    液顯WIFI無線讀卡器ID-10FC#語音開發HTTP協議讀卡小程序。讀卡器圖片如下:? ID讀卡器的特點: ?UDP通訊協議,設備主動讀
    的頭像 發表于 01-10 15:31 ?372次閱讀
    液顯ID<b class='flag-5'>讀卡器</b>C#小程序開發

    PPEC inside 超導 / 磁鐵電源,以搭積木方式快速滿足您的磁鐵供電需求

    1、PPECinside超導/磁鐵電源森木磊石PPECinside超導/磁鐵電源產品通過對超導/磁鐵電源基礎模塊的任意串并聯,使用搭積木方式進行組合,可輕松滿足用戶多樣化的輸出需求。產品采用
    的頭像 發表于 12-16 18:05 ?108次閱讀
    PPEC inside 超導 / 磁鐵電源,以<b class='flag-5'>搭積木</b>的<b class='flag-5'>方式</b>快速滿足您的磁鐵供電需求

    TRF7970A NFC讀卡器天線多路復用

    電子發燒友網站提供《TRF7970A NFC讀卡器天線多路復用.pdf》資料免費下載
    發表于 10-26 11:15 ?4次下載
    TRF7970A <b class='flag-5'>NFC</b><b class='flag-5'>讀卡器</b>天線多路復用

    CI520|13.56MHz非接觸式讀寫NFC讀卡芯片(A卡)

    門禁系統為例,NFC門禁系統通常由NFC讀卡器
    發表于 09-11 10:35

    二代身份證識別儀身份證閱讀讀卡器

    掃描儀 工地實名制讀卡器 二代證閱讀 ID/IC讀卡器 NFC讀卡模塊 多合身份證
    發表于 09-07 15:09
    主站蜘蛛池模板: 日本成人福利视频 | 天天插天天摸 | 免费看日本黄色片 | 2019天天爱天天做 | 黄色网毛片 | 久久久久久久久久免免费精品 | 色婷婷六月 | 亚洲成色在线综合网站 | 久操视频在线 | 免费黄色小视频 | 天天色综合天天 | 五月激情片 | 天堂在线免费视频 | 日韩第十页 | 天天舔天天射 | 成人在线免费 | 午夜免费福利视频 | 免费看黄色毛片 | 欧美18在线| 涩涩高清无乱码在线观看 | 5g国产精品影院天天5g天天爽 | 老外一级黄色片 | 午夜啪啪福利视频 | 欧美亚洲天堂网 | 欧美三级视频在线 | 中文字幕乱码人成乱码在线视频 | 91久久福利国产成人精品 | 色妇网| 天天天干干干 | 免费又黄又爽1000禁片 | 国产精品久久久久久久久kt | 天天爱综合 | 香蕉视频一级 | www在线视频观看 | 国产日本在线播放 | 婷婷色激情| 午夜社区| 综合五月天堂 | 色吧在线视频在线观看 | 性欧美一级 | 你懂的欧美 |