I have a MICS6814 3-in-1 Gas Sensor Breakout connected to a Raspberry Pi 4B. I am using the Python library to read the sensors continuously:
import sqlite3
import time
from mics6814 import MICS6814
gas_sensor = MICS6814()
while True:
epoch = time.time_ns() // 1e9
oxidising, reducing, ammonia, adc = gas_sensor.read_all()
con = sqlite3.connect("~/Documents/air-quality.db")
cur = con.cursor()
cur.execute(f"""
INSERT INTO sensor_readings (Oxidising, Reducing, Ammonia, ADC, Epoch)
VALUES ({oxidising}, {reducing}, {ammonia}, {adc}, {epoch})""")
con.commit()
time.sleep(1)
The read_all()
function takes a few seconds to run, so this loop ends up reading about every 5 seconds.
My problem is that I am seeing plenty of spikes in the data.
Am I doing something wrong?