mstenta / atmospi

Atmospheric monitoring app for logging and graphing temperatures and humidities over time using a Raspberry Pi and DS18B20, DHT11, DHT22, and AM2302 sensor(s).
31 stars 9 forks source link

Calibration offset #18

Open mstenta opened 9 years ago

mstenta commented 9 years ago

Provide a way to specify the delta-T for each sensor compared to a calibrated sensor.

ultima-originem commented 9 years ago

I have written a temporary fix [because it's hard coded and not derived from a configuration file] by modifying measure-ds18b20.py:

        # Apply device calibration values in mK
        if device == '28-000005e4d76b':
            temp_c = temp_c - 275
        elif device == '28-000005e4f2fd':
            temp_c = temp_c - 225
        elif device == '28-000005e5f606':
            temp_c = temp_c - 175
        elif device == '28-000005e65e0c':
            temp_c = temp_c - 875
        elif device == '28-000005e77695':
            temp_c = temp_c - 187
        elif device == '28-000005fab05d':
            temp_c = temp_c + 640
        elif device == '28-000005fab2e0':
            temp_c = temp_c + 515
        elif device == '28-000005fab89c':
            temp_c = temp_c - 72
        elif device == '28-000005fb03d6':
            temp_c = temp_c + 453

        temp_c = round(temp_c / 1000.0,1)

        # Add the measurement to the temps array.
        temps[device] = {'C': temp_c}

I would have preferred to keep the calibration out of the database and do it client-side but couldn't get that to work.

mstenta commented 9 years ago

Now that #10 is done, we have a new Devices database table for storing device-specific settings. This might be a good place for the calibration offset data to go.

The tricky thing here (and likewise in #20 ) is that some devices (ie: DHT22, DHT11, and AM2302) provide TWO readings (temperature and humidity) - but only have one "device" in the Devices database... so that would make adding color and calibration config more difficult... hmm...