-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmax30003wing_ecg_plot.ino
68 lines (53 loc) · 1.99 KB
/
max30003wing_ecg_plot.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//////////////////////////////////////////////////////////////////////////////////////////
//
// Arduino code for the MAX30003 WING board
//
// This example plots the ECG through Arduino Plotter.
//
// Arduino connections:
//
// |MAX30003 pin label| Pin Function |Arduino Connection|
// |----------------- |:--------------------:|-----------------:|
// | MISO | Slave Out | D12 |
// | MOSI | Slave In | D11 |
// | SCLK | Serial Clock | D13 |
// | CS | Chip Select | D10 |
// | VCC | Digital VDD | +5V |
// | GND | Digital Gnd | Gnd |
// | FCLK | 32K CLOCK | - |
// | INT1 | Interrupt1 | 02 |
// | INT2 | Interrupt2 | - |
//
// Copyright © Md Abdur Rahman
//
/////////////////////////////////////////////////////////////////////////////////////////
#include <SPI.h>
#include "max30003.h"
#define MAX30003_CS_PIN 10
MAX30003 max30003(MAX30003_CS_PIN);
void setup()
{
Serial.begin(115200); //Serial begin
pinMode(MAX30003_CS_PIN,OUTPUT);
digitalWrite(MAX30003_CS_PIN,HIGH); //disable device
SPI.begin();
bool ret = max30003.max30003ReadInfo();
if(ret){
Serial.println("Max30003 read ID Success");
}else{
while(!ret){
//stay here untill the issue is fixed.
ret = max30003.max30003ReadInfo();
Serial.println("Failed to read ID, please make sure all the pins are connected");
delay(10000);
}
}
Serial.println("Initialising the slave device ...");
max30003.max30003Begin(); // initialize MAX30003
}
void loop()
{
max30003.getEcgSamples(); //It reads the ecg sample and stores it to max30003.ecgdata .
Serial.println(max30003.ecgdata);
delay(8);
}