Public Lab Research note

Air Quality Indoors and in Tent at LEAFFEST 2014

by cversek | September 18, 2014 05:33 18 Sep 05:33 | #11151 | #11151

AKA "The Rough-looking Muffle Tent Poll"

What I want to do

I wanted to measure temperature, relative humidity, and carbon dioxide concentration in my tent during the LEAFFEST 2014 gathering using the Riffle-ito data logger board from the Public Lab Open Water Project. We are half-seriously calling this a prototype for the MUFFLE (Mushroom Urban Farming Factors Logger Electronics) project, a spoof on the name RIFFLE (Remote Independent Friendly Field Logger Electronics). Why? See below...

My attempt and results


Here are the parts that I cobbled together, from the left: an Enercell 9V alkaline battery; one of the early riffle-ito (Arduino compatible) prototypes which has an ATmega328P MCU, DS3231 real-time clock, and microSD card slot; a hand-crafted sensor pin breakout board with screw terminals; a Riffle project add-on sensor board with a surface-mounted SHT21 humidity and temperature sensor which communicates via I2C; a SainSmart MH-Z14 NDIR carbon dioxide sensor module which speaks serial UART among other protocols and gives calibrated values in ppm; and a 4x4 in. Carlon marine conduit box. Most of the wiring and soldering was completed in my home lab in Providence before the trip up to Salisbury, VT, but I had to fix some flaky connections on the breadboard at the last moment. On the other hand, the majority of the Arduino firmware was hacked together that Saturday night in the chilly garage while others were merry making music by the fireplace with some traditional instruments and the Coqui conductivity probe by poking at some fruits, vegetables, and fungi. Much thanks goes to Don Blair for pioneering the accessible riffle-ito platform and to Rui Wang who patiently helped me debug a problem that we had with using the Arduino SoftwareSerial library - all while dealing with my failing laptop onto which I had previously spilled my beer. I'd love for this note to be truly open source, but unfortunately my dying laptop may have swallowed the exact version of the firmware we used - which was badly in need of a redo anyway ;)


After the prototype was assembled and running, I paraded it from the drafty garage into the fireplace-warmed living room, and back to the garage (I forgot my flash light), and then back into the living room, and then outside into my tent. You can see the effects of my wandering between climatic zones within the first 15 minutes of the data record below. The 9V battery actually lasted for 2 hours, but I am showing a cleaned-up version of the first hour of the record.



If you are interested, the raw data and Python plotting code can be found in this repository location.

Questions and next steps

During the wandering between rooms, the sensors show an interesting dynamic response: RH seems to change quickly and discontinuously at inflections of the temperature, carbon dioxide readings lag behind temperature and RH changes. As might be expected, the carbon dioxide levels spike some time after entering the room with the fireplace. We should devise some experiments to more carefully measure sensor dynamics in these rapidly changing environmental conditions. Perhaps with some more careful documentation procedures and an LCD readout for user feedback, a similar portable logger system can be used to sniff out indoor air quality issues.

During the period when I am sleeping peacefully in my tent (after ~25 mins), the RH and CO2 readings seem to fluctuate in a correlated way. Could this be caused by breathing patterns? Might this be a interesting way to monitor sleeping behavior and metabolism?

The Riffle was designed to be a low power remote data logger which fits inside a plastic water bottle. How should we optimize the Muffle for cost and function in an indoor farming context where we probably have access to mains power and maybe even a wireless network?

Why I'm interested

Eventually, I want to make robust data logging and web-connected open source sensor devices that are targeted to growroom environments, especially urban mushroom farms - like the startup Mycopolitan Mushroom Company that my brother is co-founding. The parameters of interest are similar to indoor air quality monitoring, but the high humidity and spore-laden environment of mushroom farms is particularly challenging for long-term sensor installations. Temperature, relative humidity, carbon dioxide, oxygen and particulate concentration (increasing during fungal sporulation) are possibly the most interesting factors to investigate in these semi-controlled environments.


This is fantastic!

  • I love the idea of using CO2 and/or RH as a metric for sleep quality / breathing patterns. I suppose you're getting a much stronger signal in your tent than you would in an open room? But seems worth a shot!

  • Interesting to see the apparent correlations in temp, CO2, and RH, and what that might say about e.g. Craig health / mushroom health / the nature of the enclosure. I wonder if the cross-correlation time of each of these variables against the other could be used as a metric for e.g. how much air is circulating around the sensor, or how 'closed' a 'grow box system' is ...

  • Could we use the CO2 sensor, in a closed container, plus infragram, as a way of correlating plant respiration w/ photosynthetic activity?

  • How much are the parts in all of this, again? It's looking like it'd make for a neat little kit!

  • Can't wait to see this applied to mushrooms!

Is this a question? Click here to post it to the Questions page.

Reply to this comment...

I'm trying to imagine how to calibrate the CO2 sensor-- Do you think we could fill up a series standard-sized balloons of some sort with a known air mixture? Could we do it with SodaStream cans?

