在Arduino上自己动手的智能计算机插座

图片


前言


Arduino上的智能插座,可能更简单。该项目的主要目标是开发具有无线控制功能的套接字,以及“自动化” Windows的入口。激励因素是弄清楚什么是RFID标签以及如何使用它们。结果,开发了两种设备-一个读取卡的解锁器和一个实际上从该解锁器接收“打开”信号的智能插座。如果我对您感兴趣,请阅读。


, 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- ( -, ). , ( ) "" .


固件代码


https://bitbucket.org/sashadereh/arduino-smart-socket/src

Source: https://habr.com/ru/post/zh-CN395461/


All Articles