Simulator

A heart rate sensor simulator: a Pulse Sensor on an Arduino

Mokxi is a free online pulse sensor simulator that runs in your browser, with nothing to install and no account needed. A Pulse Sensor on A0 of an Arduino Uno, read by the PulseSensor Playground library, with an OLED that draws the wave and the heart rate. Set the pulse on the sensor and the reading follows, beat by beat.

  • 505parts on the bench
  • 45boards running now
  • 1.00xreal time, on every board
Arduino Uno: a heartbeat monitorlive0.000 s 0.00x
Click to open it in the editor
Click the circuit to open it in the editor. The OLED scrolls the pulse wave and the serial monitor prints each beat; drag the sensor’s heart rate up, or take the finger off.

What you can do here

In the circuit above, or in the editor it opens.

  • Set the heart rate on the sensor and watch the sketch measure it
  • Read beats per minute and the time between beats
  • See the raw pulse wave drawn on an OLED
  • Take the finger away and check the sketch shows no reading
  • Blink the board’s LED on every beat
  • Test a heart rate project without taping a sensor to your finger

What the running circuit shows

A wave, a threshold and the time between beats.

The sensor shines a green light into a fingertip and measures how much comes back; each heartbeat is a small bump in that signal. The library samples A0 in the background, calls it a beat when the wave crosses a threshold of 550 on the way up, and times the gap to the previous one. At the 72 beats a minute the sensor starts on, the monitor prints “beat: 72 BPM ibi 834”. The second number is the gap in milliseconds, and 60,000 divided by 834 is 72.

Set the sensor to 120 and after a few beats the line reads “beat: 120 BPM ibi 500”; set it to 180 and the gap falls to about 333 ms. The library averages over several beats, so the number takes a few seconds to follow a change, as it does on a wrist. Take the finger off the sensor and the beats stop arriving, and the display shows dashes instead of a number that is no longer true.

How the sensor is modeled

A clean pulse wave at the rate you choose.

The output is a voltage shaped like a real pulse wave, repeating at the rate you set. The library that ships with the real part reads it unchanged, so the sketch here is one you can upload to an Uno as it stands.

This finger is steadier than any real one. A real signal changes size with how hard you press, wanders as you move and picks up room light, and getting a clean reading is mostly a matter of holding still and shielding the sensor. None of that is modeled, and nothing here measures you: the number is the one you set. This is for building and testing the project, and no hobby sensor is a medical device.

How it works

Three steps from a blank tab to a running circuit.

  1. Open the editor

    It runs in your browser tab. Nothing to install, and you need no account to start.

    Your first project
  2. Wire it and write the code

    Drag parts onto a breadboard, run each wire from pin to pin, and write the sketch beside it.

    Wiring
  3. Press Run

    Your sketch compiles in the tab and runs on a model of the chip, with the Serial Monitor beside it.

    Run and serial
Reviews

What makers say about Mokxi.

“The AI checker helps check and correct my circuits, and it has way more components than Tinkercad. As a student I really appreciate the tool.”

ChloeEngineering student

“I’d been looking for a real online electronic simulator that was intuitive and complete when I found Mokxi. I was able to quickly import a Fritzing file and my Arduino sketch and start testing. Mokxi has all of the makings for the best online Arduino simulator I have been able to find!”

JayModel builderFeatured in his DioramaOS post

“I’m using Mokxi to develop and simulate an STM32-based four-wheel-drive robot car before building the actual hardware. It allows me to experiment with DC motor control, PWM, RPM measurement using photointerrupters, and different acceleration, braking, and reversing strategies, helping me understand and refine the system before implementing it in real life.”

NusretRobot car builder, Hamburg

Share your story

FAQ

Questions, answered.

Is it free?

Yes. The circuit on this page, every part in it and the editor it opens in are on the free plan, with no card.

Do I need an account?

No. The circuit runs the moment the page does, and the editor opens without one. A free account is only for saving a project to the cloud and sharing it by link.

Does the simulator measure my real heart rate?

No. Nothing is connected to you. You set a heart rate on the simulated sensor, and the sketch measures that, the same way it would measure the signal from a real sensor on a finger.

How does a pulse sensor work with an Arduino?

Its signal pin goes to an analog pin. The PulseSensor Playground library samples it, finds each beat as the wave crosses a threshold, and works out beats per minute from the time between beats.

What threshold should I use for a Pulse Sensor?

550 is the library’s usual starting point and the value in this sketch. On a real finger, raise it if noise is counted as beats and lower it if beats are missed.

More simulators

Each one opens on a circuit that is already running.

Take a pulse

Open the circuit, set a heart rate and watch the sketch find it. Nothing to install, and no account needed.