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
センサーをPCにつなげてpythonソフトで生データを取り込む
Search
miyasapi2
February 09, 2020
840
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
センサーをPCにつなげてpythonソフトで生データを取り込む
miyasapi2
February 09, 2020
More Decks by miyasapi2
See All by miyasapi2
ラズパイによる温度計測
satoshi2
0
440
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
290
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
440
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
First, design no harm
axbom
PRO
2
1.4k
Embracing the Ebb and Flow
colly
88
5.2k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
610
How to train your dragon (web standard)
notwaldorf
96
6.9k
Faster Mobile Websites
deanohume
310
32k
Making Projects Easy
brettharned
120
6.8k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
ノートPCとセンサーをつないで! Iotの周辺にて test_designer.ui @s_miya
お気軽に計測したい。 • ラズパイとセンサー基板をつなげれば、色々 なデータが取れるが! • キーボード,マウス,モニター,電源準備が面倒 • 外へは担いで持って行けない。
センサーとノートPCをつなげる。 • でも、PCとセンサーをつなげて動かしたい。 – ノートPCはUSBポートしかない。どうしよう。
ノートPCに中継基板 • あった!MCP2221AというIC – I2C、ADC,DAC、GPIOインターフェイスをサポート • 中継基板(I2C用)を作って、ノートPCにつなげ る。 210円
インターフェイス基板を制作 • 構成 – ノートPCのUSBにIF基板を接続。 IF基板 ノートPC センサー 5V、GND、 SCL、SDA(I2Cインターフェイス)
4本の線をつなげるだけ。
市販基板もあります。 • 部品をはんだ付けして基板を作るの嫌な人。 • マルツで売ってます。 – https://www.marutsu.co.jp/pc/i/1360420/ – 1500円
I2Cインターフェイス • I2C(inter-Integrated Ciruit)とは フィリップ社が提唱した周辺デバイスとのシリアル通信方式 アドレスは128指定でき、1バイトのデータ幅を持つ。 SCL、SDAの2つの信号を使用 I2Cインターフェイスのセンサーは多い。
ライブラリーのインストール • Windows環境では、MCP2221A基板用の pythonライブラリーがある。 • 下記のgithubを参照 https://github.com/nonNoise/PyMCP2221A/blob/master/READ ME_JP.rst pip install
PyMCP2221A
開発環境、プログラミング • I2Cインターフェイスライブラリ宣言 – この4行を入れるだけ。 • from PyMCP2221A import PyMCP2221A
• mcp2221 = PyMCP2221A.PyMCP2221A() • from PyMCP2221A import SMBus • bus = SMBus.SMBus() – 参考:ラズパイのライブラリー • import smbus • bus_number = 1 • bus = smbus.SMBus(bus_number)
I2Cの入出力 • 入出力(ラズパイも同じ。) – 入力 adrs=0x70 x1= bus.read_byte _data(adrs、0) –
出力 adrs=0x48,y1=0x55 bus.write_byte_data(adrs,0x00,y1)
開発 • 開発環境 – Jupite Note,SPIder,Pycharm何でも。 • ラズパイでも実行可能 – I2Cインターフェイスライブラリ宣言のみ変更
• おまけ – Windows環境では、Batファイルで実行可能
いろいろなセンサー基板、機構 • 数百円から数千円程度で買える。 – はんだ付けは不要。(付属ピン 数本のみ)