View
5
Download
0
Category
Preview:
Citation preview
● 2012 年以人工開 10 個櫃台報到 (1119 人 ) ● 2013 年以平板感應 NFC 的方式 ( 約 1500 人 )● 2014 年在報到入口加裝感應門 ( 約 1560 人 )
● 1 分鐘可以有 41 人報到● 平均一人報到時間為 1.46 秒● 有 197 人通過閘門但卡片感應失敗
● 2013/2014 的 NFC 由雪爾萊克 (Sharelike) 提供
近年來 COSCUP 報到方式
http://www.ithome.com.tw/news/89509
● 問題:● 本屆 PyCon 預估會有 800 人參加● 報到區需要 8 人以上
● 可能的解決方法:● 每個人上傳照片 , 會場以人臉識別報到● 寫手機 App, 讓所有人安裝 , 報到用手機感應● 寄發 NFC 識別證 , 報到時用識別證感應
● 問題:● 本屆 PyCon 預估會有 800 人參加● 報到區需要 8 人以上
● 可能的解決方法:● 每個人上傳照片 , 會場以人臉識別報到● 寫手機 App, 讓所有人安裝 , 報到用手機感應● 寄發 NFC 識別證 , 報到時用識別證感應
● 考慮因素:● 實做時間 , 價格 , 學習性
12http://us.moo.com/nfc/http://blogs.ifsworld.com/2013/06/come-on-apple-nfc-is-good-for-business/
NFC 線圈
可做成貼紙
13http://2d-code.co.uk/nfc-business-card/http://us.moo.com/nfc/http://blogs.ifsworld.com/2013/06/come-on-apple-nfc-is-good-for-business/
NFC 線圈
可做成貼紙
NFC 名片和手機互動的應用
● 無線射頻辨識 (Radio Frequency Identification)
RFID
http://www.intechopen.com/books/designing-and-deploying-rfid-applications/rfid-middleware-design-and-architecture
● 被動式 RFID● 晚上你坐在陽台 , 開啟燈光 , 鄰居走過來時因為
被燈光照到 , 所以你看到他
● 主動式 RFID● 晚上你坐在陽台 , 開啟燈光 , 鄰居看到光以後也
開了他的燈 , 所以你就看到他
RFID 情境
● 使用 Adafruit PiTFT 觸控螢幕
● 觸控螢幕 = 顯示 + 觸控 (SPI)● 常用的 RC522 RFID reader 使用 SPI 做資料交換
因為螢幕
https://www.adafruit.com/products/1601
NFC Data Exchange Format (NDEF)
Beginning NFC - Near Field Communication with Arduino, Android, and PhoneGap
● 硬體
● NFC Reader : PN532● RFID Tag : MiFare 感應白卡
● 軟體
● libnfc, pynfc
● 邏輯
● 事先儲存感應白卡的 UID● 當 reader 讀到 tag 的 UID 時做比對
實做 NFC 感應所需要的準備
● CREATE TABLE regist (
reg_no TEXT PRIMARY KEY,
uid TEXT,
ticket_type TEXT,
qrcode TEXT,
fullname TEXT,
nickname TEXT,
email TEXT,
gender TEXT,
nationality TEXT,
food TEXT,
tshirt TEXT,
mobile TEXT,
zip TEXT,
address TEXT,
attend_type TEXT,
regist_wtime TEXT DEFAULT 0,
tshirt_wtime TEXT DEFAULT 0,
is_sync TEXT DEFAULT 0);
37
● 以 USB 轉 TTL 傳輸線和 Pi 相連
● 接線方式● 黑色: Pin 6 (GND)● 白色: Pin 8 (Tx)● 綠色: Pin 10 (Rx)● 紅色:不接
Serial 連線方式
38
Raspberry Pi B 的 GPIO (P1)
黑色線接 6 號 ( 第三根 )
白色線接 8 號 ( 第四根 )
綠色線接 10 號 ( 第五根 )
http://elinux.org/RPi_Low-level_peripherals
39
Raspberry Pi B+ 的 GPIO (P1)
黑色線接 6 號 ( 第三根 )
白色線接 8 號 ( 第四根 )
綠色線接 10 號 ( 第五根 )
http://www.raspberrypi-spy.co.uk/2014/07/raspberry-pi-b-gpio-header-details-and-pinout/
40
● 安裝驅動程式 , http://goo.gl/QC5Q3O
● 從裝置管理員找到 COM 的埠號 ( 本例為 COM9)● 下載 putty, http://goo.gl/zdD9G9
● 執行 putty● Session● Serial line 填 COM9● Speed 填入 115200● Open !
● 沒畫面 , 重新插拔電源
Serial Port in Windows
41
● $ ls /dev/ttyUSB*● 開啟 putty
● 選擇 Session● 在 Serial line 填入 /dev/ttyUSB0 ( 本例為 ttyUSB0)● Speed 填入 115200● Open !
Serial Port in Linux
42
● 安裝驅動程式 , http://goo.gl/htlt3F● 重開機生效● $ ls /dev/cu*
● 如果有 /dev/cu.usbserial● $ screen /dev/cu.usbserial 115200
● 如果沒畫面 , 重新插拔電源
Serial Port in Mac
44
● 登入畫面
● pi 是登入的使用者
● @表示”在”● raspberrypi 是主機名稱
● ~表示在家目錄 (home directory)● $表示該使用者所使用的 shell( 一種文字工具介面 )● 例如 $ nano myfile.txt
● 表示用 nano編輯器開 myfile.txt檔案
符號說明
45
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
# /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="room142"
key_mgmt=NONE
auth_alg=OPEN
wep_key0=0223635251
}
在文字模式下設定無線網路
46
$ sudo ifdown wlan0
$ sudo ifup wlan0
$ sudo kill -9 $(ps -ef | grep wpa | awk '{print $2}')
$ sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
$ sudo dhclient wlan0
指令列設定 WiFi - 連線
● $ sudo apt-get update
● $ curl -SLs https://apt.adafruit.com/add | sudo bash
● $ sudo apt-get install -y adafruit-pitft-helper
● $ sudo vim /boot/config.txt
[pi1]
device_tree=bcm2708-rpi-b-plus.dtb
[pi2]
device_tree=bcm2709-rpi-2-b.dtb
[all]
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=pitft28r,rotate=90,speed=32000000,fps=20
安裝 PiTFT 驅動程式 (1)
https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi?view=all
● $ sudo mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf ~
● $ sudo vim /etc/modules
stmpe-ts
● $ sudo mkdir /etc/X11/xorg.conf.d
● $ sudo vim /etc/X11/xorg.conf.d/99-calibration.conf
Section "InputClass"
Identifier "calibration"
MatchProduct "stmpe-ts"
Option "Calibration" "3800 200 200 3800"
Option "SwapAxes" "1"
EndSection
安裝 PiTFT 驅動程式 (2)
https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi?view=all
● $ sudo vim /usr/share/X11/xorg.conf.d/99-pitft.conf
Section "Device"
Identifier "Adafruit PiTFT"
Driver "fbdev"● Option "fbdev" "/dev/fb1"● EndSection
安裝 PiTFT 驅動程式 (3)
https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi?view=all
● $ cd ~● $ wget http://libnfc.googlecode.com/files/libnfc-
1.7.0-rc7.tar.gz● $ tar zxvf libnfc-1.7.0-rc7.tar.gz● $ cd libnfc-1.7.0-rc7● $ ./configure --with-drivers=pn532_uart --with-
drivers=all ● $ make && sudo make install
下載與編譯 libnfc @ Pi
● $ sudo mkdir -p /usr/local/etc/nfc/devices.d● $ sudo cp
contrib/libnfc/pn532_uart_on_rpi.conf.sample /usr/local/etc/nfc/devices.d/pn532_uart_on_rpi.conf
● $ sudo vim /usr/local/etc/nfc/libnfc.conf
name = "PN532 board via UART"
connstring = pn532_uart:/dev/ttyAMA0
allow_intrusive_scan = true
複製設定檔 @ Pi
● $ cd ~/libnfc-1.7.0-rc7/utils
● $ LIBNFC_LOG_LEVEL=3 ./nfc-list
● $ cd ~/libnfc-1.7.0-rc7/examples
● $ ./nfc-poll
/home/pi/libnfc-1.7.0-rc7/examples/.libs/lt-nfc-poll uses libnfc 1.7.0-rc7
NFC reader: pn532_uart:/dev/ttyAMA0 opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 04
UID (NFCID1): fd 81 90 b5
SAK (SEL_RES): 08
測試 @ Pi
● $ sudo apt-get install sqlite3● $ sudo apt-get install -y python-pip● $ sudo pip install requests
安裝必要軟體
● Single(ATOM) statement● 合併 SQL語法● BEGIN TRANSACTION; SQL; COMMIT;
● 批次處理改為單次處理● execute改為 executescript
SQLite3 Tunning
● 情境● Remote server 有更新程式 / 設定檔需要部署
● 實做● Local host 開機後每分鐘檢查是否需要更新?● 當有網路以後會下載 remote server更新 script● 在下次重開機前將不會再更新
部署策略
● 每個使用者都有各別 DISPLAY 環境變數
● 切換成當前的使用者身份執行
● 實做● mysh = '/home/pi/sh/mysh.sh'● sudoPassword = 'raspberry'● os.system('echo %s|sudo -u pi %s' % (sudoPassword,
mysh.sh))
背景喚醒GUI 程式
http://simonmcc.blogspot.tw/2013/09/raspberry-pi-boot-straight-into-gui.html
● | Name | Pin # | Pin name |
|----------|--------- |---------------- |
| SDA | 24 | GPIO8 |
| SCK | 23 | GPIO11 |
| MOSI | 19 | GPIO10 |
| MISO | 21 | GPIO9 |
| IRQ | None | None |
| GND | Any | Any Ground |
| RST | 22 | GPIO25 |
| 3.3V | 1 | 3V3 |
腳位說明
● $ git clone https://github.com/mxgxw/MFRC522-python● $ cd MFRC522-python● $ sudo python Read.py
Card detected
Card read UID: 45,112,232,124,201
Size: 8
AUTH ERROR!!
AUTH ERROR(status2reg & 0x08) != 0
AUTH ERROR
下載 Reader 程式 & 測試
Recommended