ラズパイでant+を使います
参考
https://www.johannesbader.ch/2014/06/track-your-heartrate-on-raspberry-pi-with-ant/
仕様物
raspberry pi AZ4Uを扱う
sudo apt-get install -y libusb-1.0-0-dev libudev-dev
/etc/udev/rules.d/garmin-ant2.rules
を新規追加
/etc/udev/rules.d/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"
nodejsのインストール
sudo apt install -y nodejs npm
sudo npm install n -g
sudo n stable
sudo apt remove --purge nodejs npm
適当にプログラムをかく
set up
mkdir -p ~/project/ant
cd ~/project/ant
npm init
npm install ant-plus
example
index.js
に書く
index.js
constAnt=require("ant-plus");conststick=newAnt.GarminStick2();constsensor=newAnt.HeartRateSensor(stick);letcount=0;sensor.on("hbData",function(data){count+=1;console.log(count,data.DeviceID,data.ComputedHeartRate);});stick.on("startup",function(){console.log("on start up");sensor.attach(0,0);});asyncfunctionmain(){if(!stick.open()){console.log("Stick not found!");return;}}main();
start
node index.js