Cov txheej txheem:

RFID Kev Ruaj Ntseg Nrog LCD 1602: 4 Cov Kauj Ruam
RFID Kev Ruaj Ntseg Nrog LCD 1602: 4 Cov Kauj Ruam

Video: RFID Kev Ruaj Ntseg Nrog LCD 1602: 4 Cov Kauj Ruam

Video: RFID Kev Ruaj Ntseg Nrog LCD 1602: 4 Cov Kauj Ruam
Video: Secret Part. 40 (Tsev Kub Hnyiab liab Qab Tawm Nraum Zoov) 08/01/2020 2024, Kaum ib hlis
Anonim
RFID Kev Ruaj Ntseg Nrog LCD 1602
RFID Kev Ruaj Ntseg Nrog LCD 1602

Taw qhia

Niaj hnub no peb yuav ua qhov RFID Security System. Qhov no yuav ua haujlwm zoo li kev ruaj ntseg yog li thaum daim npav RFID lossis daim npav nyob ze nws yuav nthuav tawm cov lus ntawm LCD 1602. Lub hom phiaj ntawm txoj haujlwm no yog sim ua li cas RFID qhov rooj xauv ua haujlwm. Yog li, nws yuav ua haujlwm thaum daim npav RFID lossis daim npav nyob ze ntawm RFID Reader, nws yuav txheeb xyuas daim npav lossis cim npe thiab tso tawm cov lus ntawm LCD.

Khoom siv

  • RFID RC522 Nyeem Ntawv
  • Raspberry Pi 3
  • Cov qhob cij
  • Jumper Hlau
  • Zaub 1602
  • T-Cobbler

Tam sim no, Cia peb pib!

Kauj Ruam 1: Sib dhos RFID RC522 thiab LCD 1602

Sib sau ua ke RFID RC522 thiab LCD 1602
Sib sau ua ke RFID RC522 thiab LCD 1602

Yog li, tam sim no peb tab tom yuav xaim LCD thiab RFID rau lub khob cij. Hauv qab no yog daim duab nrog daim duab ntawm tus lej tus lej. Nws kuj tseem sau rau cov neeg uas tsis xav tau duab. Ntawm koj li RFID RC522 koj yuav pom tias muaj 8 qhov sib txuas tau ntawm nws, cov no yog SDA (Cov Ntaub Ntawv Tseem Ceeb), SCK (Serial Clock), MOSI (Master Out Slave In), MISO (Master In Slave Out), IRQ (cuam tshuam) Thov), GND (Lub Hwj Chim Hauv Ntej), RST (Rov Pib-Circuit) thiab 3.3v (3.3v Fais Fab Hauv). Peb yuav tsum tau xaim tag nrho cov no tab sis IRQ rau peb Raspberry Pi's GPIO pins.

Koj tuaj yeem xaim cov xov no ncaj qha rau GPIO Pins lossis zoo li peb tau ua hauv qhov kev qhia no, ntsaws RFID RC522 rau hauv peb lub Breadboard ces xaim los ntawm qhov ntawd rau peb Raspberry Pi's GPIO Pins.

Kev xaim koj li RFID RC522 rau koj Raspberry Pi yog qhov yooj yim haum, nrog nws xav kom koj txuas tsuas yog 7 ntawm GPIO Pins ncaj qha rau tus nyeem ntawv RFID. Ua raws cov lus hauv qab no, thiab txheeb xyuas peb phau ntawv qhia GPIO kom pom cov haujlwm ntawm GPIO tus pin uas koj xav tau txuas koj li RC522 rau.

SDA txuas rau tus Pin 24.

SCK txuas rau tus Pin 23.

MOSI txuas rau tus Pin 19.

MISO txuas rau tus Pin 21.

GND txuas rau tus Pin 6.

RST txuas rau tus Pin 22.

3.3v txuas rau Pin 1.

Thaum koj tau ua tiav nrog cov thaiv peb tuaj yeem mus rau qhov lom zem, coding! Wb mus

Kauj Ruam 2: Teeb RFID

