$30 off During Our Annual Pro Sale. View details »

Raspberry Pi と Netatmo と少しの ruby で作る二酸化炭素濃度モニター君

Raspberry Pi と Netatmo と少しの ruby で作る二酸化炭素濃度モニター君

2021-05-19 社内 LT 会資料

Yoshihide TANIGUCHI

May 19, 2021
Tweet

More Decks by Yoshihide TANIGUCHI

Other Decks in Programming

Transcript

  1. 2021-05-19 Wed / Quipper LT ձ Raspberry Pi ͱ Netatmo

    ͱ গ͠ͷ ruby Ͱ࡞Δ ೋࢎԽ୸ૉೱ౓Ϟχλʔ܅ @ravelll
  2. ࿩͢͜ͱ • 10෼͔͔ΒͣऴΘΔͱࢥ͍·͢ • ↓ʹ͍ͭͯ

  3. ػೳ • Netatmo Smart Home Weather Station Ͱଌఆͨ͠ೋࢎԽ୸ૉೱ౓Λ 1෼͝ͱʹऔಘͯ͠ LCD

    ʹදࣔɾߋ৽ • Netatmo ~ ͸ͳΜ͔৭ʑଌఆͰ͖ͯ໘ന͍ػցʢͪΐͬͱߴ͍ʣ
  4. ͳͥ࡞ͬͨʁ • Netatmo ͷଌఆ஋͸ Web ্ͷμογϡϘʔυͰ͔͠ݟΕͳ͍ • ݟΔͷʹ PC ΍εϚϗͷૢ࡞ඞਢͰ֬ೝ͕໘౗ͳঢ়گ͕͋Δ

    • -> ୭͔͕ৗʹ஋Λදࣔͯ͘͠ΕͨΒศརͦ͏ • ෦԰ͷ୨Ͱ຾Βͤͯͨ Raspberry Pi Ͱ༡ͼ͍ͨ
  5. ߏ੒ ruby process Netatmo API Server GET /api/get_station_info ଌఆ஋ Netatmo

    Smart Home Weather Station POST /oauth2/token access token atmo gem Send ଌఆ஋ / n min Raspberry Pi 3 Model B 1602 LCD I2C adapter i2c-ss1602 gem
  6. ίʔυ • https://github.com/ravelll/pi-co2-monitor • ؀ڥม਺ͷઃఆɾۭߦೖΕͯ΋30ߦະຬ • ऴྃ࣌ʹ clear ͠ͳ͍ͱϓϩηεࢮΜͰ΋࠷ޙʹऔಘͨ͠ଌఆ஋Λ දࣔ͠ଓ͚ͯ͠·͏ͷͰ

    at_exit Ͱ clear ͯ͠Δ
  7. ॴײ • ރΕͯΔػࡐͱطଘͷϥΠϒϥϦΛ૊Έ߹ΘͤΔ͚ͩͰγϡοͱͰָ͖ͯ͠ ͔ͬͨ • Raspberry Pi ৮ΔͷॳΊͯͳͱ͜Ζ͔Β5࣌ؒ͘Β͍ʁ • ಈ͘Ϟϊ͕Ͱ͖Δͱָ͍͠ͳͱ࠶ೝͨ͠

    • Netatmo API client Ͱ͋Δ atmo gem ͕ native extension ΛؚΉ gem ʹґଘ͠ ͍ͯΔΆ͘ɺruby-dev package ͷ install ͕ඞཁͩͬͨͷͰґଘͷগͳ͍ client gem ॻ͜͏͔ͳͱࢥͬͨ • ೋࢎԽ୸ૉೱ౓Λଌఆ͢ΔϞδϡʔϧ΋ൢച͞Ε͍ͯΔͷͰͦΕΛ࢖͑͹ɹ Netatomo ΁ͷґଘΛ੾ΕͯϙʔλϏϦςΟˢˢʹͳͬͯྑͦ͞͏