I volunteer to make airtight plastic balloons of a known size for the purpose.

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


  • Yes, it wouldn't be so bad to set up a tent in one's domicile for the purpose of science.
  • It seems like a lot of correlations can be made in order to build a model for the sensor response and vice versa; this would be an interesting subject for a Public Lab sub-community to investigate using open data methods.
  • Putting the sensor in a terrarium would be an interesting test case, but I'm not sure how much an infragram image would vary over a fews hours or even days.
  • The CO2 sensor is the big-ticket item at $80 (see link in post for source); the Riffle is how ever much you are charging for this app (I got mine for free!); the SHT21 is a few bucks, the optional box is $10, maybe another $10 for cables and weather proof bushings (not on this prototype yet). I don't think a kit would fair well - I'm just about providing the resources for interested hobbyists to do-it-themselves. Maybe custom assembled units could be made for researchers with deeper pockets, a warm feeling about open source, and a tollerance for early stage prototypes.
  • Maybe the next test should be done in an enclosed mushroom.


This particular optical sensor is supposed to be factory calibrated, but there is no harm in checking the numbers! One of the reasons that I did not go with a cheaper MG811 MOX electrochemical gas sensor module, was that it provided only an analog output and was difficult for me to try to calibrate. While testing the MG811, I sealed it in a container with a known amount of sodium bicarbonate (baking soda) solution and injected an excess of ascorbic acid (could also use vinegar) to cause it to give off CO2. The problem that I had was that the sensor voltage was not only directly correlated to CO2 but also to water vapor to a high enough degree that the results did not make much sense. The SodaStream sounds like it might work better than what I tried. However, this inherent water vapor sensitivity would be even more of an issue in a growroom. Furthermore, the MOX sensor needs to be held at a high enough temperature to function at all so it drew over 1 watt of power, whereas the optical sensor took more like 0.1 watt. At the end of the day, Occam's razor prevailed over Uncle Pennybags' monocle.

Is this a question? Click here to post it to the Questions page.

Reply to this comment...

Please explain what is meant by: "During the period when I am sleeping peacefully in my tent (after ~25 mins), the RH and CO2 readings seem to fluctuate in a correlated way. " I did a correlation for RH and CO2 from 2:30 to 3 and got a value of 0.05. This doesn't indicate any correlation. I must be misunderstanding?

Is this a question? Click here to post it to the Questions page.

Reply to this comment...


Well, I hadn't done any correlation analysis yet, but I tend not to trust algorithms that yield a single number value judgement. To better qualitatively show what patterns that I think I see, I have plotted the part of the data record from around 25 mins up to 60 mins since the start of the experiment (segment 1). (Note that the datetime stamps in the raw data are likely not absolutely correct since we had forgotten to synchronize the RTC.) The data sets have been rescaled by subtracting their means and dividing by the standard deviation.


The remainder of the data (segment 2) - which was not plotted in the original post - understandably looks to be not as correlated. I don't know what happened here, but I will say that I've been tossing and turning a bit more now that I've taken to sleeping on my side within the last year.


The code for these plots can be found at this link.

Reply to this comment...

Thanks for making the effort to explain and for doing the experiment. Yes, there is an interval of high correlation.

Reply to this comment...

Hey, I also got myself the SainSmart MH-Z14 and I must say, I am not sure if I really trust the values. Mine (using Arduino and the UART interface) reads around 700ppm indoors, rising steadily to over 1000ppm when put outdoors. These values look suspicious to me - they're twice as high as I'd have expected, and I don't really believe that outdoor CO2 levels (on my window sill on a winter day) are higher than indoors. What's more, I get a rather suspiciously good (negative) correlation between the temperature and the CO2 concentration (r-square = 0.95). Do you have any more insights into how reliable these measurements actually are? Yes, my sensor does spike when I breathe at it, so it seems to react to CO2 changes, but beyond that I haven't seen evidence that this sensor actually does what the datasheet promises.

Judging by the few websites and Youtube movies that exist about this sensor, it seems that most people get measurements around 1000, and nobody seems to question that, even though, according to [1] "NIOSH considers that indoor air concentrations of carbon dioxide that exceed 1,000 ppm are a marker suggesting inadequate ventilation." So, perhaps this sensor isn't actually working, or at least not with anywhere near the accuracy promised by the datasheet?


Is this a question? Click here to post it to the Questions page.

Reply to this comment...

@tobi_k Hi, I am glad that there are others testing out these sensors with a skeptical attitude. Very often, the abosulute baseline readings from many cheap sensors should not be trusted. Expensive instruments have all sorts of compensating analog signal conditioning circuitry and calibration trimmers that have to be tuned in a lab - thus driving costs up. Discount sensor companies cut all sorts of corners in design and manufacturing and often lie about the real world performance. I prefer to look at relative values and time change since they are usually more trustworthy. Also, simultaneous recording temperature and humidty can give you extra clues to understand the response of the CO2 sensor. And, believe me, the situation with the MOX CO2 sensors is much worse - since the sensor itself is the major source of error.

The SainSmart board is a drop-in module for many types of control systems and is unecessarily complicated, containing its own MCU. I do think that the underlying NDIR unit (metallic module) is sound, but it needs a better interface. I am making plans to see if the particular optical sensor can be obtained cheaply and designed into an open source module which is easier to calibrate and integrate into extensible sensor platforms. Again, it is important to lower one's expectations for the veracity of DIY sensor systems and to put things to the test!

Reply to this comment...

Login to comment.