0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GROVE - GSRセンサーとArduino M5StickC Plus2 (ESP32)で緊張度を測定する

Posted at

GSRセンサーをつなげてseed studioのサンプルプログラムを書き込みましたが、起動しませんでした。
色々調べた結果、下記のコードで同等の結果を得ることができました

今回使用したGSRセンサーはこちら
うまく動かないメーカー(seed studio)のコード

修正して動作を確認したコードはこちら

```Arduino:GSR_reading.ino
#include <M5Unified.h>

const int GSR = 36;
int sensorValue = 0;
int gsr_average = 0;

void setup() {
  auto cfg = M5.config();
  M5.begin(cfg);
  Serial.begin(115200);
  
  pinMode(GSR, INPUT);
  gpio_pulldown_dis(GPIO_NUM_25);  // G36を使うときのおまじない
  gpio_pullup_dis(GPIO_NUM_25);
}

void loop() {
  long sum = 0;
  for (int i = 0; i < 10; i++) {
    sensorValue = analogRead(GSR);
    sum += sensorValue;
    delay(5);
  }
  
  gsr_average = sum / 10;
  Serial.print("GSR Average: ");
  Serial.println(gsr_average);

  delay(500);
}

なお出力は下記の要領で見られます
{5D041FF2-7374-4F4D-836D-75F42F34E37F}.png

115200に変更して下さい
{07D9BEB4-7C84-4854-9366-9C121B557F71}.png

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?