Polarize
GitHub Get in touch

Work · Repository

olimex-shield

EEG/ECG/EMG with an Arduino + Olimex SHIELD-EKG/EMG: firmware, bridge, recording workbench, playback, BIDS export

  • Python
  • MIT licence
  • 1 post
  • 3 merged PRs
  • 1 star

View on GitHub → Changelog ↓

Posts about it

README

Kind: tool · Stage: SHIPPED

Record EEG, ECG or EMG with an Arduino UNO and an Olimex SHIELD-EKG-EMG, a single-channel amplifier that costs about C$75 with the Arduino. This repo holds the sketch that runs on the board, a small bridge that reads it over USB and checks whether the signal can be trusted, and a browser workbench to watch, record, tag, play back and export to EEG-BIDS.

It was built for the Polarize.Tech post Can a $70 board tell me I’m wrong?, which characterises one board in numbers. This repo is the tool only: it holds no board’s measurements. Measure your own (Checking your board).

This is not a medical device. It is a hobby amplifier, and nothing it shows is a diagnosis. Read Safety before you put an electrode on anyone.

The rig

Olimex SHIELD-EKG-EMG board Olimex SHIELD-EKG-EMG-PRO electrode cable with three snap leads

The Olimex SHIELD-EKG-EMG and its SHIELD-EKG-EMG-PRO electrode cable. Photos: DigiKey, as used in the blog post.

Part Role
Olimex SHIELD-EKG-EMG Analog front end, 0.16–40 Hz, one differential channel
Olimex SHIELD-EKG-EMG-PRO cable 3.5 mm jack to three snap leads
Arduino UNO R3 10-bit converter and USB serial
Snap electrodes Disposable gel electrodes are best. The post used self-adhesive TENS pads, which are made for stimulation, not recording. Never ultrasound gel.

Wiring and flashing: apps/olimex-shield/README.md.

Quick start

You need Python 3.10+ and, for the hardware, pyserial.

git clone https://github.com/polarizetech/olimex-shield && cd olimex-shield
python3 -m pip install pyserial
python3 apps/web/serve.py

Open http://127.0.0.1:8150/. No board yet? Pick demo://synthetic. Synthetic data is badged as synthetic everywhere it goes, including recordings and exports.

What it can and cannot see

   
Band 0.16–40 Hz, set in hardware before the converter. Software cannot recover anything outside it.
Sample rate 250 Hz declared. Boards run slightly off nominal; the bridge measures it.
Resolution 10-bit ADC, one differential channel. The default µV scale (7.9 µV/count) is not externally verified and the gain differs per board: calibrate yours and set OLIMEX_UV_PER_COUNT (see hardware notes).
Intended for Resting alpha, ECG rhythm, muscle on/off. None of these is validated against a reference amplifier by this tool.
Not for Brainstem responses (they sit far above 40 Hz), skin conductance, or anything clinical.

Documentation

Safety

The workbench shows this list in full before every connection. Here it is too:

  1. This is NOT a medical device and nothing it shows is a diagnosis. If you are worried about your heart, your brain or your skin, this app is not the instrument to use.
  2. Run the board from a BATTERY-POWERED laptop, unplugged from mains. A mains-powered USB host puts your body between a wall socket and an electrode; the Olimex shield is not a medically isolated front end.
  3. Unplug EVERY mains-connected device from the laptop, not only the charger: an external monitor or HDMI cable, a powered USB hub or dock, an Ethernet cable, and any mains-powered audio interface or headphone amplifier used for stimuli. Each one is a path from mains, through the laptop, to the electrodes.
  4. If you cannot run on battery, a “properly isolated” power supply alone is NOT enough: isolate the USB data line too, with a USB isolator rated for patient connection (medical isolation, e.g. to IEC 60601-1). A general-purpose USB isolator is not a substitute.
  5. Never connect an electrode to anyone with an implanted pacemaker, ICD, or any other active implanted device.
  6. Never give current a path across the chest. While anything mains-referenced is connected, do not place electrodes on both arms or on both sides of the chest – an arm-to-arm or side-to-side pair puts the heart in that path. That includes this app’s own ECG limb leads: record them on battery only, with nothing else plugged in.
  7. Do not touch grounded metal – a radiator, a tap, a desktop PC’s case – while you are wired up. It gives any fault current a return path through you.
  8. Do not place electrodes on broken skin, on a rash, or over a wound.
  9. Stop immediately if the skin stings, burns, itches or reddens under an electrode.
  10. This app applies no current and delivers no stimulation of any kind. It only listens. If any part of the rig ever produces a sensation, disconnect it.
  11. One person, one rig, one session. Do not connect two people to the same amplifier.

