Upgrade to Pro — share decks privately, control downloads, hide ads and more …

玄関を Suica で開ける

B5afb655902c0dc47bf46c160f26e893?s=47 Coro
February 24, 2016

玄関を Suica で開ける

デブサミ2016 [19-E-7]IoTの未来はここにあった!大集合おうちハックLT祭 で使用したスライドです
http://event.shoeisha.jp/devsumi/20160218/session/1059/

B5afb655902c0dc47bf46c160f26e893?s=128

Coro

February 24, 2016
Tweet

Transcript

  1. ݰؔΛ Suica Ͱ։͚Δ @Coro365 1 σϒαϛ 2016 [19-E-7] IoTͷະདྷ͸͜͜ʹ͋ͬͨʂେू߹͓͏ͪϋοΫLTࡇ

  2. ݰؔΛ Suica Ͱ։͚Δ ͳΜͰ͔ͦ͢Εʁ(স) 2

  3. ݰؔΛ Suica Ͱ։͚Δ ͳΜͰ͔ͦ͢Εʁ(স) ݰؔͷ伴Λ Suica(NFC)Λ͔ͯ͟͠։͚Δ 3

  4. ݰؔΛ Suica Ͱ։͚Δ ߏ੒ Raspberry pi ϓϥε ϚΠφε ৴߸ઢ USB

    4 Servo NFC Reader
  5. ݰؔΛ Suica Ͱ։͚Δ ओཁΩϟϥΫλʔ ϥζϕϦʔ ύΠ Raspberry pi 5

  6. ݰؔΛ Suica Ͱ։͚Δ ओཁΩϟϥΫλʔ αʔϘϞʔλʔ Servo motor 6 GWS servo

    S03T/2BBMG/F τϧΫ:7.4kg
  7. ݰؔΛ Suica Ͱ։͚Δ ओཁΩϟϥΫλʔ ඇ઀৮ICΧʔυϦʔμ/ϥΠλ NFC Reader 7

  8. ݰؔΛ Suica Ͱ։͚Δ ओཁΩϟϥΫλʔ ίʔυ 8

  9. ిࢠ޻࡞͸ා͘ͳ͍ έʔϒϧΛ࡞Δ Step1 δϟϯύʔ ϫΠϠʔΛ༻ҙ 9

  10. ిࢠ޻࡞͸ා͘ͳ͍ έʔϒϧΛ࡞Δ Step2 ୺Λ੾Δ 10

  11. ిࢠ޻࡞͸ා͘ͳ͍ έʔϒϧΛ࡞Δ Step3 ൽບΛണ͘ 11

  12. ిࢠ޻࡞͸ා͘ͳ͍ έʔϒϧΛ࡞Δ Step4 ۚ۩Λ༻ҙ 12 ̦̞ίωΫλ ৴߸఻ୡίωΫλ༻ϐϯɹϝε

  13. ిࢠ޻࡞͸ා͘ͳ͍ έʔϒϧΛ࡞Δ Step5 δϟϯύʔ ϫΠϠʔ ͱۚ۩͕߹ମ 13

  14. ిࢠ޻࡞͸ා͘ͳ͍ έʔϒϧΛ࡞Δ Step6 ࠇ͍ιέοτΛ༻ҙ 14 ̦̞ίωΫλ ৴߸఻ୡίωΫλʢࠇʣ

  15. ిࢠ޻࡞͸ා͘ͳ͍ έʔϒϧΛ࡞Δ Step7 ࠇ͍ιέοτͱ߹ମ 15

  16. ిࢠ޻࡞͸ා͘ͳ͍ έʔϒϧΛ࡞Δ 16

  17. Ͳ͜Ͱങ͏ͷ 17

  18. Ͳ͜Ͱങ͏ͷ 18

  19. ݰؔΛ Suica Ͱ։͚Δ ߏ੒ Raspberry pi ϓϥε ϚΠφε ৴߸ઢ USB

    19 Servo NFC Reader
  20. ιϑτ෦෼ ϥΠϒϥϦ͕༏ल nfcpy ServoBlaster ͏͔͢͝ $ sudo apt-get install bzr

    $ cd <hoge> $ bzr branch lp:nfcpy trunk $ sudo apt-get install python-usb $ sudo python examples/tagtool.py 20
  21. ιϑτ෦෼ ϥΠϒϥϦ͕༏ल nfcpy ServoBlaster ͏͔͢͝ $ git clone git://github.com/ richardghirst/PiBits.git

    $ cd PiBits/ServoBlaster/user $ make $ sudo make install $ echo 4=90% > /dev/servoblaster 21
  22. http://a.com loop do idm = idm(nfc) unlock_user = USERS.key(idm) unless

    unlock_user == nil print("Welcome back #{unlock_user}!\n") unlock print("Wait #{AUTO_LOCK}sec...") sleep(AUTO_LOCK) print("\n") lock else print("Illegal user\n") end print("Please wait reader restart...\n") end ιϑτ෦෼ ϥΠϒϥϦ͕༏ल nfcpy ServoBlaster ͏͔͢͝ USERS = {"Bob_Marley" => "xxxxxxxxxxxxxxxx", "Alice_Cartelet" => "xxxxxxxxxxxxxxxx"} UNLOCK_ANGLE = "91" LOCK_ANGLE = "40" AUTO_LOCK = 40 def nfc() `sudo python ~/Documents/nfc/…/tagtool.py` end def idm(text) m = text.match(/ID=(.*?)\s/) idm =m[1] print("IDm = #{idm}\n") return idm end def unlock() `echo 4=#{UNLOCK_ANGLE}% > /dev/servoblaster` end def lock() `echo 4=#{LOCK_ANGLE}% > /dev/servoblaster` end 22
  23. http://a.com ιϑτ෦෼ ϥΠϒϥϦ͕༏ल nfcpy ServoBlaster ͏͔͢͝ 23 ಈը

  24. υΞͷ伴ʹऔΓ෇͚Δ 24

  25. υΞͷ伴ʹऔΓ෇͚Δ 25

  26. υΞͷ伴ʹऔΓ෇͚Δ 26

  27. υΞͷ伴ʹऔΓ෇͚Δ έʔϒϧΛ࡞Δ 27

  28. ׬੒ʂ 28 ಈը

  29. ͓ΘΓ @Coro365 ิ଍͸ͪ͜Β ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ http://coro.hatenadiary.jp/entry/2015/12/23/233434 29