LoginSignup
0
1

More than 3 years have passed since last update.

RaspberryPiで重さ測る その2 2台編

Posted at

モチベーション

2台に増やしたい

環境

RaspberryPi3B+
Raspbian 9.8
RPi.GPIO
python
ロードセル
ADコンバータ HX711

接続

1台目

  • VCC青 - Raspberry Pi3 5V Pin#2
  • GND橙 - Raspberry Pi3 GND Pin#6
  • DT黄 - Raspberry Pi3 BCM5 Pin#29
  • SCK緑 - Raspberry Pi3 BCM6 Pin#31

2台目

  • VCC赤 - Raspberry Pi3 5V Pin#5
  • GND白 - Raspberry Pi3 GND Pin#9
  • DT黒 - Raspberry Pi3 BCM17 Pin#11
  • SCK茶 - Raspberry Pi3 BCM18 Pin#12

ソフトの仕様

2台を並行で動かしたいので
引数にREFFERENCE UNIT, DTのBCM値, SCKのBCM値を与えられるように変更

ソースコード

example.py
~~ 省略 ~~
    # 引数を変数に格納
    referenceUnit = int(args[1])
    dout = int(args[2])
    pd_sck = int(args[3])

~~ 省略 ~~
    # REFFERENCE UNITの設定
    hx.set_reference_unit(referenceUnit)

~~ 省略 ~~
   # dout, pd_sck を使ってHX711を初期化
   hx = HX711(dout, pd_sck)

実行

python example.py 1 5 6 

を実行した結果から1台目の補正値を計算 → 361

python example.py 1 17 18

を実行した結果から2台目の補正値を計算 → 375

以下の2つのコマンドを別のshellから起動することで2台の計測ができました。

python example.py 361 5 6 
python example.py 375 17 18
0
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
0
1