Txhawm rau kom tau txais RFID los ua haujlwm, peb yuav tsum rub tawm qee qhov chaw cia khoom los ntawm GitHub siv lub davhlau ya nyob twg ntawm Raspberry Pi. Yog li, ua ntej tshaj plaws, muab koj cov kua txiv hmab txiv ntoo raspberry kom nws tuaj yeem qhib tau.

Qhib Terminal thiab ntaus qhov no:

sudo raspi-teeb tsa

2. Cov lus txib no yuav coj mus rau lwm lub vijtsam thiab los ntawm qhov ntawd, nqis mus rau Kev Xaiv Kev Sib Txuas thiab tom qab ntawd mus rau P4 SPI txhawm rau ua kom qhov kev xaiv ntawd.

3. Rov qab mus rau lub davhlau ya nyob twg thiab ntaus qhov no:

sudo rov pib dua

Peb ua qhov no yog li SPI tuaj yeem ua haujlwm tau zoo.

4. Thaum Raspberry Pi tau rov pib qhib Terminal thiab ntaus:

lsmod | pab spi

Peb yuav tsum ua qhov no txhawm rau txheeb xyuas yog tias SPI tau ua haujlwm raug. Yog li, yog tias koj pom spi_bcm2835 ces koj li RFID tau sau npe los ntawm Raspberry Pi thiab tam sim no koj tuaj yeem txav mus teeb LCD 1602

Teeb meem

Yog tias qee qhov laj thawj uas SPI tsis tau qhib ces ua raws cov theem no kom koj SPI ua haujlwm.

7. Yog tias qee qhov laj thawj SPI module tsis tau qhib, peb tuaj yeem hloov kho cov txheej txheem teeb tsa boot los ntawm kev siv cov lus txib hauv qab no ntawm peb Raspberry Pi.

sudo nano /boot /config.txt

8. Hauv cov ntaub ntawv teeb tsa, siv Ctrl + W nrhiav "dtparam = spi = on". Yog tias koj tau pom nws, txheeb xyuas seb puas muaj # nyob ntawm nws xub ntiag. Yog tias muaj tshem nws raws li qhov no tau tawm tswv yim txog kab ua kom ua. Yog tias koj tsis tuaj yeem pom kab txhua, tsuas yog ntxiv "dtparam = spi = on" rau hauv qab ntawm cov ntawv.

Thaum koj tau ua qhov hloov pauv, koj tuaj yeem nias Ctrl + X tom qab nias Y thiab tom qab ntawd Enter kom txuag qhov kev hloov pauv. Tam sim no koj tuaj yeem ua tiav los ntawm Kauj Ruam 5 dua, rov pib dua koj li Raspberry Pi tom qab ntawv txheeb xyuas seb puas tau qhib lub module.

Yog li tam sim no peb ua tiav nrog RFID thiab cia mus rau LCD 1602!

Kauj Ruam 3: Teeb LCD 1602

Yog li txhawm rau ua LCD kom pom cov tsiaj ntawv peb yuav tsum tau rub lub chaw cia khoom thiab peb tseem yuav tsum rub qee yam ntxiv.

1. Qhib lub davhlau ya nyob twg thiab ntaus qhov no txhawm rau teeb lub LCD chaw cia khoom:

git clone

2. Txhawm rau txheeb xyuas yog tias lub chaw cia khoom tau teeb tsa kom raug peb yuav tsum ntaus qhov haujlwm no hauv lub davhlau ya nyob twg:

ls ua

Yog tias koj pom daim nplaub tshev npe hu ua lcd ces koj tau ua tiav teeb tsa lub chaw cia khoom.

3. Tam sim no, peb yuav tsum hloov phau ntawv teev npe, peb tuaj yeem ua qhov no los ntawm kev ntaus hauv txoj haujlwm no:

cd lwd

4. Thaum kawg, peb yuav tsum ua cov ntaub ntawv nab npawb tshiab yog li ua cov ntaub ntawv nab npawb 3 tshiab thiab khaws cia rau hauv daim nplaub tshev tshiab thiab npe nws Security.py.

5. Tom qab ntawv, ntaus tus lej no hauv daim ntawv thiab khaws nws.

#!/usr/bin/env nab hab sej

