LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsThe MAX30102 shines infrared light into your fingertip and measures how much is reflected. Each heartbeat pushes a little more blood through, which shows up as a tiny dip in the signal. The sketch spots those beats and averages the rate.
Not a medical device. Readings are for learning and must not be used for diagnosis.
Tick anything you already have and the total updates.
Red and infrared LEDs with a photodetector: blood absorbs light differently with each heartbeat, which the sensor picks up from your fingertip.
Follow the colours: red is power, dark grey is ground, blue is a signal.
heart_rate_monitor.inoVerify & upload in Electrolark// Fingertip heart-rate monitor
// Geekobot project library · board: Arduino Nano
// Wiring diagram, parts list and build steps: Geekobot project page "heart-rate-monitor"
#include <Wire.h>
#include "MAX30105.h"
#include "heartRate.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
MAX30105 pulseSensor;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const byte AVG = 4;
byte rates[AVG];
byte rateSpot = 0;
long lastBeat = 0;
int beatAvg = 0;
unsigned long lastDraw = 0;
void setup() {
Serial.begin(115200);
if (!pulseSensor.begin(Wire, I2C_SPEED_FAST)) Serial.println(F("MAX30102 not found"));
pulseSensor.setup();
pulseSensor.setPulseAmplitudeRed(0x0A);
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) Serial.println(F("OLED not found"));
oled.setTextColor(SSD1306_WHITE);
oled.clearDisplay();
oled.display();
}
void loop() {
long ir = pulseSensor.getIR();
if (checkForBeat(ir)) {
long delta = millis() - lastBeat;
lastBeat = millis();
float bpm = 60 / (delta / 1000.0);
if (bpm > 30 && bpm < 220) {
rates[rateSpot++] = (byte)bpm;
rateSpot %= AVG;
beatAvg = 0;
for (byte i = 0; i < AVG; i++) beatAvg += rates[i];
beatAvg /= AVG;
}
}
if (millis() - lastDraw < 200) return;
lastDraw = millis();
oled.clearDisplay();
oled.setTextSize(1);
oled.setCursor(0, 0);
oled.print(F("Heart rate"));
oled.setCursor(0, 20);
if (ir < 50000) {
oled.print(F("Place your finger"));
beatAvg = 0;
} else {
oled.setTextSize(3);
oled.print(beatAvg);
oled.setTextSize(1);
oled.print(F(" BPM"));
if (millis() - lastBeat < 150) oled.fillCircle(118, 8, 5, SSD1306_WHITE); // pulse dot
}
oled.display();
Serial.print(F("IR=")); Serial.print(ir); Serial.print(F(" BPM=")); Serial.println(beatAvg);
}
The sketch above runs here on a simulated Arduino Nano. Move the sliders for the sensors and buttons it reads, and watch the Serial monitor, display and outputs change.
Keep your finger still with light, steady pressure, and shield the sensor from room light.
Check SDA/SCL and try address 0x3D. Run an I²C scanner to confirm.
Open the Serial Monitor at 115200 baud and check for messages. Make sure you chose the right board and port in the Arduino IDE.
Close other programs using the serial port, try another USB cable (some are charge-only) and press reset just before uploading.
Yes. Most of the code works unchanged on an ESP32 with the ESP32 board package. Watch for 5 V modules: ESP32 pins are 3.3 V, so 5 V output signals need a resistor divider.
Use a 5 V USB phone charger or a power bank into the board's USB port.
5 parts: Nano CH340 Development Board (Soldered), MAX30102 Heart Rate & Pulse Oximeter Sensor Module, 0.96" OLED Display 128x64 (I2C), Solderless Breadboard (830 points) and Dupont Jumper Wires (40 pcs). Tools: Digital Multimeter and Wire Stripper and Cutter. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 1–2 hours. The build on this page has 7 steps.
No. This page has the complete, tested code (heart_rate_monitor.ino). Install these libraries first: SparkFun MAX3010x Pulse and Proximity Sensor Library, Adafruit SSD1306 and Adafruit GFX Library.
Yes. The Run it panel under the code runs this exact sketch on a simulated board. Move the sliders or press the buttons for the sensors it reads, and the Serial monitor, display and outputs react as they will on the real build. It is a simulation, so real readings depend on your parts and wiring.
About ₹568 for the parts at the prices on this page, plus tools if you do not have them. Quantity price breaks lower the cost when you build several.
Drawing text on an I²C display; Photoplethysmography (PPG).
Not a medical device. Readings are for learning and must not be used for diagnosis.
Ideas that reuse this build: Analog pulse sensor version. They are listed under Take it further on this page.
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
See the smoke level live on a crisp screen and get a loud warning when it spikes.
An infrared eye that spots an open flame and raises the alarm.
Walk into the room and it sounds the alarm: the classic first security build.
Learning project. Check every circuit and the datasheet of each part before you power it up.
IR=89627 BPM=0 IR=91427 BPM=18 IR=90552 BPM=18 IR=88643 BPM=18 IR=89278 BPM=18 IR=91267 BPM=36 IR=90881 BPM=36 IR=88844 BPM=36 IR=88973 BPM=36
A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.