Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Golang+Raspiで趣味的IoT入門的な話
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
y_matsuwitter
April 13, 2015
Programming
3k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Golang+Raspiで趣味的IoT入門的な話
Gunosy.go#12にて
y_matsuwitter
April 13, 2015
More Decks by y_matsuwitter
See All by y_matsuwitter
LLMと共に進化するプロセスを目指して
ymatsuwitter
13
5.4k
Building Products in the LLM Era
ymatsuwitter
11
13k
Product Utilization of Large Language Models Starting Today
ymatsuwitter
3
3.5k
経営・意思・エンジニアリング
ymatsuwitter
23
22k
LLM in 2023 and 2024
ymatsuwitter
8
6.4k
Turbulent Technological Changes and Career Strategies
ymatsuwitter
2
3.3k
LLM in toB Service and Its UX
ymatsuwitter
7
12k
Agent and small LLM validation
ymatsuwitter
7
3.1k
Information management for a culture of speed: The story of Notion and LayerX
ymatsuwitter
4
11k
Other Decks in Programming
See All in Programming
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
560
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
270
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
370
Jetpack Compose メカニズム
skydoves
0
410
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
870
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
160
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
110
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
140
Heart of Swift Concurrency
koher
0
680
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.7k
Security issues being discussed on Web Platforms
petamoriken
0
930
Featured
See All Featured
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
430
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
690
Discover your Explorer Soul
emna__ayadi
2
1.3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
HDC tutorial
michielstock
2
870
Designing Experiences People Love
moore
143
24k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Transcript
Golang+RaspiͰझຯత IoTೖతͳ @y_matsuwitter
ࣗݾհ • ։ൃຊ෦ࣥߦһࡶ༻ • iOS, Android, Infrastructure, Web • Golangڭ
• ਖ਼࠲ • ࠷ۙؾʹͳΔͷ: MQTT
ࠓͷ • GolangͰݸਓझຯతʹIoTʹ৮Εͨ w/RaspberryPi • Gobotͱembdͷհ
: ిࢠ࡞ૉਓͷͰ͢
IoT(Internet of Things) • ༷ʑͳϞϊ͕ΠϯλʔωοτΛհͯ͠ܨ͕Δٕज़ͷ૯শ • ࠷᷿ۙͰେਓؾ
RaspberryPiͱ
Spec • খܕɾ҆Ձͳڭҭ͚LinuxϚγϯ • RaspberryPi Foundation͕։ൃ • CPU: ARM •
Memory: 256 ~ 1GB • USB microBͰڅి • GPIOϐϯ͕༻ҙ͞Ε͍ͯΔ
ARMͳͷͰ Golang͕ಈ͘ʂʂ GOARCH=arm go build
GPIO(General Purpose Input/ Output)ͱʁ • ଞσόΠεɺճ࿏ͱೖग़ྗΛߦ͏ͨΊͷΠϯλʔϑΣʔε • ιϑτΣΞଆͷࢦఆͰಈ࡞ΛΓସ͑Δࣄ͕Ͱ͖Δ
ࠓճͬͨͷ • SHT21 ... Թɾ࣪ηϯα • I2Cͱ͍͏ํࣜͰԹɺ࣪ΛΓͱ Γ͢Δ
I2Cͱ • ΈࠐΈػثͰར༻͞ΕΔγϦΞϧ௨৴ن֨ͷҰͭ • ͳ௨৴͕ڐ͞ΕΔ༻్͚ • Ұͭͷܦ࿏্ͰෳͷػثͱΓͱΓͰ͖Δ
GolangͰI2C • Gobotembdͷར༻ਪ
Gobot
About Gobot • GolangͰϋʔυΣΞϓϩάϥϛϯάશൠΛߦ͏ͨΊͷϑϨ ʔϜϫʔΫ • RaspberryPi, Arduino, AR.DroneͳͲͷαϙʔτ •
MQTT·ΘΓͷΞμϓλΛॳظ͔Βαϙʔτ • ͍͔ͭ͘ͷηϯαྨ͙͢ʹ͑ΔΑ͏υϥΠό༻ҙ͞Εͯ ͍Δ
Sample: ArduinoͰLEDͷ໓ package main import ( "time" "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/platforms/firmata" "github.com/hybridgroup/gobot/platforms/gpio"
) func main() { gbot := gobot.NewGobot() firmataAdaptor := firmata.NewFirmataAdaptor("arduino", "/dev/ttyACM0") led := gpio.NewLedDriver(firmataAdaptor, "led", "13") work := func() { gobot.Every(1*time.Second, func() { led.Toggle() }) } gbot.AddRobot(gobot.NewRobot("bot", []gobot.Connection{firmataAdaptor}, []gobot.Device{led}, work, )) gbot.Start() }
kidoman/embd
About embd • ΈࠐΈϓϩάϥϛϯά͚ϑϨʔϜϫʔΫ • GobotͱൺΔͱ͏গ͠ϨΠϠ? • ରԠগͳ͍ • ֤छBusΛ৮Γ͍͢
• Ұ෦ηϯαͷυϥΠό༻ҙ͞Ε͍ͯΔ
Sample: RasPiͰLED໓ package main import ( "time" "github.com/kidoman/embd" _ "github.com/kidoman/embd/host/rpi"
// This loads the RPi driver ) func main() { for { embd.LEDToggle("LED0") time.Sleep(250 * time.Millisecond) } }
embdͰSHT21͔ΒԹΛऔಘ • ࠓճEmbdͷI2CBusΛར༻ // Busʢܦ࿏ʣͷ࡞ bus := embd.NewI2CBus(1) // ॳظԽ
bus.WriteByte(addr, byte(softreset)) // ॳظԽྃͪ time.Sleep(500 * time.Millisecond)
ଓ͖ // ԹΛૹͬͯΒ͏Α͏৴߸ૹ৴ bus.WriteByte(addr, triggerTemperatureNoHold) // ϋʔυΣΞଆͷ৴߸ͪ time.Sleep(temperatureWait * time.Millisecond)
// 1όΠτಡΈग़͠ first, _ := bus.ReadByte(addr) // 2όΠτಡΈग़͠ second, _ := bus.ReadByte(addr) // ̎ͭͷΛݩʹηϧγεʹม temp := (175.72*float64((int64(first)<<8+int64(second))&statusBitMusk))/float64(1<<16) - 46.85
Ռ ఆظతʹࣨԹΛChatʹ͛ͯ͘ΕΔBot
ײ • Golangࣗମ͕ܰྔͳͷͰݸਓ࡞ͰͷΈࠐΈʹ͍͢ ͦ͏ • ίʔσΟϯάΑΓ֤छηϯαͷ༷ॻͱͷ֨ಆ • ֤छϑϨʔϜϫʔΫ͕༻ҙ͍ͯ͠ΔυϥΠό͑ΔηϯαΛ બͿํָ͕
ࢀߟ • RaspberryPi https://www.raspberrypi.org/ • Gobot http://gobot.io/ • embd http://embd.kidoman.io/