Tests

python3 scripts/check.py

Status, citing and license

Released as-is for people who want to build the same rig; it is not yet packaged as a community open-source project. Versions are tagged, so download the latest release.

Cite with CITATION.cff. MIT licensed, see LICENSE. Vendored third-party files keep their own licences: the fonts in apps/web/vendor/design/fonts/ are SIL OFL (licence text beside each font), and the icons are a subset of Phosphor Icons (MIT, © Phosphor Icons).

Changelog

2026-11-29 #8

Upgrade to scaffold v0.15.0: research is saved, never a blocker

Runs scaffold update --apply: moves to scaffold v0.15.0, adding “Research is saved, never a blocker” to AGENTS.md and the role briefs, and moving the CI ref. Scaffold-managed files only; locally edited files that would lose content were kept. scaffold check: no failures. Earlier releases’ manual upgrade steps, where any were pending, are not done here.

🤖 Generated with Claude Code

2026-11-26 #6

Beats extension: live R peaks and R-R intervals (exploratory)

Adds extensions/beats/ (olimex-shield-ext-beats 0.1.0, catalogued, exploratory): GET /beats runs Elgendi 2013’s two-moving-average QRS detector (doi:10.1371/journal.pone.0073557) on the last 5 s of the live ring. It returns each beat once, numbered (k), with its host time t, age_s and rr_s. It is for polarize-holo’s ?heart=ecg (polarizetech/polarize-holo, branch claude/ecg-heart).

  • Settings from the paper: 8–20 Hz, third-order Butterworth run forward and backward, 97 ms and 611 ms windows, offset fraction 0.08. The extracted text prints “0.8”; the paper tested 0–10 % and found 2–10 % best. The owner approved this reading and the test.
  • Why this detector: Porr & Macfarlane 2024 (doi:10.1371/journal.pone.0309739) rank Elgendi among the best at rest.
  • Scope: scope/ecg-beats.md (explore tier). Stdlib only, and nothing on the recording path changes.

Checks: extensions/beats/dev_check.py 5/5, python3 scripts/check.py passes, ruff check . and ruff format --check . are clean. The route has been checked against the bridge’s demo://synthetic source only (EEG-like noise, so the beats it found there mean nothing). Not yet checked on a person wearing the shield.

🤖 Generated with Claude Code

2026-11-09 #5

0.3.0: tool kind and extensions, scaffold v0.12.0, merged with main

  • Commits the 0.3.0 work (tool kind, TOOL.toml, extension kit, experimental routes as an extension, tests/test_contract.py) that sat uncommitted in the main checkout since late September. Every suite in scripts/check.py passed on it unchanged.
  • Updates to scientific-research-scaffold v0.12.0 and KIT Adaptive Preregistration 949f0cd.
  • Merges main (docs site, reuse register, spectrum() fix). The one conflict was CHANGELOG.md: the fix is folded into 0.3.0, dated 2026-11-08 because 0.3.0 was never tagged; /spectrum is listed under Outputs changed (only the workbench draws from it).
  • Tagged v0.3.0 (annotated) at this branch’s tip.

Checks: scripts/check.py all ok (MNE-BIDS read-back, atlas and blog-post checks skipped as before); ruff clean; scaffold check 37 ok, 2 warnings (folder name; no SCOPE.toml). Used live: physical-nonlinear-mixing’s pnm calc --via olimex reads the shield through this bridge.

🤖 Generated with Claude Code