Skip to content

feat: add temperatureOffset, humidityOffset and percentage-based offset config options#38

Open
Aldarande wants to merge 1 commit into
ryck:masterfrom
Aldarande:feat/temperature-humidity-offset
Open

feat: add temperatureOffset, humidityOffset and percentage-based offset config options#38
Aldarande wants to merge 1 commit into
ryck:masterfrom
Aldarande:feat/temperature-humidity-offset

Conversation

@Aldarande
Copy link
Copy Markdown

Problem

DHT sensors placed inside a MagicMirror enclosure are often affected
by the heat generated by the display and electronics, resulting in
inaccurate temperature and humidity readings.

Solution

Add four optional config parameters to compensate for sensor drift:

  • temperatureOffset (default: 0): fixed value added to the raw temperature reading
  • temperatureOffsetPercent (default: 0): percentage applied to the raw temperature reading
  • humidityOffset (default: 0): fixed value added to the raw humidity reading
  • humidityOffsetPercent (default: 0): percentage applied to the raw humidity reading

Both fixed and percentage offsets can be combined:
final value = raw * (1 + offsetPercent / 100) + offset

Usage

{
    module: "MMM-DHT-Sensor",
    config: {
        sensorPin: 2,
        sensorType: 22,
        temperatureOffset: -3,       // fixed offset: -3°C
        temperatureOffsetPercent: 0, // percentage offset
        humidityOffset: 0,
        humidityOffsetPercent: -5,   // sensor reads 5% too high
    }
}

Changes

  • MMM-DHT-Sensor.js: added four offset options to defaults and applied
    them in processSensorData()

…ptions

Add percentage-based offset options to complement the existing fixed offsets.

- `temperatureOffsetPercent` (default: `0`): percentage applied to raw temperature
- `humidityOffsetPercent` (default: `0`): percentage applied to raw humidity

Both fixed and percentage offsets can be combined:
final value = raw * (1 + offsetPercent / 100) + offset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant