Hello friends, I hope you all are doing great. Today, I am going to share the new MPR121 Touch Sensor Library for Proteus Simulation. The MPR121 turns any piece of copper, foil or conductive paint into a touch key: twelve of them on a single I2C chip, each with its own threshold, its own baseline that follows the room, and an interrupt pin that tells your microcontroller the moment something changes. It is the chip behind touch keyboards, fruit pianos and capacitive control panels. With this library you can run a full Proteus simulation of the popular MPR121 breakout - the registers, the electrodes' data and baselines, the thresholds, the IRQ - and touch its electrodes from the pop-up, the sheet or your own circuit.

Figure: The MPR121 simulation running: the electrodes touched one after the other, each playing its note.
Updates

MPR121 Touch Sensor Library for Proteus

Latest version: V1.0 (November 2026, this tutorial)

Used in the demo: Mini Speaker · Resistor

Helping Tools

The demo builds a twelve-key touch piano: an Arduino reads the touches on IRQ and plays a note on a speaker for each electrode.

NOTICE: Our team has put a lot of effort into these small parts: the bodies, the animation and the pop-ups are all our own design, and you get them free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the push-button board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the MPR121 Touch Sensor Library for Proteus Simulation:

Figure: The MPR121 Touch Sensor Library for Proteus Simulation.

What Is the MPR121 Touch Sensor?

The MPR121 is a capacitive touch controller with twelve electrode inputs. For each electrode it charges the electrode's capacitance with a known current for a known time and measures the voltage it reaches - a number of about 700 for a bare pad. A finger adds capacitance, so the same charge gives a lower voltage and the number drops. The chip filters each electrode's data, keeps a slowly moving baseline for it, and declares a touch when the data falls far enough below the baseline. The popular breakout adds a 3.3 V regulator, the I2C pull-ups and a power LED, and brings out the twelve electrodes and the IRQ pin.

The MPR121 at a glance
MPR121 touch sensor board
Electrodes12 (E0 - E11), any conductive pad
InterfaceI2C at 0x5A - 0x5D (the ADD pin)
InterruptIRQ, open drain, active low
Supply3.3 V (the breakout regulates)
Data10-bit filtered data and 8-bit baseline per electrode
Usestouch keyboards and pianos, control panels, interactive art

Filtered Data, Baseline and Delta

Every electrode has two numbers. The filtered data is the latest measurement, smoothed. The baseline is the chip's idea of what the electrode reads when nobody touches it, and it follows slow changes - humidity, temperature, a cover being fitted - by small steps. The difference, baseline minus data, is the delta. A touch is declared when the delta exceeds the electrode's touch threshold, and released when it falls under the release threshold. The gap between the two (12 and 6 is a common choice) keeps a borderline touch from flickering, and the debounce register can demand several samples in a row.

Stop Mode and Run Mode

The electrode configuration register, ECR at 0x5E, starts and stops the measurements. Its low four bits say how many electrodes run - 12 for all of them - and its top two bits say how the baselines start: from the register, from the first samples' five high bits, or from all ten bits. While ECR is zero the chip is in stop mode, and only then does it accept writes to its configuration registers, 0x2B to 0x7F. That catches many first sketches: they change a threshold while the chip runs and nothing happens. The library follows the same rule and warns in its event log.

IRQ

Polling twelve electrodes over I2C all the time is wasteful. The MPR121 pulls its IRQ pin low whenever the touch status changes, and releases it when the host reads the status registers 0x00 and 0x01. A sketch can simply watch one input pin and talk to the chip only when there is news - which is exactly what the demo does.

The Touch Sensor in the Simulation

The model is a complete I2C slave with the MPR121's register map: the pointer byte first, auto-increment, the status, data, baseline, threshold, debounce, configuration and ECR registers, the soft reset (0x80 = 0x63) and the stop-mode rule. Every sample period it computes each running electrode's filtered data, moves the baselines, applies the thresholds and the debounce, and updates the status and IRQ. A finger is modelled as 60 counts of added capacitance growing over 30 ms. The fingers can come from four places: the TOUCH property's DEMO sequence, the pop-up's E0 - E11 chips, a click on an electrode pin on the sheet, or the circuit itself - an electrode pin pulled LOW, for example by a pushbutton to GND, counts as a finger.

Features of the MPR121 Touch Sensor Library for Proteus Simulation

  • A real-looking board: the 24 x 34 mm breakout at its real size; touched electrode pads light up on the sheet (blue for a finger, green when the MPR121 reports it).
  • The real register map: status, data, baselines, thresholds, debounce, ECR, soft reset, and the stop-mode rule.
  • Real touch logic: deltas against the baselines, touch and release thresholds, debounce, IRQ.
  • Four ways to touch: the DEMO sequence, the pop-up's chips, clicks on the sheet, or a pin pulled low by your circuit.
  • A pop-up: all twelve electrodes with their data, baselines and deltas, a touch history, eight tiles - graphs, an event log and a check page.
  • A complete package: about 1.9 MB with the library, our resistors and speaker, our Arduino UNO V4.0 and the demo, without the source code of the model.

