Need Help Writing A Program That Can Calibrate MQ-8 Sensor With Arduino

Hello Arduino Community

I am having a lot of difficulty getting a program to correctly calibrate my MQ-8 (H2) sensors. I have read a lot of related articles on several forums and online, but there is not clear explanation in their code or in their procedure for how to modify their values and apply it to my sensor. A lot of information out there focuses on the MQ-137 sensor which detects several gasses including CO2. A very prominent name in this area is Davide Girgoni whose files I have downloaded, but doesn’t seem to be directly applicable to my sensor.

Basically, I understand that I need to look at the sensor Sensitivity Characteristics curve, and approximate the values in order to recreate a copy of the data that I can preform calculations with. I am using excel for this. I am then preforming a power regression? to get an equation that can serve as a scaling factor?

I have been trying to use sandbox electronics “demo” code: MQ-8 Hydrogen/H2 Sensor Module | Sandbox Electronics

but it doesn’t seem to work for me. Also, It is very unclear to me where they are getting their values for their points, under the " global " section. Additionally, as opposed to the previous method I described that uses an equation, this method seems to only use two points, which seems to me like a less accurate method of calibration.

I would really appreciate any help to get this to work. I have attached a link for my spreadsheet and codes that I have been working on.

[/b] Spreadsheet:[/b]

**You may have to download it and open it in Excel, since Google Sheets doesn’t preform regressions I believe

Note:[/b] in the 2 sensor calibration code, I have not modified the original points under the aforementioned section of the sandboxelelectronics code, because I am not sure where these values are coming from.

Additionally, the sketch.ino just spits out a “raw” value, without calibration.

I would appreciate your prompt responses :slight_smile:

MQ-8 Ver1.3 - Manual (1).pdf (451 KB)

sketch_jun08a.ino (619 Bytes)

_2_Senor.ino (7.58 KB)

What hydrogen gas concentrations are you using for calibration? Are you certain of the concentrations?

Two years ago we bought a nitrogen gas generation system specified to produce 99.999% pure nitrogen. Didn't work. Service guy suspected the calibration of the metering system. He used canisters of 99.999% nitrogen. Used up a can long before the 10 minutes needed to calibrate the system. Metering was not the problem.

That is why I ask about your calibration method.


Hi Paul,

Since I do not require super precise measurements for my project, and since average hydrogen concentration in the atmosphere is about 0.5ppm, I am taking the "0" concentration to be the air.

I have power function that correlates with the sensor's data sheet. I have a power function, and know the scaling factor (a) and the exponent (b). I am not sure how to incorporate this for this sensor

y= ax^b