5
3

More than 3 years have passed since last update.

Raspberry Pi と Python 3 を使ってANT+自転車パワーメーターの値を読む

Last updated at Posted at 2019-12-14

基本こちらの内容通りすれば動く
Track Your Heartrate on Raspberry Pi with Ant+

必要なもの

Raspberry Pi
USB ANT+ ドングル

USB-Serialの準備

USBドングルを指して dmesg | tail もしくは lsusb で idVendorとidProductを確認する

Bus 001 Device 004: ID 0fcf:1008 Dynastream Innovations, Inc. ANTUSB2 Stick

/etc/udev/rules.d/garmin-ant2.rules を編集して usbserial を設定

garmin-ant2.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fcf", ATTRS{idProduct}=="1008", RUN+="/sbin/modprobe usbserial vendor=0x0fcf product=0x1008", MODE="0666", OWNER="pi", GROUP="root"

/dev/ttyUSB0 があることを確認

ls /dev/ttyUSB0

ソフトウェアの準備

ソフトウェアは以下の repository をクローン。オリジナルは Python3 で動かない。こっちのフォークのほうが新しい。
mch/python-ant

クローンしてセットアップ

git clone https://github.com/mch/python-ant
cd python-ant
sudo python3 setup.py install

パワーメーターの信号を読み取る

自転車パワーメーターを読む場合は、 ID = 11, Period = 4091 もしくは 8182 となる。
python-antのサンプルコードを Python3 の文法に合わせて以下のようになった。
Git Repository python3-ant-receive

sudo python3 powermeter.py

5
3
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
5
3