Skip to content

Project of RFID access control reader based on Raspberry Pi with use C#. It uses SQL to check the entrance eligibility and write the time of get in.

License

Notifications You must be signed in to change notification settings

ArBom/AccessControlReader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AccessControlReader

Project of RFID access control reader based on Raspberry Pi with use C#. It uses SQL to check the entrance eligibility and write the time of get in.

About the App

One used finite state machines to design this software. You can see machine state diagram below.

stateDiagram-v2
    [*] --> Init
    Init --> Unconfig :SQL
    Unconfig --> Blocked :SQL
    Init --> Blocked :SQL
    Init --> Reading :SQL
    Unconfig --> Reading :SQL
    Blocked --> Reading :SQL
    Reading --> Blocked :SQL
    Unconfig --> Unconfig :SQL

    state Blocked {
        [*] --> _Blocked
        _Blocked --> BUnaOpen :DoorOpen
        BUnaOpen --> _Blocked :DoorClose
        _Blocked --> _Blocked :SQL
        _Blocked --> [*]
    }

    state Reading {
        [*] --> _Reading
        _Reading --> OpenRFID :ValidCard
        OpenRFID --> _Reading :t
        OpenRFID --> StillOpen :DoorOpen
        StillOpen --> _Reading :DoorClose
        StillOpen --> TooLondOpen :t
        TooLondOpen --> _Reading :DoorClose
        _Reading --> OpenButton :ButtonPres
        OpenButton --> _Reading :t
        OpenButton --> StillOpen :DoorOpen
        _Reading --> WrongCard :WrongCard
        WrongCard --> _Reading :t
        WrongCard --> RUnaOpen :DoorOpen
        _Reading --> RUnaOpen :DoorOpen
        RUnaOpen --> _Reading :DoorClose
            _Reading --> _Reading :SQL
        _Reading --> [*]
    }

The app starts the cyclic check of reader status, after boot itself. Reader can be switched off / blocked with SQL.

In time of use RFID card it check the entrance eligibility

sequenceDiagram
    actor U as User
    participant R as Reader
    participant D as Database
    U->>R: Getting close card to reader
    R->>D: Record existence check of card
    D->>R: Answer
    alt record exist
        R->>D: Take tier, user of card
        D->>R: Answer
        alt valid tier
            R->>D: Take user's data
            R->>D: Save record
            R->>U: entrance
        else invalid tier
            R->>D: Save record
            R->>U: no entry
        end
    else no exist 
        R->>D: Save data
        R->>U: no entrance
    end

How to run

You need to install .NET on your Raspbian. To do it You should follow the instruction at learn.microsoft.com To compile You need to install NuGet packages:

PM> NuGet\Install-Package Iot.Device.Bindings -Version 2.2.0
PM> NuGet\Install-Package Microsoft.EntityFrameworkCore -Version 7.0.5
PM> NuGet\Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 7.0.5
PM> NuGet\Install-Package Microsoft.EntityFrameworkCore.Tools -Version 7.0.5
PM> NuGet\Install-Package NetCoreAudio -Version 1.7.0
PM> NuGet\Install-Package System.Device.Gpio -Version 2.2.0

In time of first run App it create .xml file on your desktop. You should change connection string inside it, and if it is necessary, devices properties.

connection string placement

Hardware

Wire and devices connection schema consistent with default .xml file and most popular components' variant on market is featured bellow. Project foretakes a use of magnetic sensor to detect a door open, and monostable switch to open the door from inside. wiring schema Individual components may use different supply voltages. Make you sure they are connected correctly. Particular attention should be sensitive to the electric-bolt, and secure the rest of components. On schamat at above employed 24V-electic-bolt to open a door lock. In order to improve user-friendly communication and general make better design, several simple animations have been implemented, which are pesented in the table below. These animations are associated with states of device.

Info RFID Blockade No entry Entrance Alert Exclamation mark
info_sign rfid blocked stop_hand rgbkit (4)-min door_alert exclamation_mark

Exceptions handling

