Hi, I'm using the playground pulse sensor and I got the exact code from the library called "Get_BPM_to_Monitor" but no value is being outputted in the serial monitor.
It shows the message a "We created a HeartSensor Object !" but then the BPM is not showing and no data s collected. All my wiring is correct, my power is on 5V, my gND is on GND, and my pulse is on A0, and I'm using an Arduino UNO Wifi Rev2.
Welcome After you follow @Railroader advice post an annotated schematic showing exactly how you have wired it, what parts you have used and be sure to show all power sources. Then post your code and links to technical information on all of the devices.
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.
// Variables
const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED = LED_BUILTIN; // The on-board Arduino LED, close to PIN 13.
int Threshold = 550; // 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(115200); // For Serial Monitor
// Configure the PulseSensor object, by assigning our variables to it.
pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED); //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() {
if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened".
int myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int".
// "myBPM" hold this BPM value now.
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.
}
this is the code that I'm using from the Pulse Sensor Playground library Example
All the serial printing and the delay will cause your program to miss many heart beats. Remove all of them and see if your program detects a heart beat.
Is the pulse sensor affixed to a living human or animal?
And did you place the vinyl cover on the front of the sensor, and velcro material on the back of the sensor, before attaching the sensor to the human/animal subject?
Please edit your post and enclose the sketch code inside "code" tags (select it and press the "<CODE/>" button from the editor's toolbar) to prevent the forum from "interpreting" special characters and making your code almost unreadable.
For more information, see How to get the best out of this forum.
The pulse sensor is being affixed to a human, and the vinyl cover and velcro material is correctly attached. The light from the sensor is facing my finger.
Also, I changed my schematic to be A0 for them to match.
I'm using the A0 pin in my circuit and I have the const int set to A0. I don't think that's related to the issue though. There's no values being updated and it says it cannot detect the start of a beat.