ntshuam RPi. GPIO ua GPIO

ntshuam MFRC522 ntshuam teeb liab ntshuam lub sijhawm ntshuam lcddriver

txuas ntxiv_ nyeem = Tseeb

zaub = lcddriver.lcd ()

# Txheeb SIGINT rau kev ntxuav thaum tsab ntawv raug rho tawm

def end_read (teeb liab, thav duab): thoob ntiaj teb txuas ntxiv nyeem ntawv ("Ctrl+C ntes, xaus nyeem.") txuas ntxiv_reading = tsis tseeb GPIO.cleanup ()

# Nkag mus rau SIGINT

signal.signal (signal. SIGINT, kawg_read)

# Tsim lub hom phiaj ntawm chav kawm MFRC522

MIFAREReader = MFRC522. MFRC522 ()

# Zoo siab txais tos cov lus

print ("Zoo siab txais tos rau MFRC522 cov ntaub ntawv nyeem piv txwv") luam tawm ("Nias Ctrl-C kom nres.")

# Lub voj no tseem tshawb xyuas cov chips. Yog tias ib tus nyob ze nws yuav tau txais UID thiab txheeb xyuas qhov tseeb

thaum txuas ntxiv_ nyeem: # Luam theej duab daim npav (xwm txheej, TagType) = MIFAREReader. MFRC522_Request (MIFAREReader. PICC_REQIDL)

# Yog tias pom daim npav

yog tias xwm txheej == MIFAREReader. MI_OK: print ("Card kuaj pom") display.lcd_display_string ("Nyob Zoo Tib Neeg", 1) display.lcd_display_string ("Access Granted", 2) time.sleep (1.5) display.lcd_clear () # Tau UID ntawm daim npav (xwm txheej, uid) = MIFAREReader. MFRC522_Anticoll ()

# Yog tias peb muaj UID, txuas ntxiv mus

yog tias xwm txheej == MIFAREReader. MI_OK:

# Luam UID

print ("Daim npav nyeem UID: %s, %s, %s, %s") %(uid [0], uid [1], uid [2], uid [3]) # Qhov no yog lub hauv paus tseem ceeb rau kev lees paub tseeb qhov tseem ceeb = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF] # Xaiv lub cim scanned MIFAREReader. MFRC522_SelectTag (uid)

# Ua pov thawj

xwm txheej = MIFAREReader. MFRC522_Auth (MIFAREReader. PICC_AUTHENT1A, 8, qhov tseem ceeb, uid)

# Txheeb xyuas yog tias muaj tseeb

yog tias xwm txheej == MIFAREReader. MI_OK: MIFAREReader. MFRC522_Read (8) MIFAREReader. MFRC522_StopCrypto1 () lwm tus: luam tawm ("Kev lees paub yuam kev")

Kauj Ruam 4: Ua Kev Ruaj Ntseg Ua Haujlwm

Peb txhua tus tau teeb tsa thiab tam sim no peb tuaj yeem thaum kawg tau txais Kev Ruaj Ntseg Ua Haujlwm! Txhawm rau nws ua haujlwm peb yuav tsum qhib davhlau ya nyob twg.

1. Qhib davhlau ya nyob twg

2. Peb yuav tsum hloov cov npe rau lcd nplaub tshev yog li sau qhov no ntawm lub davhlau ya nyob twg:

cd lwd

3. Ntaus qhov no:

nab hab sej Security.py

Nyob zoo! Lub davhlau ya nyob twg yuav tsum hais qhov no "Zoo Siab Txais Tos Rau Kev Ruaj Ntseg."

Muab koj daim ID cim rau ntawm tus nyeem ntawv RFID thiab pom tias muaj dab tsi tshwm sim.

Yog tias RFID nyeem nws ces nws yuav hais daim npav kuaj pom ntawm lub davhlau ya nyob twg thiab ntawm lub LCD nws yuav tso tawm "Nyob Zoo Tib Neeg" thiab hauv qab nws "Access Granted"

Yog tias qhov no tsis tshwm sim nrog koj ces thov txheeb xyuas koj lub Circuit thiab thov kev pab

Pom zoo: