ESP32 MFRC522 Write / Read 讀取與寫入資料 Sector / Block + Node-Red UI控制Sector / Block 讀寫
每個區段的區塊3也叫做控制區塊(Sector Trailer, Trailer Block或Security Block),如果把上圖的資料結構想像成16層大樓,控制區塊相當於每一層樓的密碼鎖;進、出該層樓必須先輸入正確的密碼,而且每層樓都有兩組密碼。
控制區塊包含金鑰A和金鑰B兩組密碼(各6位元組),以及存取控制位元(4位元組,但僅使用前3位元組)
RFID卡內部有1KB的EEPROM記憶體,為了妥善管理並達到一卡多用的功能,這個記憶體空間被劃分成16個區段(sector),每個區段有4個區塊(block),區段0的區塊0包含卡片的唯一識別碼(UID,也稱為「製造商識別碼」,Manufacturer Code)。
參考 https://swf.com.tw/?p=941
load:0x3fff0030,len:1416
load:0x40078000,len:14804
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c
Connecting to dlink-103A
.
WiFi connected
IP address:
192.168.0.100
Please scan MIFARE Classic card...
掃描卡片開始進行讀或者寫
使用A和B作為KEY FF FF FF FF FF FF
注意,會把資料寫入到卡片 在 sector #
Ready!
===================================================
Tap an RFID/NFC tag on the RFID-RC522 reader
The client esp32-client-24:6F:28:A9:83:F4 connects to the public MQTT broker
Public HiveMQ MQTT broker (broker.mqtt-dashboard.com) connected
Card UID: 86 D5 EA 6A
PICC type: MIFARE 1KB
Card UID: 86 D5 EA 6A
Card SAK: 08
PICC type: MIFARE 1KB
Sector Block 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 AccessBits
15 63 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
62 61 6C 65 78 39 75 66 6F 74 65 73 74 69 6E 67 35 [ 0 0 0 ]
61 61 6C 65 78 39 75 66 6F 74 65 73 74 69 6E 67 31 [ 0 0 0 ]
60 61 6C 65 78 39 75 66 6F 74 65 73 74 69 6E 67 35 [ 0 0 0 ]
RFID Halt
Message arrived in topic: alex9ufo/RFID/read
Message: 05,01
0501
-------callback-----------
Data was read.
sector=5, block=1
Read block: alex9ufo testing:
RFID Halt
Data was read.
sector=5, block=1
Read block: alex9ufo testing:
RFID Halt
RFID Halt
Card UID: 86 D5 EA 6A
PICC type: MIFARE 1KB
Card UID: 86 D5 EA 6A
Card SAK: 08
PICC type: MIFARE 1KB
Sector Block 0
1 2 3
4 5 6
7 8 9 10 11
12 13 14 15 AccessBits
15 63 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
62 61 6C 65 78 39 75 66 6F
74 65 73 74 69 6E 67 35 [ 0 0 0 ]
61 61 6C 65 78 39 75 66 6F
74 65 73 74 69 6E 67 31 [ 0 0 0 ]
60 61 6C 65 78 39 75 66 6F
74 65 73 74 69 6E 67 35 [ 0 0 0 ]
14 59 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
58 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
57 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
56 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
13 55 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
54 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
53 4B 65 65 70 20 48 61 63
6B 69 6E 67 21 00 00 00 [ 0 0 0 ]
52 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
12 51 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
50 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
49 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
48 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
11 47 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
46 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
45 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
44 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
10 43 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
42 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
41 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
40 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
9 39 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
38 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
37 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
36 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
8 35 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
34 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
33 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
32 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
7 31 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
30 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
29 74 65 73 74 00 48 61 63
6B 69 6E 67 21 00 00 00 [ 0 0 0 ]
28 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
6 27 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
26 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
25 61 6C 65 78 39 75 66 6F
20 74 65 73 74 69 6E 67 [ 0 0 0 ]
24 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
5 23 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
22 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
21 61 6C 65 78 39 75 66 6F
20 74 65 73 74 69 6E 67 [ 0 0 0 ]
20 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
4 19 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
18 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
17 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
16 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
3 15 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
14 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
13 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
12 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 [ 0 0 0 ]
2 11 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
10 2B 39 32 33 30 30 34 34
34 37 37 37 37 20 20 20 [ 0 0 0 ]
9 32 38 2D 30 39 2D 31 39
38 39 20 20 20 20 20 20 [ 0 0 0 ]
8 4A 68 6F 6E 20 41 62 72
61 68 75 6D 20 20 20 20 [ 0 0 0 ]
1 7 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
6 41 6E 74 68 6F 6E 79 20
20 20 20 20 20 20 20 20 [ 0 0 0 ]
5 20 20 20 20 20 20 20 20
20 20 20 20 20 20 00 00 [ 0 0 0 ]
4 01 02 03 04 05 06 07 08
00 00 00 00 00 00 00 00 [ 0 0 0 ]
0 3 00 00 00 00
00 00 FF 07 80 69 FF FF FF FF FF FF
[ 0 0 1 ]
2 61 6C 65 78 39 75 66 6F
20 74 65 73 74 69 6E 67 [ 0 0 0 ]
1 61 6C 65 78 20 20 20 20
20 20 20 20 20 20 20 20 [ 0 0 0 ]
0 86 D5 EA 6A D3 08
04 00 62 63 64 65 66 67 68 69
[ 0 0 0 ]
[{"id":"440dc39decd59992","type":"function","z":"e0e6742e2f6dbb32","name":"function ","func":"var arr = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];\nmsg.payload=arr;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":220,"wires":[["4681174250f230f4","62eed776a0fae487"]]},{"id":"794846c8299b7423","type":"inject","z":"e0e6742e2f6dbb32","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":100,"y":220,"wires":[["440dc39decd59992"]]},{"id":"4681174250f230f4","type":"debug","z":"e0e6742e2f6dbb32","name":"debug 251","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":410,"y":220,"wires":[]},{"id":"62eed776a0fae487","type":"change","z":"e0e6742e2f6dbb32","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":180,"wires":[["6970876a0912347f"]]},{"id":"6970876a0912347f","type":"ui_dropdown","z":"e0e6742e2f6dbb32","name":"","label":"SECTOR NO:","tooltip":"","place":"Select option","group":"4375a788bff1fee7","order":1,"width":5,"height":1,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":600,"y":180,"wires":[["76f618d8468c543c","a34c99c30f9124ac"]]},{"id":"76f618d8468c543c","type":"debug","z":"e0e6742e2f6dbb32","name":"debug 252","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":240,"wires":[]},{"id":"173499103408be5a","type":"inject","z":"e0e6742e2f6dbb32","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":100,"y":280,"wires":[["e7c1df4d5e779173"]]},{"id":"e7c1df4d5e779173","type":"function","z":"e0e6742e2f6dbb32","name":"function ","func":"var arr = [0,1,2];\nmsg.payload=arr;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":280,"wires":[["2081dfec848a4f66","1bf54f0df38a17f6"]]},{"id":"1bf54f0df38a17f6","type":"change","z":"e0e6742e2f6dbb32","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":320,"wires":[["fcdf176530f8f52b"]]},{"id":"2081dfec848a4f66","type":"debug","z":"e0e6742e2f6dbb32","name":"debug 253","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":410,"y":280,"wires":[]},{"id":"fcdf176530f8f52b","type":"ui_dropdown","z":"e0e6742e2f6dbb32","name":"","label":"BLOCK NO:","tooltip":"","place":"Select option","group":"4375a788bff1fee7","order":3,"width":5,"height":1,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":590,"y":320,"wires":[["742b2a78cedc2748","9642693593b2476b"]]},{"id":"742b2a78cedc2748","type":"debug","z":"e0e6742e2f6dbb32","name":"debug 254","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":380,"wires":[]},{"id":"94dea7d5330ef913","type":"ui_button","z":"e0e6742e2f6dbb32","name":"","group":"4375a788bff1fee7","order":5,"width":5,"height":1,"passthru":false,"label":"讀取","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":70,"y":20,"wires":[["5e02e64f7e0fe670"]]},{"id":"df0a4bb4d3ae8982","type":"ui_button","z":"e0e6742e2f6dbb32","name":"","group":"4375a788bff1fee7","order":7,"width":5,"height":1,"passthru":false,"label":"寫入","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":70,"y":80,"wires":[["4479867fd9ee6b5e"]]},{"id":"cd3d4b973f912055","type":"ui_text_input","z":"e0e6742e2f6dbb32","name":"","label":"寫入的字串","tooltip":"","group":"4375a788bff1fee7","order":8,"width":11,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":90,"y":140,"wires":[["07075a7612c40bf4"]]},{"id":"a35a6bc7a0738026","type":"ui_text","z":"e0e6742e2f6dbb32","group":"4375a788bff1fee7","order":12,"width":11,"height":1,"name":"","label":"RFID讀取回來的字串","format":"{{msg.payload}}","layout":"row-spread","className":"","x":360,"y":480,"wires":[]},{"id":"5e02e64f7e0fe670","type":"function","z":"e0e6742e2f6dbb32","name":"function ","func":"var par1 = context.global.sec_no ;\nvar par2 = context.global.blk_no ;\nif(par1<10)\n{\n par1 = '0'+par1;\n}\nif(par2<10)\n{\n par2 = '0'+par2;\n}\nvar par3= par1+','+par2;\n\nmsg.payload=par3;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":20,"wires":[["63bbbc908a4787b8","15b3490a50a2ce6c"]]},{"id":"4479867fd9ee6b5e","type":"function","z":"e0e6742e2f6dbb32","name":"function ","func":"var par1 = context.global.sec_no ;\nvar par2 = context.global.blk_no ;\nvar par3 = context.global.str;\n\nif(par1<10)\n{\n par1 = '0'+par1;\n}\n\nif(par2<10)\n{\n par2 = '0'+par2;\n}\n\nvar par4= par1+','+par2+','+par3;\n\nmsg.payload=par4;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":80,"wires":[["f9d0f0c553234d13","15b3490a50a2ce6c"]]},{"id":"07075a7612c40bf4","type":"function","z":"e0e6742e2f6dbb32","name":"function ","func":"context.global.str=msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":140,"wires":[["df0a4bb4d3ae8982","b1113b320af0444b"]]},{"id":"a34c99c30f9124ac","type":"function","z":"e0e6742e2f6dbb32","name":"function ","func":"context.global.sec_no=msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":180,"wires":[[]]},{"id":"9642693593b2476b","type":"function","z":"e0e6742e2f6dbb32","name":"function ","func":"context.global.blk_no=msg.payload;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":320,"wires":[[]]},{"id":"63bbbc908a4787b8","type":"mqtt out","z":"e0e6742e2f6dbb32","name":"","topic":"alex9ufo/RFID/read","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"841df58d.ee5e98","x":570,"y":20,"wires":[]},{"id":"afa41963d4f07c3a","type":"mqtt in","z":"e0e6742e2f6dbb32","name":"","topic":"alex9ufo/RFID/back","qos":"1","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":110,"y":480,"wires":[["a35a6bc7a0738026"]]},{"id":"f9d0f0c553234d13","type":"mqtt out","z":"e0e6742e2f6dbb32","name":"","topic":"alex9ufo/RFID/write","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"841df58d.ee5e98","x":570,"y":80,"wires":[]},{"id":"15b3490a50a2ce6c","type":"debug","z":"e0e6742e2f6dbb32","name":"debug 255","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":370,"y":60,"wires":[]},{"id":"a306b5667ef71d7a","type":"mqtt in","z":"e0e6742e2f6dbb32","name":"","topic":"alex9ufo/RFID/read","qos":"1","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":110,"y":360,"wires":[["9b5a8a3ddd50ad7e"]]},{"id":"2958973746da924b","type":"mqtt in","z":"e0e6742e2f6dbb32","name":"","topic":"alex9ufo/RFID/write","qos":"1","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":110,"y":400,"wires":[["9b5a8a3ddd50ad7e"]]},{"id":"9b5a8a3ddd50ad7e","type":"ui_text","z":"e0e6742e2f6dbb32","group":"4375a788bff1fee7","order":10,"width":11,"height":1,"name":"","label":"MQTT 發行的字串","format":"{{msg.payload}}","layout":"row-left","className":"","x":330,"y":380,"wires":[]},{"id":"b1113b320af0444b","type":"debug","z":"e0e6742e2f6dbb32","name":"debug 256","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":410,"y":140,"wires":[]},{"id":"4375a788bff1fee7","type":"ui_group","name":"READ/WRITE 1K","tab":"048debf3dd7e9641","order":3,"disp":true,"width":11,"collapse":false,"className":""},{"id":"841df58d.ee5e98","type":"mqtt-broker","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"048debf3dd7e9641","type":"ui_tab","name":"2024 RFID ","icon":"dashboard","disabled":false,"hidden":false}]
沒有留言:
張貼留言