Hello friends, I hope you all are doing great. Today, I am going to share the new SCD41 CO2 Sensor Library for Proteus Simulation. The SCD41 is the tiny true-CO2 sensor that has made indoor air monitors cheap and small: it measures carbon dioxide, temperature and humidity and talks to your Arduino over I2C. With this library you can run a full Proteus simulation of it, with its real command set, so that the code you test here runs unchanged on the real sensor.
SCD41 CO2 Sensor Library for Proteus
Latest version: V1.0 (November 2026, this tutorial)
Other gas and fire sensors: Gas MQ-2 · MQ-3 / MQ-7 / MQ-135 · PMS5003 · CCS811 · Flame Sensor · MH-Z19B CO2
Helping Tools
- Serial Monitor Advance: a serial terminal window for the UART of your board
- Serial Monitor Expert: the serial monitor with extra debugging tools
- LCD Library for Proteus V3.0: 16x2, 20x4 and I2C LCDs to show your readings
The module is drawn at its real size and comes alive at run time: its LEDs blink with every I2C transfer and every measurement, and the white membrane over the sensor glows when its infrared lamp pulses. The demo is a classroom CO2 traffic light - green, yellow and red LEDs and a buzzer that tells you when to open the windows.
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 CO2 sensor board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the SCD41 CO2 Sensor Library for Proteus Simulation:
What is the SCD41?
The SCD41 is a CO2 sensor about the size of a fingernail: a green 10 x 10 mm carrier with a silver can on top and a white membrane in the middle of the can. It measures the real carbon dioxide in the air, in parts per million (ppm), and on the same chip the temperature and the relative humidity. It talks over I2C, so two wires and the supply are all it needs. That combination - true CO2, small, cheap and digital - is why it sits in so many classroom monitors, office air-quality meters, smart thermostats and ventilation controllers.
Many small air sensors only estimate CO2. A metal-oxide gas sensor smells the volatile organic compounds that people breathe out and converts them into an "equivalent CO2" (eCO2) - a guess that is fooled by perfume, cleaning sprays and cooking. The SCD41 measures the CO2 molecules themselves, so its number is right even in a room full of other smells.
| SCD41 | |
|---|---|
| Measures | CO2 (ppm), temperature (C) and relative humidity (%) |
| CO2 range | 400 to 5000 ppm specified (+-(40 ppm + 5 %)), output up to 40 000 ppm |
| Principle | photoacoustic: an infrared lamp, a small cell and a microphone |
| Measurement | every 5 s (periodic), every 30 s (low power) or one single shot |
| Interface | I2C at the address 0x62, every data word with a CRC-8 |
| Supply | 2.4 to 5.5 V; the module adds a 3.3 V regulator and pull-ups |
| Size | the sensor 10.1 x 10.1 mm; our module 22 x 20 mm |
How Does a Photoacoustic Sensor Work?
CO2 absorbs infrared light of one particular wavelength, about 4.26 micrometres. Inside the SCD41 a tiny lamp sends pulses of that light into a little cell. Every pulse is absorbed by the CO2 molecules in the cell; they warm up, the gas expands for a moment, and the expansion is a sound - too faint to hear, but not for the microphone built into the cell. The more CO2, the louder the sound. That is the photoacoustic principle, and it lets the sensor be much smaller than the classic NDIR sensors, which need a long light path between a lamp and a detector.
Our simulation shows exactly that. The pop-up draws the cell with its lamp, the CO2 molecules and the microphone: when the lamp pulses, the molecules light up and sound waves run to the microphone. On the sheet, the white membrane over the module's sensor glows with every pulse.
How the SCD41 Talks: I2C Commands and CRC
The SCD41 has no registers to write. Every action is a command, a 16-bit word sent high byte first to the address 0x62. Some commands take a data word, some return one or more words, and every data word - in both directions - is followed by a CRC-8 checksum: polynomial 0x31, start value 0xFF. A sketch that checks the CRC never shows a value that was damaged on the wires. The commands you need most:
| Command | Word | What it does |
|---|---|---|
| start_periodic_measurement | 0x21B1 | a result every 5 s |
| start_low_power_periodic_measurement | 0x21AC | a result every 30 s, for batteries |
| get_data_ready_status | 0xE4B8 | one word: a new result waits when its low 11 bits are not zero |
| read_measurement | 0xEC05 | three words: CO2 in ppm, T raw, RH raw |
| stop_periodic_measurement | 0x3F86 | back to idle; takes 500 ms |
| measure_single_shot | 0x219D | one result 5 s later |
| set / get_temperature_offset | 0x241D / 0x2318 | the offset for the self-heating, 4 C at the start |
| set_sensor_altitude, ambient pressure | 0x2427, 0xE000 | the pressure compensation |
| perform_forced_recalibration | 0x362F | calibrate to a known CO2 level |
| get_serial_number | 0x3682 | three words, the chip's serial number |
The temperature and the humidity come as raw 16-bit numbers. The conversion is short: T = -45 + 175 x raw / 65535 and RH = 100 x raw / 65535. The CO2 word is already in ppm.
Features of the SCD41 CO2 Sensor Library for Proteus Simulation
- A real-looking module: the black board at its real size, 22 x 20 mm, with the green carrier, the silver can and the white membrane of the sensor, the regulator, the pull-ups and our small TEP mark.
- Animated: PWR, I2C and MEAS LEDs that work at run time, and the membrane glows when the infrared lamp pulses.
- The real command set: all the commands of the maker's own driver with their delays, the CRC-8 on every word, the periodic, low-power and single-shot modes.
- Real behaviour: the sensor does not answer while a command runs, refuses settings in periodic mode, and does not answer a read when there is no new result - exactly the mistakes a real sketch has to handle.
- Compensation and calibration: the temperature offset, the altitude and the ambient pressure, automatic self-calibration settings and forced recalibration.
- A room to measure: a classroom profile in which a class comes in and the windows open later, a clock to speed up the room, and chips for fresh air, an office, a class, a crowd, a breath and ventilation.
- A pop-up: the photoacoustic cell, the CO2 over the room's clock on the good, stuffy and poor bands, eight live tiles, graphs, an event log and a check page.
- A complete package: about 2.3 MB with the library, our LED, resistor and buzzer libraries, our Arduino UNO V4.0 and the demo, without the source code of the model.
The SCD41 in Proteus
The device is SCD41TEP in TEPSCD41.LIB, under Sensors > Gas, with the prefix U and the model TEPSCD41.DLL. Search SCD41 in Pick Devices. It has four pins along the bottom: VCC (3.3 to 5 V), GND, SCL and SDA. Its properties describe the room it sits in: PROFILE (STEADY or CLASSROOM), CO2 (the air at the start), TEMP and HUMIDITY, SPEED (the room's clock - 60 makes every simulated second a minute of the room, while the sensor still measures every 5 s) and PRESSURE (the real air pressure around it).
Download SCD41 CO2 Sensor Library for Proteus Simulation
Click the button below to download SCD41-CO2-Sensor-Library-for-Proteus-v1.0.zip (about 2.3 MB, without the source code of the models):
SCD41 CO2 Sensor Library for Proteus V1.0- README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
- Proteus Library Files:
TEPSCD41.LIB,TEPLED5MM.LIB,TEPRESISTOR.LIB,TEPPASSIVE.LIBandArduinoV4TEP.LIB. - Proteus Model Files:
TEPSCD41.DLL,TEPLED5MM.DLL,TEPRESISTOR.DLL,TEPPASSIVE.DLLandTEPARDUINO.DLL. - Arduino Code: the demo sketch.
- 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 SCD41 CO2 Sensor Library for Proteus Simulation
- Close Proteus and extract the whole zip file, for example to your Desktop.
- Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
- Copy the files from Proteus Model Files into the MODELS folder.
- Delete
TEPSCD41.IDXfrom the LIBRARY folder if it is there. - Start Proteus, press P and search for SCD41.
Proteus Simulation of a Classroom CO2 Traffic Light
In a full classroom the CO2 climbs fast: 25 people breathe out enough to pass 1000 ppm in a few minutes, and above about 1200 ppm people get tired and lose their focus. A CO2 traffic light on the wall tells the teacher when to open the windows. That is our demo. U1 is the SCD41 with PROFILE CLASSROOM and SPEED 60, so the class comes in after two simulated seconds and the windows open at 35 s. Its SCL and SDA go to A5 and A4 of our Arduino UNO Library for Proteus V4.0. D1, D2 and D3 are green, yellow and red LEDs from our 5mm LED Library for Proteus on pins 5, 6 and 7, each through 220 ohm; BZ1 is a buzzer from our Passive Buzzer Library for Proteus on pin 8. The Arduino's built-in monitor is the same window as our TEP Serial Monitor Advance for Proteus. Open SCD41-CO2-ArduinoUnoV4.pdsprj.
The Sketch
Libraries for the SCD41 exist, but our sketch talks to it with plain Wire calls, so that every byte can be seen. A command is two bytes:
Wire.beginTransmission(SCD41);
Wire.write(cmd >> 8);
Wire.write(cmd & 0xFF);
return Wire.endTransmission() == 0;
Every word the sensor sends back is two bytes and a CRC. The sketch checks each one with the sensor's own CRC-8, polynomial 0x31 and start value 0xFF:
if (crc8(d, 2) != d[2]) return false;
After the start command the sensor measures every 5 s. The sketch asks once a second whether a new result is waiting, and reads it only then - a read without a new result is not answered:
if (!readWords(&status, 1) || (status & 0x07FF) == 0) return;
The three words of the result become the CO2 in ppm, the temperature and the humidity, and the traffic light follows the CO2: green under 800 ppm, yellow up to 1200 ppm, red above, and from 1500 ppm the buzzer beeps after every result.
const float t = -45 + 175.0 * m[1] / 65535, rh = 100.0 * m[2] / 65535;
SCD41 Simulation Results
Open the project and press Run. The demo runs 52 simulated seconds - almost an hour of the classroom - and took 327 seconds on our PC with the pop-up open and the pictures being taken. Click the module for its pop-up. Every number below comes from one simulation run, the demo exactly as it ships.
The First Result
The sketch reads the serial number and the temperature offset (4.0 C), and starts the periodic measurement at 602 ms. Five seconds later the lamp fires and the first result arrives: 597 ppm, 22.2 C and 46.3 %RH. The class has just come in, but the air is still good: the green LED lights. The pop-up shows the cell with its lamp, the CO2 over the room's clock - the room in grey, the results in blue - and the tiles.
The Class Comes In
With 25 people in the room the CO2 climbs. At 10 s the sensor reports 856 ppm and the light turns yellow; at 20 s it is 1323 ppm, red, and the banner says it is time to ventilate. The temperature has risen to 22.8 C and the humidity to 50.4 %RH - people warm a room and breathe out water too.
At 30 s the result is 1614 ppm, over 1500 ppm: the red LED is lit and the buzzer beeps twice after every result. On the sheet the module's PWR LED is on, and the I2C and MEAS LEDs flash with every transfer and measurement.
The Windows Open
At room minute 35 - 35 simulated seconds - the windows open. Fresh air comes in and the CO2 falls: 1107 ppm at 40 s, yellow again, and 736 ppm at 45 s, back to green. In the pop-up's chart the blue results follow the grey room a little late, because the sensor needs about a minute of the room to follow a change.
The Graphs, the Event Log and the Check Page
The Graphs page plots the CO2 the sensor reports, the CO2 in the room, the temperature and the humidity. The Event log keeps the start, the class, the windows and a note of the results. The Check page sums up the run: 66 commands, 0 not acknowledged, no CRC errors, 10 results, the last one within the sensor's accuracy of the air at the cell.
The monitor shows what the Arduino made of it: the serial number, the offset, a line for every result and a line whenever the light changes.
Why 800 and 1200 ppm?
Outdoor air holds about 420 ppm of CO2. Indoors, everyone adds to it with every breath, so the CO2 tells how well a room is ventilated for the people in it. Under about 800 ppm the air is fresh. Between 800 and 1200 ppm it is getting stuffy, and many guidelines for schools and offices ask for ventilation here. Above 1200 ppm people feel tired and concentrate less, and the stale air also holds more of whatever the people in it breathe out. The CO2 itself is harmless at these levels; it is a measure of the air that has been breathed before.
True CO2 or Equivalent CO2?
Our MH-Z19B CO2 Sensor Library for Proteus covers the bigger NDIR sensor with a UART; the SCD41 does the same job in a tenth of the space and on I2C. Both measure real CO2. Metal-oxide sensors such as the CCS811 report an "eCO2" calculated from VOCs - fine as a hint, but a can of spray in the room sends it to the ceiling while the real CO2 does not move.
Self-Heating and the Temperature Offset
The lamp and the electronics warm the sensor a little, so the temperature it measures is higher than the air around it. The SCD41 subtracts an offset - 4 C at the start - and the humidity is corrected with it. In a closed case the self-heating is bigger: measure the real temperature beside the device and set the offset with set_temperature_offset. Our model does the same: change the offset and both the temperature and the humidity move, as they would on the real sensor.
Pressure, Altitude and Calibration
The sensor counts CO2 molecules, so its reading depends on how dense the air is. At 1000 m above the sea the air pressure is about 900 hPa, and a sensor that thinks it is at sea level reads about 11 % low. Tell it the altitude once, or feed it the ambient pressure from a pressure sensor. For calibration the SCD41 has automatic self-calibration, which assumes that it sees fresh outdoor air now and then, and forced recalibration, where you put it in air of a known CO2 level and tell it that value.
Try It Yourself
- Click Breath in the pop-up: the next result jumps by thousands of ppm, as when you breathe on a real sensor.
- Click Ventilate during the class: the CO2 falls at once.
- Set SPEED to 1: the room runs in real time - now you see how slowly a real room fills.
- Change the sketch to start_low_power_periodic_measurement (0x21AC): a result every 30 s instead of every 5 s.
- Send a setting while the periodic measurement runs and watch the Event log: it is not acknowledged.
Ideas to Extend the Demo
- Switch a fan with a relay or a MOSFET above 1200 ppm: an automatic ventilation controller.
- Show the CO2 on an LCD or an OLED as a small desk air monitor.
- Send the readings over Wi-Fi with one of our ESP32 boards and log a whole school day.
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 SCD41
- Give it a clean supply: the lamp draws short peaks of about 200 mA - a capacitor near the module helps.
- Let it breathe: keep the membrane free and give the sensor some air flow; never cover it with glue or tape.
- Idle mode for settings: stop the periodic measurement and wait 500 ms before changing a setting or calibrating.
- Set the altitude: the CO2 reading depends on the air pressure.
- Give it time: the first readings after power-on settle for a few minutes.
Troubleshooting
- Every command is not acknowledged: the sensor is busy (stop_periodic_measurement takes 500 ms) or asleep after power_down - wake it first. The pop-up's banner and Event log say which.
- A setting is ignored: settings are not acknowledged in periodic mode - stop it first.
- read_measurement is not answered: there is no new result yet - poll get_data_ready_status first.
- A CRC warning in the Event log: the CRC of a data word is wrong - polynomial 0x31, start value 0xFF, over the two bytes.
- The part is not simulated:
TEPSCD41.DLLis missing from MODELS and from the project folder.
Limitations of the Simulation
- The commands, their words, their delays and the conversions are from the maker's own SCD4x driver; the module is our own drawing of an SCD41 breakout.
- Our own choices: the room and its profile, the sensor following the air with about a minute of the room's clock, the noise, the self-heating that the 4 C offset cancels, the supply current, and the LEDs and the glow on the module.
- Not modelled: the accuracy band and the drift of a real sensor, the slow automatic self-calibration itself (its settings are stored and read back) and the lamp's current peaks.
- Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or the maker of the SCD41.
- Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.
So, that was all about the SCD41 CO2 Sensor Library for Proteus Simulation. I hope it helps you build and test your air monitor before the real sensor arrives - and shows how simple the SCD41 really is: a few commands, three words of data and a checksum. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!