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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Are puppies a ranking factor?
jonoalderson
2
4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
580
Utilizing Notion as your number one productivity tool
mfonobong
4
610
Building an army of robots
kneath
307
47k
エンジニアに許された特別な時間の終わり
watany
109
250k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
A Modern Web Designer's Workflow
chriscoyier
699
190k
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ファイルで実行可能
いろいろなセンサー基板、機構 • 数百円から数千円程度で買える。 – はんだ付けは不要。(付属ピン 数本のみ)