Monitor Your Breath in Real Time
by Upside Down Labs in Circuits > Sensors
2176 Views, 20 Favorites, 0 Comments
Monitor Your Breath in Real Time
Turn your heartbeat into a breathing visualizer!
In this project, we’ll use the Heart BioAmp Candy to capture ECG (Electrocardiography) signals and detect the subtle changes that occur as you breathe. An Arduino processes the ECG data, while the Breathing Monitor Web App transforms those changes into a real-time visualization of your breathing pattern.
As you inhale, the R-peaks in the ECG signal typically become smaller. As you exhale, they become taller. The system tracks these changes to estimate your breathing phase and brings it to life with an animated balloon that inflates when you inhale and deflates when you exhale.
You’ll also get live visualizations of your ECG waveform, R-peak envelope, and breath strength, giving you a clear view of how your signals change with every breath.
Watch the full video of this instructable on youtube.
Supplies
Hardware
- Heart BioAmp Candy
- Arduino Uno R4 Minima
- Jumper wires
- BioAmp Snap Cable v3
- Gel electrodes
- USB Type-C cable
- Alcohol swabs
- Laptop or PC
Software
- Arduino IDE
- Chromium-based browser such as Google Chrome, Brave, or Opera
- Heart BioAmp Arduino Firmware
How It Works?
The Heart BioAmp Candy captures your ECG signal and sends it to the Arduino for processing.
As you breathe, the amplitude of the ECG R-peaks changes. The firmware analyzes these changes to detect your breathing phase—inhaling, exhaling, or holding your breath.
The processed data is sent to the Breathing Monitor Web App, which visualizes your breathing in real time using a balloon animation, ECG waveform, R-peak envelope, breath strength, and hold timer.
Breathing → ECG changes → R-peak analysis → Breathing detection → Visual feedback
Connecting the Hardware
- Connect the Heart BioAmp Candy to the Arduino Uno R4 Minima using jumper wires.
- Connect VCC on the Heart BioAmp Candy to 5V on the Arduino.
- Connect GND to GND.
- Connect OUT to A0.
- Double-check all connections before powering the circuit.
- Make sure the VCC and GND connections are not reversed, as incorrect power connections can damage the sensor.
Skin Preparation
- Clean the electrode placement areas using alcohol swabs or Nueprep.
- Gently wipe the skin to remove dirt, oil, and sweat.
- Allow the skin to dry completely before applying the electrodes.
- Make sure the skin is clean and dry for better electrode contact and signal quality.
Electrode Placement
Connect the BioAmp Snap Cable v3 to the gel electrodes.
Peel the electrodes from their backing and place them on your chest.
Use the following placement:
- IN− (black wire): Left side of the chest
- IN+ (red wire): About 2–3 cm to the right of IN−
- REF (yellow wire): Far right side of the chest or another suitable bony area
Try to keep the electrodes firmly attached and avoid excessive movement.
Tip: Sit comfortably and remain relatively still while recording for a better signal.
Download Arduino Firmware
The Arduino firmware and Breathing Monitor Web App are available in the Heart BioAmp Arduino Firmware repository.
- Open the Heart BioAmp Arduino Firmware GitHub repository.
- Click the green Code button.
- Select Download ZIP.
- Once the download is complete, extract the ZIP file to a folder on your computer.
- Open the extracted folder and locate the 08_Breathing_Monitor folder.
- This folder contains the Arduino firmware and Breathing Monitor Web App required for the project.
Upload the Firmware
- Connect the Arduino
- Connect the Arduino Uno R4 Minima to your computer using a USB Type-C cable.
- Open the Firmware
- Open the 08_Breathing_Monitor folder and double-click the .ino file. It will open in the Arduino IDE.
- Install the Board Package
- In Arduino IDE, go to Tools → Board → Boards Manager. Search for Arduino UNO R4 Boards and install the latest version.
- Select the Board
- Go to Tools → Board → Arduino UNO R4 Boards → Arduino Uno R4 Minima.
- Select the Port
- Open Tools → Port and select the port assigned to your Arduino.
- Upload the Firmware
- Click the Upload button in Arduino IDE and wait for the process to complete. Once the upload finishes successfully, your Arduino is ready to use with the Breathing Monitor Web App.
Improve Signal Quality
ECG signals can easily pick up electrical interference from the environment.
For cleaner recordings:
- Unplug your laptop from its charger.
- Stay a few meters away from AC-powered appliances.
- Keep your body and electrode cables as still as possible.
- Make sure the electrodes have good contact with your skin.
These steps can help reduce noise in your ECG signal.
Open the Breathing Monitor Web App
After uploading the firmware, open the Breath_Monitor_Web_App folder and double-click index.html to launch it in a Chromium-based browser such as Chrome, Brave, or Opera.
Connect Your Arduino
- Open the web app and click Connect in the top-right corner.
- A list of available serial devices will appear.
- Select your Arduino board and click Connect.
- The board may appear as CDC.
Tip: If the device list is crowded, temporarily turn off Bluetooth to make it easier to identify your Arduino.
Calibrate the Breathing Monitor
When you connect the device for the first time, a calibration window will appear.
- Click Start to begin the calibration.
- After a short countdown, follow the three guided breathing phases:
- Normal Breathing: Breathe normally for about 6 seconds.
- Deep Inhale and Hold: Take a deep breath and hold it for about 6 seconds.
- Slow Exhale: Slowly exhale for about 6 seconds.
- Follow each phase as instructed for accurate calibration.
The calibration process records the changes in your ECG signal during breathing and uses them to adjust the balloon's response to your breathing pattern.
Visualize Your Breathing
Once calibration is complete, take a few normal breaths and observe the visualization.
- Inhale: The balloon gradually inflates.
- Exhale: The balloon gradually deflates.
The web app also provides real-time signal visualizations:
- ECG Signal: Displays your ECG waveform in real time.
- R-Peak Envelope: Shows changes in the amplitude of the ECG R-peaks.
- Breath Strength: Indicates the estimated strength of your current breathing phase.
- Hold Timer: Starts counting when you take a deep breath and hold it.
Recalibrate the System
Your ECG signal can vary due to electrode placement, body movement, and other factors.
If the balloon does not respond accurately to your breathing, click the Calibrate button and repeat the calibration process.
Recalibrating helps the system adjust to your current signal range for a more responsive breathing visualization.
Troubleshooting
- Arduino not detected: Check the USB connection, firmware, and selected port.
- Noisy signal: Unplug the charger, move away from AC devices, and check electrode placement.
- Balloon responds incorrectly: Run the calibration again.
- Weak signal: Check electrode contact, cable connections, and power.
Conclusion
That’s it! You’ve built an ECG-based breathing monitor that captures ECG signals, analyzes R-peak changes, and visualizes your breathing in real time.
Explore different breathing patterns and observe how the ECG and breathing signals change. The complete firmware and web app are available in the Heart BioAmp Arduino Firmware repository, along with the Heart BioAmp Candy documentation.