Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Golang+Raspiで趣味的IoT入門的な話
Search
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.1k
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.3k
Turbulent Technological Changes and Career Strategies
ymatsuwitter
2
3.2k
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時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
310
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
260
FDEが実現するAI駆動経営の現在地
gonta
2
280
What's New in Android 2026
veronikapj
0
250
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
210
React本体のコードリーディング
high_g_engineer
1
140
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
340
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
320
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
140
Android CLI
fornewid
0
210
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.6k
Featured
See All Featured
The Invisible Side of Design
smashingmag
301
52k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
520
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
450
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
850
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
410
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
460
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Code Reviewing Like a Champion
maltzj
528
40k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
260
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
630
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
340
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/