MH-Z16 CO2 sensor support in mycodo

I’m following your mushroom cultivation controller guide, but somehow ended up with a MH-Z16 (with I2C/UART interface board from here) instead of the suggested MH-Z19b.

Reading the datasheet, it seems this probe comes with automatic baseline correction, which is not appropriate for use in a fruiting chamber with consistently elevated CO2 levels. And to avoid this, they say to turn the probe off at least once in every 24h period, which apparently can be done via the I2C interface?
(note I’m very new to electronics- so could easily be missing something obvious!)

My question is how (if at all) is this power cycle handled in mycodo? I don’t see anything in the MH-Z16 input configuration. Nor is there an output that jumps out at me as something I could trigger on a timer. Any suggestions appreciated!

1 Like

Hi. You would need to develop your own power circuit if you wanted to turn the sensor’s power on and off. However, the issue is you will need to expose the sensor to fresh air (~400 ppmv CO2) for ABC to operate correctly, if I’m not mistaken. The only easy solution I can see to doing this automatically is if you keep your sensor in a small sampling chamber and have two air pumps connected: one to draw in air from wherever you want to sample the CO2 from, and one that draws in atmospheric air that has a CO2 concentration ~400 ppmv. You would draw air to sample, acquire a measurement, then draw in fresh air to bring the sensor’s environment back to ~400 ppmv so the ABC can operate.

My thought was to cycle the power to it every 22h or so, and do a manual calibration check on a longer interval. I guess success here would depend on how quickly the probe begins to drift. I don’t think it needs a different power circuit (though a relay on the VCC would do the trick, it seems a little like overkill) - the datasheet says there’s a command that can be sent over I2C. Which is how I had it running, not via UART like in your guide for the Z-19B. But figuring out how to send this command is well beyond my understanding.

Anyway, for now I’ve switched to the Z-19B which sidesteps the problem!

1 Like

By “power circuit”, I don’t mean “power supply”. There are a number of circuits you can use to control power. For such a low current, a relay would not be appropriate, but you could use it if that’s all you have. Transistors and MOSFETs are more appropriate for small devices such as this.

Probably the best thing to do if you want it to work right away, then you can have time to figure out how to manipulate your MH-Z16.