Click me to show at possible errors table
β„– Type Module Descripion I c o n s
1 DataBase Unconfig; reader just added itself to SQL
2 ⚠️ DataBase Lack of data about this reader at SQL πŸ“„ πŸ›’
7 πŸ’₯ DataBase ConnectionString is null or empty πŸ“„ πŸ›’
8 πŸ’₯ DataBase DonnectionString is: "❗❗❗ INSERT IT HERE ❗❗❗" πŸ“„ πŸ›’
9 ⚠️ DataBase Cannot to connect with DataBase πŸ“„ πŸ›’ πŸ–§
10 ️πŸ’₯ Configurator Platform not supported (its not Linux) :(
11 πŸ’₯ Configurator Cannot get the Desktop folder :(
12 ️πŸ’₯ Configurator Problem with default XML file (at app folder) :( πŸ“„
13 ⚠️ Configurator Cannot save default XML file at Desktop :( πŸ“„
14 πŸ’₯ Configurator XML file exist on Desktop, but it cannot be read :( πŸ“„
15 ⚠️ Configurator Problem inside XML file :( πŸ“„
16 ⚠️ Configurator MXL file exception πŸ“„
17 ⚠️ Configurator Cannot to read XML value (ACConfig/Devices) πŸ“„
18 ⚠️ Configurator Lack of XML Key :( πŸ“„
20 ️πŸ’₯ DataBase Config XML element is null πŸ“„ πŸ›’
22 ️πŸ’₯ DataBase No reader ID :(
30 ️πŸ’₯ GPIO XML config GPIO el. is empty πŸ“„ πŸ“Ÿ
31 ️⚠️ GPIO Reading of hardware property (GPIO) from XML problem πŸ“„ πŸ“Ÿ
32 ️πŸ’₯ GPIO Bolt pin is closed πŸ“Ÿ
33 ️⚠️ GPIO Exit Button pin is closed πŸ“Ÿ
34 ️πŸ’₯ GPIO Cannot to set Bolt pin value πŸ“Ÿ
35 ️⚠️ GPIO Cannot to open at least one pin πŸ“Ÿ
36 ️πŸ’₯ GPIO Bolt pin is closed πŸ“Ÿ
37 ️⚠️ GPIO Door Sensor pin is closed πŸ“Ÿ
40 ️πŸ’₯ RC522 XML config RC522 el. is empty πŸ“„ πŸ“Ÿ πŸ“‘
41 ️️πŸ’₯ RC522 Reading of hardware property (RC522) from XML proble πŸ“„ πŸ“Ÿ πŸ“‘
42 οΈοΈπŸ›ˆ RC522 Unknown RC522 hardware version πŸ“Ÿ πŸ“‘
43 ️πŸ’₯ RC522 mfRc522 is not an object at software πŸ“Ÿ πŸ“‘
50 ️⚠️ Screen XML config screen el. is empty πŸ“„ πŸ“Ÿ
51 ️⚠️ Screen Reading of hardware property (Sreen) from XML problem πŸ“„ πŸ“Ÿ
52 ️⚠️ Screen Communication with screen problem πŸ“Ÿ
60 ️⚠️ StateMachine XML config State Machine el. is empty πŸ“„
61 ️⚠️ StateMachine Reading of state text communicat from XML problem πŸ“„
74 οΈπŸ›ˆ GPIO Green diod pin closed πŸ“Ÿ
75 οΈπŸ›ˆ GPIO Diod pin(s) closed πŸ“Ÿ
77 οΈπŸ›ˆ GPIO Red diod pin closed πŸ“Ÿ
78 οΈοΈπŸ›ˆ GPIO Time of bolt open cannot be shorter than 1s πŸ“„ πŸ“Ÿ
79 οΈοΈπŸ›ˆ GPIO Time alert cannot be shorter than .5s πŸ“„ πŸ“Ÿ
80 οΈπŸ›ˆοΈοΈ Noises XML config Noises el. is empty πŸ“„ πŸ”‡
83 οΈπŸ›ˆοΈοΈ Noises Cant open noise file πŸ”‡
84 οΈπŸ›ˆοΈοΈ Noises Wrong format of noise file πŸ”‡

Error type: πŸ›ˆ- info ⚠️- warning πŸ’₯ -critical error

Icons: πŸ”‡-noises πŸ“‘-RC522 πŸ“Ÿ-hardware πŸ–§-LAN / connection πŸ›’-SQL πŸ“„-XML file :( - internal


Source of noises used at project: https://mixkit.co
License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0

About

Project of RFID access control reader based on Raspberry Pi with use C#. It uses SQL to check the entrance eligibility and write the time of get in.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages