Commit 0ca5c24d authored by jake.greenwood's avatar jake.greenwood

Add new file

parents
#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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment