Comments (4)
@FernandoDiogo99
I'm not sure I understand your issue.
The code that you posted reads the signal from the Pulse Sensor every 100ms (10Hz) and sends it over the serial port. That's all. It does not calculate BPM. It's best used with the Arduino serial plotter. Click on Tools > Serial Plotter
to open it, and make sure that the baud rate is 9600. Baud rate selector is in the lower right hand corner of the plotter window.
from pulsesensorplayground.
@FernandoDiogo99
Please let me know if my comment cleared up your issue.
from pulsesensorplayground.
@biomurph Hi! I have the same problem. My pulse sensor sends me high values and beside that it prints values even though I don't have the finger placed onto the sensor. Please I really need to know how to fix these two issues.
I am using this code:
//Variables
const int PulseWire = A0;
const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.
int Threshold = 550; //for heart rate sensor
float myTemp;
int myBPM;
String BPM;
String temp;
int error;
int panic;
int raw_myTemp;
float Voltage;
float tempC;
void setup()
{
Serial.begin(9600);
esp8266.begin(115200);
pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino's LED with heartbeat.
pulseSensor.setThreshold(Threshold);
// Double-check the "pulseSensor" object was created and "began" seeing a signal.
if (pulseSensor.begin()) {
Serial.println("We created a pulseSensor Object !"); //This prints one time at Arduino power-up, or on Arduino reset.
}
Serial.println("AT");
esp8266.println("AT");
delay(3000);
if(esp8266.find("OK"))
{
connectWiFi();
}
t.every(10000, getReadings);
t.every(10000, updateInfo);
}
void loop()
{
panic_button();
start: //label
error=0;
t.update();
//Resend if transmission is not completed
if (error==1)
{
goto start; //go to label "start"
}
delay(4000);
}
void updateInfo()
{
String cmd = "AT+CIPSTART="TCP","";
cmd += IP;
cmd += "",80";
Serial.println(cmd);
esp8266.println(cmd);
delay(2000);
if(esp8266.find("Error"))
{
return;
}
cmd = msg ;
cmd += "&field1="; //field 1 for BPM
cmd += BPM;
cmd += "&field2="; //field 2 for temperature
cmd += temp;
cmd += "\r\n";
Serial.print("AT+CIPSEND=");
esp8266.print("AT+CIPSEND=");
Serial.println(cmd.length());
esp8266.println(cmd.length());
if(esp8266.find(">"))
{
Serial.print(cmd);
esp8266.print(cmd);
}
else
{
Serial.println("AT+CIPCLOSE");
esp8266.println("AT+CIPCLOSE");
//Resend...
error=1;
}
}
boolean connectWiFi()
{
Serial.println("AT+CWMODE=1");
esp8266.println("AT+CWMODE=1");
delay(2000);
String cmd="AT+CWJAP="";
cmd+=SSID;
cmd+="","";
cmd+=PASS;
cmd+=""";
Serial.println(cmd);
esp8266.println(cmd);
delay(5000);
if(esp8266.find("OK"))
{
return true;
}
else
{
return false;
}
}
void getReadings(){
raw_myTemp = analogRead(A1);
Voltage = (raw_myTemp / 1023.0) * 5000; // 5000 to get millivots.
tempC = Voltage * 0.1;
//myTemp = (tempC* 1.8) + 32; // conver to F
Serial.println(tempC);
int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int".
// "myBPM" hold this BPM value now.
if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened".
Serial.println(myBPM); // Print the value inside of myBPM.
}
delay(20);
char buffer1[10];
char buffer2[10];
BPM = dtostrf(myBPM, 4, 1, buffer1);
temp = dtostrf(myTemp, 4, 1, buffer2);
}
void panic_button(){
panic = digitalRead(8);
if(panic == HIGH){
Serial.println(panic);
String cmd = "AT+CIPSTART="TCP","";
cmd += IP;
cmd += "",80";
Serial.println(cmd);
esp8266.println(cmd);
delay(2000);
if(esp8266.find("Error"))
{
return;
}
cmd = msg ;
cmd += "&field3=";
cmd += panic;
cmd += "\r\n";
Serial.print("AT+CIPSEND=");
esp8266.print("AT+CIPSEND=");
Serial.println(cmd.length());
esp8266.println(cmd.length());
if(esp8266.find(">"))
{
Serial.print(cmd);
esp8266.print(cmd);
}
else
{
Serial.println("AT+CIPCLOSE");
esp8266.println("AT+CIPCLOSE");
//Resend...
error=1;
}
}
}
from pulsesensorplayground.
@Perprintim
It looks like you're targeting an ESP8266. That means that the PulseSensor Playground library will be using a software interrupt. It's important that you do the same in your code. Take a look at the BlinkWithoutDelay sketch in the File > Examples > Digital
drop down for reference.
Also, try adjusting the Threshold variable upwards to avoid erroneous noise when not touching the sensor.
Also, send a pic of your Pulse Sensor and setup for verification.
from pulsesensorplayground.
Related Issues (20)
- USE_ARDUINO_INTERRUPTS problem with NodeMCU 0.9 HOT 3
- GETTING STARTED WORKING BUT NOT GETTING BPM TO MONITOR HOT 5
- Quick question, my smart meter has a pulse HOT 1
- Getting_BPM_to_monitor sketch displaying random values at 11250 baud HOT 8
- Node MCU V1 - Plotter is working but no BPM in Monitor HOT 3
- I'm getting high BPM HOT 1
- Code error for sp32 pulse sensor data to thinspeak HOT 19
- Compatibility issue Nano BLE ABX00034 HOT 6
- PulseSensr_BPM_Alternative Compilation Errors HOT 7
- turning off/on the bright light when needed HOT 2
- Can't compile even when including "USE_ARDUINO_INTERRUPTS true" HOT 14
- GETTING STARTED WORKING BUT NOT GETTING BPM TO MONITOR , ALTERNATIVE HOT 1
- No BPM readings HOT 3
- Problem about sensor when connecting with Arduino NANO 33 loT HOT 3
- Pulse sensor BPM_to_Monitor script does not work on Arduino Nano Every HOT 5
- example for esp8266 HOT 3
- sampleTimer.stop() and sampleTimer.start issues HOT 6
- `multiple definition of __vector_11` when including `<Servo.h>` HOT 14
- When using the duration parameter of tone, the sound will be distorted HOT 12
- Heart rate is abnormally high HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pulsesensorplayground.