Hello, I'm trying to get BPM from the ESP32 board with a pulse sensor connected (from pulsesensor.com). The GettingStartedProject is working for me after changing the correct pins to the ESP32, but the "Getting_BPM_"to_Monitor" won't work for me..
/* Getting_BPM_to_Monitor prints the BPM to the Serial Monitor, using the least lines of code and PulseSensor Library.
* Tutorial Webpage: https://pulsesensor.com/pages/getting-advanced
*
--------Use This Sketch To------------------------------------------
1) Displays user's live and changing BPM, Beats Per Minute, in Arduino's native Serial Monitor.
2) Print: "♥ A HeartBeat Happened !" when a beat is detected, live.
2) Learn about using a PulseSensor Library "Object".
4) Blinks LED on PIN 13 with user's Heartbeat.
--------------------------------------------------------------------*/
#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.
// Variables
const int PulseWire = 36; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 2; // The on-board Arduino LED, close to PIN 13.
int Threshold = 2000; // Determine which Signal to "count as a beat" and which to ignore.
// Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.
// Otherwise leave the default "550" value.
PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called "pulseSensor"
void setup() {
Serial.begin(9600); // For Serial Monitor
// Configure the PulseSensor object, by assigning our variables to it.
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.
}
}
void loop() {
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("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".
Serial.print("BPM: "); // Print phrase "BPM: "
Serial.println(myBPM); // Print the value inside of myBPM.
}
delay(20); // considered best practice in a simple sketch.
}
Not tested but uses millis() instead of delay. As an idea.
Now what does "isn't working" mean?
My MPTT charge controller isn't working <<<< I mean really how helpful is that to you in trying to figure out why my solar cell is not working? Would you want more information?
I realized that the PulseSensorPlayground doesn't work with my board..
And I tried to find another way to measure BPM with my board but I found nothing
If you know any other way in order to measure BPM it'll help me a lot.
Thanks!
My board:
([Amazon.com]
The code you have posted uses IO-pin 36 as the inputpin for the heartbeat
const int PulseWire = 36; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
Your thread is another example why it is very important to tell a lot of details about a project
The microcontroller-word is
not
superstandardized like USB-devices
you have to take care of more details than just
"does the plug fit into the socket"
You are working on an informatic project. And what is most needed in an informatic project is information!
You should post exact that codeversion that you have tried
instead if just writing
You can post code by using this method that adds the code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps
press Ctrl-T for autoformatting your code
do a rightclick with the mouse and choose "copy for forum"
paste clipboard into write-window of a posting
best thing is to read
and follow the given tips there
It is up to you to post all this information right away
or loosing the support of the volunteers here by continuing posting too short non-informative postings.
There is a neverending stream of new questions from people that are able to give sufficient details about their project. Answering to such people is fun
Asking again and again for left out details is annyoing