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
Balancing Empowerment & Direction
lara
6
1.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Abbi's Birthday
coloredviolet
4
10k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
36k
How GitHub (no longer) Works
holman
316
150k
Google's AI Overviews - The New Search
badams
0
1.6k
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Code Review Best Practice
trishagee
74
20k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
760
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
540
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ファイルで実行可能
いろいろなセンサー基板、機構 • 数百円から数千円程度で買える。 – はんだ付けは不要。(付属ピン 数本のみ)