Created
July 1, 2020 06:37
-
-
Save IdrisCytron/6cf33a2bc370a13ef57c57f96f5ee7b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Project: Display Heart Rate Data on IoT Blynk Using Arduino (Maker UNO) | |
Board: Arduino Uno (Maker UNO) | |
Connections: | |
Maker UNO | Finger-clip Heart Rate | |
5V - VCC | |
GND - GND | |
SDA - SDA | |
SCL - SCL | |
External libraries: | |
- Blynk by Volodymyr Shymanskyy V0.6.1 (Manager) | |
- BlynkESP8266 by Volodymyr Shymanskyy (Zip) | |
https://github.com/vshymanskyy/BlynkESP8266 | |
*/ | |
#define BLYNK_PRINT Serial | |
#include <Wire.h> | |
#include <ESP8266_Lib.h> | |
#include <BlynkSimpleShieldEsp8266.h> | |
// You should get Auth Token in the Blynk App. | |
// Go to the Project Settings (nut icon). | |
char auth[] = "YourAuthToken"; | |
// Your WiFi credentials. | |
// Set password to "" for open networks. | |
char ssid[] = "YourNetworkName"; | |
char pass[] = "YourPassword"; | |
// or Software Serial on Uno, Nano... | |
#include <SoftwareSerial.h> | |
SoftwareSerial EspSerial(2, 3); // RX, TX | |
// Your ESP8266 baud rate: | |
#define ESP8266_BAUD 9600 | |
ESP8266 wifi(&EspSerial); | |
long prevMillis = 0; | |
int interval = 1000; | |
char bpm; | |
void setup() | |
{ | |
// Debug console | |
Serial.begin(9600); | |
EspSerial.println("AT+RST"); | |
delay(1000); | |
while (EspSerial.available()) { | |
EspSerial.read(); | |
} | |
// Set ESP8266 baud rate | |
EspSerial.begin(ESP8266_BAUD); | |
delay(10); | |
Blynk.begin(auth, wifi, ssid, pass); | |
Serial.println("heart rate sensor:"); | |
Wire.begin(); | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
if (millis() - prevMillis > interval) { | |
Wire.requestFrom(0xA0 >> 1, 1); // request 1 bytes from slave device | |
while(Wire.available()) { // slave may send less than requested | |
bpm = Wire.read(); // receive heart rate value (a byte) | |
Serial.println(bpm, DEC); // print heart rate value | |
} | |
Blynk.virtualWrite(0, bpm); | |
prevMillis = millis(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment