
Vorwort
Smart Socket auf Arduino, was einfacher sein könnte. Das Hauptziel dieses Projekts war es, Steckdosen mit drahtloser Steuerung zu entwickeln und den Zugang zu Windows zu "automatisieren". Die motivierende Komponente besteht darin, herauszufinden, was RFID-Tags sind und wie man mit ihnen arbeitet. Als Ergebnis wurden zwei Geräte entwickelt - ein Entsperrer, der Karten liest, und eine intelligente Steckdose, die vom Entsperrer ein Einschaltsignal empfängt. Wenn ich an Ihnen interessiert bin, lesen Sie bitte.
, RFID-, . . . ( ). , , , .
:

:

:
- Arduino Leonardo
- -D 12
- Bluetooth-
- 220, 2
- 220
. 15 15 .

. Arduino Leonardo, Uno, , USB-HID . Uno, , Windows . Leonardo , . Leonardo Arduino Due, Micro, Zero Esplora.
, :

10 AC250V DC30V. . , , :
digitalWrite(relay_pin, HIGH);
. , .
. DuPont. 2 . !
. , 12, 0,4 — Arduino. ? , , . Vin Arduino, — Gnd. : USB- Vin.
Bluetooth-
— Bluetooth-. HC-05, , .

, , — . , . , . . bluetooth- AT-. , AT- AT-. , (FC-114) (. ). AT-. , . - . , - AT-. , FC-114. 34 , , bluetooth- , 34 , Arduino.

bluettoth- HC-05. HC-05 " ". MAC-, . AT-, . RX bluetooth- 0 Arduino ( RX), TX 1 Arduino. , , UART Arduino. Arduino , UART Arduino.
void setup()
{
}
void loop()
{
}
, , , bluetooth-, AT-. , IDE (Tools -> Serial Monitor). , Serial Monitor, (baud rate) 38400 \r\n (Both NL & CR). , , "AT". "OK". "AT+NAME?". bluetooth-. -, , , MAC- , "Slave", "Master". :
AT+ROLE?
0 — , "Slave", 1 — "Master". , :
AT+ROLE=0 - "Slave":
MAC- Slave', Master , . :
AT+ADDR?
, : "ADDR:20:2:110001". , MAC- Slave' 20:2:110001.

Slave' . Master'. Arduino , Serial Monitor, 38400, /r/n. .
AT+ORGL
AT+RMAAD
AT+ROLE=1
AT+CMODE=1
AT+INIT
AT+INQ
AT+LINK=MAC- (: 20,2,110001)
, . ORGL , RMAAD "" Slave-. ROLE, , 1 , , Master. CMODE 1 ( 0) , Master- Slave- ( ). INIT SPP (Serial Port Profile), / . : " Bluetooth , , ". 17 . , , . INQ , Master- Slave-. — MAC- . :
+INQ:address,type,signal 20:2:110001,0,7FFF
. MAC- Slave' LINK Master- Slave'. , MAC- . bluetooth- ~2 . , . ( ) — , "".
AT-:

:

:

:
- Arduino Uno
- Bluetooth-
- RFID —
- LCD —
.
LCD —
LCD- 1620. 2 16 . Arduino I2C. I2C – , (SDA SCL). — . (master) (slave), master, . 127 . I2C , – (SDA, . Serial Dta) (SCL, . Serial Clock). LiquidCrystal_I2. . .
void lcd_display_two_lines(const char* first_line, const char* second_line)
{
g_lcd.clear();
g_lcd.setCursor(0, 0);
g_lcd.print(first_line);
g_lcd.setCursor(0, 1);
g_lcd.print(second_line);
}
RFID —

RFID . RFID- RC-522, HF, MIFARE 13,56 . Arduino SPI. SPI – , . SPI :
- MOSI – ;
- MISO – ;
- SCK – ;
- NSS – ,
RFID- , – .
RFID- MIFARE Classic
MIFARE Classic ( MIFARE DESFIre, , ). MIFARE 1K MIFARE 4K , 16 MIFARE 1K 40 MIfare 4K. MIFARE 1K 32 MIFARE 4K (Sector Trailer). 8 MIFARE 4K 15 (16-) . / .
"" . Sector Trailer ( ) , ( ). Sector Trailer () . MIFARE Classic / .
. 16 , / ( 0 0, -). / . /, ( ). (, ..). , increment/decrement. , , .
. MIFARE Classic . ( ). Access Condition ( Sector Trailer) ( ) . , MIFARE ( ) , MIFARE, . (Sector Trailer) (access bits) C1, C2 3. MIFARE. C1 (LSB).
, RFID-. : – RFID – , – RFID – . RFID – 128 . 128 = 8 16 . 3 1, 3 2 , , 2 3. , – B, trailer . 128 - , . — , , . - , . .

, Arduino. . RFID- , , bluetooth " Windows" . , RFID- . : , . , , RFID-. — .
, , " " — , . , (.. «»), . , «» , .

"" 20 , Arduino. . — ON, — , . :
pinMode(pin_number, INPUT)
pinMode(pin_number, INPUT_PULLUP)
, , bluetooth , Windows , — RFID-. , , , , - . , ID RFID- , , . , RFID-, , Read Only .. . , , , . . , , , . .
. , , RFID- MIFARE 1K. , 6 , 6 .
"" — 5 , , // . Master- bluetooth Slave-, , bluetooth-. - . , , Arduino, USB-.
. , RFID-. RFID-, RFID-. , , , "" . , Ethernet- WiFi-, management-. , ? , , "" -. RFID- ( -, ). , ( ) "" .
Firmware-Code
https://bitbucket.org/sashadereh/arduino-smart-socket/src