The MPR121 in Proteus

The device is TOUCHMPR121TEP in TEPMPR121.LIB, under Modules > Sensors, with the prefix U and the model TEPMPR121.DLL. Search MPR121 or touch in Pick Devices. On the left are IRQ, SCL, SDA, ADD, 3.3V and GND; on the right the twelve electrodes E0 to E11. One property: TOUCH, DEMO or NONE.

Figure: The MPR121 touch sensor board.

Download MPR121 Touch Sensor Library for Proteus Simulation

Click the button below to download MPR121-Touch-Sensor-Library-for-Proteus-v1.0.zip (about 1.9 MB, without the source code of the models):

MPR121 Touch Sensor Library for Proteus V1.0
  • README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
  • Proteus Library Files: TEPMPR121.LIB, TEPRESISTOR.LIB, TEPSPEAKER.LIB and ArduinoV4TEP.LIB.
  • Proteus Model Files: TEPMPR121.DLL, TEPRESISTOR.DLL, TEPSPEAKER.DLL and TEPARDUINO.DLL.
  • Arduino Code: the demo sketch (Wire only).
  • Proteus Simulation: the demo project, its HEX file and copies of the DLLs.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install MPR121 Touch Sensor Library for Proteus Simulation

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the files from Proteus Model Files into the MODELS folder.
  4. Delete TEPMPR121.IDX from the LIBRARY folder if it is there.
  5. Start Proteus, press P and search for MPR121.

Proteus Simulation of a Touch Piano

The demo uses an A4 sheet with our Arduino UNO Library for Proteus V4.0 and the MPR121 U1: SDA and SCL on A4 and A5, IRQ on D2, ADD and GND to ground, 3.3V on +3.3V. A 28 mm speaker from our Mini Speaker Library for Proteus plays the notes from D8 through a 100 ohm resistor. The board's TOUCH property is DEMO, so the electrodes get touched by themselves; the electrode pins are left open, ready for buttons of your own. The Arduino's monitor is built in, the same window as our TEP Serial Monitor Advance for Proteus. Open MPR121-Touch-Piano-ArduinoUnoV4.pdsprj.

Figure: The whole simulation on an A4 sheet.

The Sketch

The sketch talks to the chip with Wire and its own registers. After the soft reset and the thresholds, one write starts all twelve electrodes:

  writeReg(0x5E, 0x8C);                        // ECR: baseline from the first samples (CL = 10), electrodes E0 - E11 running

In the loop it waits for IRQ, reads the two status registers and plays the lowest touched key:

  if (digitalRead(IRQ_PIN) == HIGH) return;    // IRQ low: the touch status has changed
  const uint16_t now = readStatus();

MPR121 Simulation Results

Open the project and press Run. The demo runs 5.6 simulated seconds and took about two minutes on our PC with the pop-up open and the pictures being taken. Click the board for its pop-up. Every number below comes from one simulation run, the demo exactly as it ships.

Start-Up

The board powers up at 0x5A, because ADD is on GND. 76 ms later the sketch soft-resets it, writes the 24 thresholds and the debounce, and starts it with ECR = 0x8C: all twelve electrodes running, the baselines initialised from the first samples, a sample every 16 ms - the event log shows each step. Twenty-seven writes in all, and the board sits in run mode with every electrode at its baseline, about 700 counts.

The First Touch

At 1.0 s the demo puts a finger on E0. Its filtered data drops - by 1.2 s it reads 641 against a baseline of 700, a delta of 59 - and at the first sample after the delta passes the touch threshold of 12, at 1.013 s, the MPR121 sets bit 0 of its touch status and pulls IRQ low. The Arduino sees IRQ low, reads 0x00 and 0x01 - which releases IRQ - and prints "E0 touched: C4"; the speaker plays 262 Hz. When the finger lifts at 1.4 s the delta decays, and at 1.477 s it falls under the release threshold of 6: E0 is released, IRQ goes low again, and the note stops.

Figure: E0 touched.
Figure: The board with touched pads.
Figure: The simulation in the workspace.

Along the Keyboard

The demo walks along the keyboard: E2 at 1.6 s, E4 at 2.2 s, E5 at 2.8 s, E7 at 3.4 s and E11 at 4.0 s, each for about half a second, each touched about 13 ms after the finger arrives and released about 70 ms after it leaves. The pop-up's touch history fills with green bars, one row per electrode, and the speaker plays D4, E4, F4, G4 and B4. Every change brings one IRQ and one read of the status - the Arduino never polls the bus in between.

