LoginSignup
1
1

More than 3 years have passed since last update.

RaspberryPiで重さ測る その1 導入編

Last updated at Posted at 2020-02-22

モチベーション

重さ測りたい

参考ページ

環境

RaspberryPi3B+
Raspbian 9.8
RPi.GPIO
python

追加購入品

接続

VCC - Raspberry Pi3 5V Pin 2
GND - Raspberry Pi3 GND Pin 6
DT - Raspberry Pi3 BCM5 Pin#29
SCK - Raspberry Pi3 BCM6 Pin#31

テスト用ソフトウェアの入手

pi@raspberrypi:~/loadcell $ git clone https://github.com/tatobari/hx711py
Cloning into 'hx711py'...
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 220 (delta 11), reused 14 (delta 5), pack-reused 198
Receiving objects: 100% (220/220), 58.69 KiB | 0 bytes/s, done.
Resolving deltas: 100% (116/116), done.

実行

pi@raspberrypi:~/loadcell/hx711py $ python example.py
Tare done! Add weight now...
-1763
285
797
2845
2845
3869
2845
797
5149
3869
2845
3869
3869
3869
2845
4381
4893
4637
^CCleaning...
Bye!

補正値(REFFERENCE UNIT)を決める

キッチンスケールで測ったら274.5gであったマグカップをロードセルに乗せて実行

pi@raspberrypi:~/loadcell/hx711py $ python example.py
~~省略~~
102959
102931
102967
102935
102981
102987
102965
102946
103002

平均すると102973.8438なので
102973.8438 / 274.5 = 375.1324
を補正値に採用する。
ソースコードを一部改変。

example.py
referenceUnit = 375.1324
pi@raspberrypi:~/loadcell/hx711py $ python example.py
~~省略~~
274
274
274

g単位の精度はありそうです。
おわり。

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