概要
前回は 24GHz-mmWave-Radar-Sensor-Sleep-Breathing-Monitoring-Module を使用したが、今回は 60GHz mmWave Radar Sensor - Breathing and Heartbeat Module を試してみる。こちらは心拍数が計測できる。
試行
このボードは分析結果の数値をシリアルで渡してくれるので、M5Stackと GROVE - 4ピン-ジャンパメスケーブル で繋いで読み取る。
Groveの21ピンをrx、22ピンをtxに割り当て、それぞれボードのtx、rxに接続する。
main.cpp
#include <M5Stack.h>
HardwareSerial serial_ext(2);
#define MESSAGE_HEAD_1 0x53
#define MESSAGE_HEAD_2 0x59
#define MESSAGE_TAIL_1 0x54
#define MESSAGE_TAIL_2 0x43
int data[20] = {0};
int i, j = 0;
int Msg, Msg_prev;
void setup() {
M5.begin();
M5.Lcd.fillScreen(TFT_NAVY);
M5.Lcd.setTextColor(TFT_CYAN);
M5.Lcd.setTextSize(2);
M5.Lcd.drawString("Breathing rate:", 0, 0);
M5.Lcd.drawString("Heart rate:", 0, 120);
serial_ext.begin(115200, SERIAL_8N1, 21, 22);
Serial.print("Ready.");
}
void loop() {
if (serial_ext.available() > 0) {
Msg_prev = Msg;
Msg = serial_ext.read();
if (Msg_prev == MESSAGE_TAIL_1 && Msg == MESSAGE_TAIL_2) {
if (data[2] == 0x81 && data[3] == 0x05 && data[5] == 0x01) {
M5.Lcd.fillRect(40, 40, 100, 60, TFT_NAVY);
M5.Lcd.setCursor(40, 40);
M5.Lcd.setTextSize(6);
M5.Lcd.printf("%d", data[6]);
Serial.printf("Breathing rate: %d\n", data[6]);
} else if (data[2] == 0x81 && data[3] == 0x02 && data[5] == 0x01) {
M5.Lcd.fillRect(40, 160, 100, 60, TFT_NAVY);
M5.Lcd.setCursor(40, 160);
M5.Lcd.setTextSize(6);
M5.Lcd.printf("%d", data[6]);
Serial.printf("Heart rate: %d\n", data[6]);
} else {
for (j = 0; j < 20; j++) {
Serial.printf("%02x ", data[j]);
}
Serial.println("");
}
i = 0;
} else {
data[i] = Msg;
if (i < 19) i++;
}
} else {
delay(25);
}
M5.update();
}
課題
ドキュメントが役に立たない。
こちらも、受信はできるものの、ボードに対してコマンド送信がまだうまくいかない。