Figure: E7 touched.

Two Keys at Once

At 4.6 s two fingers land at once, on E1 and E9. The touch status reads 0x202 - bits 1 and 9 - both electrodes show a delta of 60, and the sketch prints both touches but plays the lower note, C#4, as a one-voice instrument would. Both are released together at 5.285 s.

Figure: Two keys at once.

The Graphs, the Event Log and the Check Page

The Graphs page plots E0's filtered data and baseline, the touch status and IRQ. The Event log records the start-up and every touch and release with its delta. The Check page sums up the run: the supply at 3.30 V and the address 0x5A, run mode with ECR 0x8C, thresholds 12 / 6 and a sample every 16 ms, eight touches on E0, E1, E2, E4, E5, E7, E9 and E11, and the host's 14 reads (28 status registers), 27 writes, nothing ignored and no NACK.

Figure: The Graphs page.
Figure: The Event log.
Figure: The Check page.

The Arduino's monitor lists every touch with its note and every release - the whole demo as the touch piano heard it.

Figure: The Arduino's monitor.

Touch Keys in Real Life

On a real board the electrodes are pads of copper on a PCB, aluminium foil behind a sheet of acrylic, or conductive paint - anything a finger can come close to. Keep the wires from the board to the pads short and apart, because a wire is an electrode too. A thin cover of plastic or glass works fine; the thresholds may need to be lowered for a thick one, and raised for large pads that see a lot of noise. Let the board start with nobody touching it, so the baselines start from the untouched values.

Capacitive or Mechanical Keys?

A mechanical button needs a hole in the panel, wears out after its rated number of presses and lets dust and water in. A capacitive key sits behind a sealed surface, has nothing to wear, and can take any shape - a slider, a wheel, a drawing. The price is sensitivity to its surroundings: a wet finger, a thick glove or a metal frame nearby changes the readings. That is why the MPR121 tracks a baseline for every electrode and lets you tune the thresholds one by one, and why a simulation that shows the data and the baselines is so handy while you choose them.

Try It Yourself

  • Set TOUCH to NONE and play the piano with the pop-up's chips or by clicking the electrode pins on the sheet.
  • Wire a pushbutton from E5 to GND: pressing it counts as a finger on E5.
  • Raise the touch threshold to 70 for all electrodes: the demo's fingers (60 counts) no longer register.
  • Write a threshold while the chip runs and look at the event log's warning - then do it properly in stop mode.
  • Change the sketch to play a chord: one note per touched electrode with several tone pins.

Ideas to Extend the Demo

  • A touch keypad for a door lock, with an LCD for the code.
  • A capacitive slider: four electrodes in a row and the position from which ones are touched.
  • A touch lamp: one electrode, a long press to dim.

Your Own Sketches

The demo sketch is in the zip file, and you can change it in the Arduino IDE. New to Arduino? Start with our Arduino Tutorial for Beginners. Export the compiled binary, and set the UNO's PROGRAM property to the new file. Our guide on How to get the HEX file from Arduino shows you where the file ends up.

Things to Know Before Using a Real MPR121 Board

  • Supply: the chip runs at 3.3 V; most breakouts regulate a 5 V supply and shift the I2C levels.
  • Configuration: change registers only in stop mode (ECR = 0x00).
  • Address: ADD to GND, 3.3V, SDA or SCL for 0x5A - 0x5D: four boards on one bus.
  • Wiring: short, separated electrode wires; ground nearby helps stability.
  • Start-up: do not touch the pads while the baselines initialise.

Troubleshooting

  • No touches: ECR is still 0x00, or the thresholds are 0.
  • Settings ignored: they were written in run mode - the event log says so.
  • IRQ stays low: the sketch never reads 0x00 / 0x01.
  • No answer on the bus: the wrong address (ADD) or no supply on 3.3V.
  • The part is not simulated: TEPMPR121.DLL is missing from MODELS and from the project folder.

Limitations of the Simulation

  • The register map, the touch logic, the baselines and IRQ follow the MPR121 datasheet; the board is our own drawing.
  • Our own figures: about 700 counts for an untouched electrode, a finger as 60 counts over 30 ms, one count of noise.
  • Not modelled: the charge current and time settings' effect on the counts, the auto-configuration, the proximity electrode, the GPIO / LED function.
  • Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or the chip's maker.
  • Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.

So, that was all about the MPR121 Touch Sensor Library for Proteus Simulation. I hope it helps you get the thresholds, the baselines and the interrupt right before the first copper pad goes behind a real cover. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!