"The first and only Arduino library where MQ Sensors combine with Data Science"
if r_squared >= 0.9995:
print("R-squared value for {gas name} is above 0.9995, plotting against first and last values.")
x0, y0 = x[0], y[0]
xn, yn = x[-1], y[-1]
b = np.log10(yn/y0) / np.log10(xn/x0)
a = 10**(np.log10(yn) - b * np.log10(xn))
b2 = np.log10(yn) - b * np.log10(xn)
b2_rounded = round(b2, 4)
a_rounded = round(a, 4)
b_rounded = round(b, 4)
The first formula is determined according to all points (Curves.py, OldCurve), while the second formula is determined according to the first and last point. Therefore, in order to collect them all in the same formula and to increase the accuracy rate, we used the method in the second formula and took the logarithm (if R² = 1 (100%) always: logm = valueb, logb = log₁₀(valuea)) for curves greater than 99.95% and collected them all in the first formula, thus we increased the accuracy rate without having to use 2 different formulas (Curves.py, NewCurve).
Therefore, we need to make a transition according to the formula:
In data graphs, the x-axis is given as ppm and the y-axis is given as ratio.
For the MQ-2 sensor, calibration at 1000 ppm LPG is recommended as an example. This value is the point where Rs/Ro is approximately 0.78. There is a logarithmic relationship, rather than a linear one, between the sensor and the ppm. The mathematical relationship of this connection is exactly as follows:
The sensor is limited by a lower bound of 1% and an upper bound of 99%, which is considered the saturation point. The lower the percentage of the gas used for calibration, the more sensitive the sensor is to that specific gas compared to others it measures.
STATUS 1: MQ-2, MQ-3, MQ-4, MQ-5, MQ-6, MQ-7, MQ-8, MQ-9, MQ-135, MQ-136, MQ-137 [Almost All & Standart]
STATUS 2: MQ303A, MQ303B, MQ307A, MQ309A [A Models & B Models]
STATUS 3: MQ-131_LOW, MQ131 [MQ131 Models]
def CorrectionCoefficient(RH, temp):
valuea = interpolate(RH, 33, 85, a_RH33, a_RH85)
valueb = interpolate(RH, 33, 85, b_RH33, b_RH85)
valuec = interpolate(RH, 33, 85, c_RH33, c_RH85)
return valuea + valuec * np.exp(valueb * temp)
From classical regression methods, multivariable regression models, curve fitting and spline-based approaches, time series analysis, state-space and Kalman filtering methods, to machine learning algorithms, ensemble learning methods, and artificial neural network models, a total of 76 different algorithms are applied to the same dataset. Each model is evaluated using Cross-Validation, its R² (Coefficient of Determination) is calculated, and the model achieving the highest R² score is automatically selected.
"The first and only Arduino library series where Gas Sensors and Geiger Counter combine with Data Science"
| Library | Scope |
|---|---|
| MQDataScience | MQ2, MQ3, MQ4, MQ5, MQ6, MQ7, MQ8, MQ9, MQ131_LOW, MQ131_HIGH, MQ135, MQ136, MQ137, MQ138, MQ214, MQ216, MQ303A, MQ303B, MQ306A, MQ307A, MQ309A Gas Sensors |
| TGSDataScience | TGS813, TGS822, TGS826, TGS2201, TGS2442, TGS2600, TGS2602, TGS2610, TGS2611, TGS2612, TGS2620, TGS6812, TGS8100 Gas Sensors |
| MG811DataScience | MG811 Gas Sensor |
| SP3S-AQ2DataScience | SP3S-AQ2-01 Gas Sensor |
| RadioactiveDataScience | Geiger Counter |










