1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspberry Pi | I2C > I2Cセンサーの接続確認まで > 使用品 | 配線 | i2cdetect | link:Rasberry PIのI2Cコマンド詳解

Last updated at Posted at 2018-02-27
Raspberry Pi 2 Model B (以下RPi)
Raspbian Jessie
Python 2.7.9
I2C接続のとあるセンサー

概要

I2C接続のとあるセンサーを使うことになった。
最終形は組込みCであるが、RPiで使い始めることで、トラブルの回避、問題の切り分けがしやすくなる。

使用

使用するものは以下の通り。

  • RPi + 40ピンソケット加工品
  • ジャンパーピン
  • ブレッドボード
  • プルアップ抵抗 x 2 (図面の抵抗値)
  • コンデンサ 104 (VCCとGND間)
  • I2Cセンサー

RPiのケース上にブレッドボードを載せ、配線をしておく

配線

以下を使う。

  • Pin# 01: VCC(3.3V)
  • Pin# 03: SDA1
  • Pin# 05: SCL1
  • Pin# 09: GND

I2CとしてはCHANNEL1を使うことになる。

RPiからの実行

$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

ただのしかばねのようだ。

こちらに記載のmodprobeを実行する。

$ sudo modprobe -r i2c-bcm2708
$ sudo modprobe i2c-bcm2708 baudrate=50000
$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --      

I2Cセンサー(特技: xxx、yyy測定)が仲間になりたそうにこちらを見ている。
仲間にしますか?

  • はい
  • いいえ

参考

組込みCでの実装

Python実装

対象のセンサーのPython実装のコードが見つかった。
それで動作確認したところ、期待した値を取得できた。
これで、ハードチェックは完了した。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?