Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
COM6005M-IoT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jake.greenwood
COM6005M-IoT
Commits
0ca5c24d
Commit
0ca5c24d
authored
Jan 23, 2023
by
jake.greenwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
HeartRateSensor.ino
HeartRateSensor.ino
+97
-0
No files found.
HeartRateSensor.ino
0 → 100644
View file @
0ca5c24d
#include "DFRobot_Heartrate.h"
#include "rgb_lcd.h"
#include <WiFiNINA.h>
#include <ThingSpeak.h>
#include <Wire.h>
#include <Pushsafer.h>
#define heartratePin A1
const
int
colorR
=
255
;
const
int
colorG
=
0
;
const
int
colorB
=
0
;
char
thingSpeakAddress
[]
=
"api.thingspeak.com"
;
const
char
APIKey
[]
=
"Y4IXT1SYBRS3LXER"
;
const
unsigned
long
channel_id
=
2008164
;
const
int
updateThingSpeakInterval
=
1
*
1000
;
WiFiClient
client
;
rgb_lcd
lcd
;
#define PushsaferKey "YUOjrl0QMdnIeqWKsNLn"
Pushsafer
pushsafer
(
PushsaferKey
,
client
);
DFRobot_Heartrate
heartrate
(
ANALOG_MODE
);
///< ANALOG_MODE or DIGITAL_MODE
void
setup
()
{
char
ssid
[]
=
"VM9745152"
;
char
pass
[]
=
"4zpmvcNPtwbb"
;
int
status
=
WL_IDLE_STATUS
;
pinMode
(
6
,
OUTPUT
);
Serial
.
begin
(
9600
);
Serial
.
println
(
"Attempting to connect"
);
status
=
WiFi
.
begin
(
ssid
,
pass
);
if
(
status
!=
WL_CONNECTED
)
{
Serial
.
println
(
"Could not get Wifi connection!"
);
}
else
{
Serial
.
print
(
"Connected to"
);
Serial
.
println
(
ssid
);
}
ThingSpeak
.
begin
(
client
);
lcd
.
begin
(
16
,
2
);
lcd
.
setRGB
(
colorR
,
colorG
,
colorB
);
lcd
.
print
(
"DETECTING BPM!"
);
}
void
loop
()
{
uint8_t
rateValue
;
heartrate
.
getValue
(
heartratePin
);
///< A1 foot sampled values
rateValue
=
heartrate
.
getRate
();
///< Get heart rate value
if
(
rateValue
)
{
lcd
.
setCursor
(
0
,
0
);
lcd
.
print
(
" "
);
lcd
.
setCursor
(
0
,
0
);
lcd
.
print
(
"Your current BPM: "
);
lcd
.
setCursor
(
0
,
1
);
lcd
.
print
(
" "
);
lcd
.
setCursor
(
0
,
1
);
image
.
png
lcd
.
print
(
rateValue
);
digitalWrite
(
4
,
HIGH
);
//Serial.println(rateValue);
ThingSpeak
.
setField
(
1
,
rateValue
);
ThingSpeak
.
writeFields
(
channel_id
,
APIKey
);
struct
PushSaferInput
input
;
input
.
title
=
"BPM!"
;
input
.
message
=
(
String
(
rateValue
));
input
.
icon
=
"1"
;
input
.
vibration
=
"1"
;
input
.
device
=
"a"
;
input
.
device
=
"a"
;
input
.
url
=
"https://www.pushsafer.com/api"
;
input
.
urlTitle
=
"Open Pushsafer.com"
;
input
.
time2live
=
"0.032"
;
input
.
priority
=
"1"
;
Serial
.
println
(
pushsafer
.
sendEvent
(
input
));
Serial
.
println
(
"Sent"
);
delay
(
100
);
}
delay
(
20
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment