Project: The Purple People Counter

I just uploaded a project I that made last weekend. It uses an Arduino Bit with connecting / output circuitry to read the number of people in a room using a carbon dioxide sensor. The algorithm that does the people counting in the Arduino sketch needs to be improved.

Your comments, suggestions and critique are invited.

Here’s the project:

1 Like

I’ve added the sketch to the project. For some reason the project page is not letting me attach a sketch, but DID attach it as an ‘additional file’.

I have rebuilt the ‘people counter’ from the ground up, with an eye toward submitting a design and prototype to the bitlab. I have a 0-5000ppm sensor from CK Sensors (an obscure company in Kentucky) but I still have my eye on the industry standard CO2 sensor that uses infrared absorption technology, the K30.

The device consists of several modules:

  1. The sensor and associated control board. The board is more complex than it needs to be since I ripped this out of another instrument. It works however, so I’ll keep it intact until I get a replacement. I soldered jumper wires to the +5volt, GND and the signal line that varies between zero and 4 volts.

  2. Analog signal amplification. When a person enters a room, the CO2 concentration increases by 30 to 200ppm depending on the size of the room and the ventilation. In order to have sufficient precision and the ability to scale the sensitivity of the counter, the signal is amplified. The unamplified signal with fresh air (about 400ppm CO2) is about 400 mV. In a large room, with a single person the output of the sensor module is around 425mV. A small room with 5 people will have an output of 1.2volts. Clearly the device must have a sensitivity setting. I want to do this early and with hardware, so the processing code will be more clear. So I put a NTE928 op-amp with a potentiometer to adjust the gain. The gain is adjustable up to 3X.

    NOTE: There should also be a LV(M)321 op-amd buffering the signal line. I have not been able to obtain this chip yet, so I just left it out. It would be present, along with other protective components, in a real bit design.

  3. Digital signal processing and data interpretation. The Bit will have two modes: percent CO2 (ppm/10000), and People Count: the number of people in the air space. I would also like to have a trigger output when a person enters the room. Currently only the %CO2 part runs reliably, but if I play with the sensitivity setting and software parameters, I can count up to 5 people in my 120 sf office. This software development is another area I will concentrate on.

Here is a picture of the three modules, powered by a p3 USB Power bit, and being read with a Number bit. Parts of the schematic I wrote while proctoring the last regular organic chemistry exam a couple days ago, is shown in the backdrop:

Here is the amplifier section:

And here is the business end of the sensor:

Thanks to everyone here who has helped me learn the electronics used in this project, including anyone I have forgotten to name below:

cc: @JackANDJude, @StuckInSynth, @Philip_Verbeek, @alexpikkert, @br1wr2el3, @henrique007, @codewizard58, @matthiasmwolf, @syedBits


@chris101 This sounds like an interesting project. Maybe it could be used for attendance. I will be interested to follow this.

Thanks Bruce - I’d love to hear about academic use ideas. One thought I had was to monitor the people in my tutoring room. It could signal for help during high volume times, maybe through a text via cloudbit attached to the counter? This use is what made me think of having a trigger output. It would send a momentary HIGH when a person entered the room. Not sure how to handle leaving the room though.

Hi @chris101,
I am following the progress on your purple people counter with high interest. I think you really are working on a ingenious project !
I really want to understand the steps you are making and the following question boggles my mind:
You are measuring the amount of CO2 in the room, but to measure the number of people there are a few more parameters as I can see, such as volume of the room in cubic feet, and the amount of ventilation and maybe the amount of CO2 per person ( is it depenfing on a persons weight or lung volume or breazing in-out per minute ??) It is a little unclear to me… These parameters must be set somwhere I think, are you going to include them in the software ?
Great project, I really hope it will result in a new bit…

@chris101, great to see you connecting the Bits with other electronic components. I am underwater now, but I will look carefully to your project. Congrats!

1 Like

The LMV321 by TI is available at and you can buy them singly for 32 cents or so. also has them. LMV324 is the quad version and is still less than $1 each.

1 Like

Thanks Henrique @henrique007,

LittleBits works for me in two ways; 1) it’s really easy to put together all the support circuity for a prototype. You don’t need to design an entire system, just isolate the function you want, then use littleBits for the support circuitry and software. 2) is more philosophical. The limits of the three wire analog system provide a framework that is easy and intuitive for me. Bumping up against those limitations provides a shot of creativity and learning.

Thanks Peter! (@codewizard58) I will go to then.


Hi @chris101.
Agree with you! Besides that I am testing littleBits with kids and non-technical professionals. I believe it is 1) a great tool to develop young makers and inspire them to develop their STEAM skills, and 2) a great tool to inspire non-technical professionals to embed electronics in their jobs. I had a nice experience showing littleBits to my brother, who is an architect, and he just had some thoughts on how to use it to improve his projects (I did the same with Arduino few months ago, but he didn’t was not so excited as he was with littleBits).
I am working to have a chapter of littleBits in SP to scale my experiences and to have more people experiencing with littleBits.


@chris101 Most of our classrooms have two doors, so it would be easy to use one for entry and one for exit.

1 Like

Hello again - I’m back to thinking about the Purple People Counter.

This week I took my CK Sensors CO2 sensor up to a 300 square foot study room, and attached it to a datalogger. The room can accommodate 10 to 12 people but is usually not full. It’s an ideal room to test the sensor. Below is the data, and my analysis:

As you can see, the data quantizes well, but is also affected by local conditions. The room has three doors, and is air conditioned by a computerized central system that affect the CO2 level. I believe however, that I will be able to write software that will be able to do three things:

1. give an approximate count of the people present
2. send a trigger when a person enters or leaves the room
3. report the percent CO2 in the air

to be continued …


Hi @chris101

How are things going with this project? kinda curious:)

1 Like

Hi @Philip_Verbeek!

I’ve got a CO2 sensor sitting on my workbench, and I look at it every day, thinking about this project. My second sensor is installed in a tutoring room that will hold 1 to a dozen students in a couple weeks (we are still mid-semester.) While I am pleased by the results of my last experiment, there are still environmental factors (eg. vents, doors being opened and closed, etc.) that make coming up with a number that corresponds to how many people there are, difficult.

Lately I have been idling this project in favor of clocks, and gps devices (Which I will post about … soon!) Knowing of your (and others?) interest, I will run my prototype some more (once school resumes,) and think about how the software needs to interpret the data. I will also need to work out how to intra-connect a dual opamp to amplify the small signal from the sensor without using the Vernier device. The single amplifier I’m currently using may be responsible for some of the signal’s randomness.

Thanks for the nudge!

1 Like