Home Elements Boards Recipes

Logging Temperature Sensor

This recipe uses

Setup Time

The NTPTime Element configures the ESP8266 system to use a ntp server from the internet to get the current time. This time always returns the greenwich time (GMT). A configuration is required to calculate the local time that includes the name of the local timezone and the offset to GMT. If there is a “summertime” period, the start and end of that period can be configured as well.

The POSIX format for this configuration is explained here: https://developer.ibm.com/technologies/systems/articles/au-aix-posix/.

Examples for timezones can be found in https://sites.google.com/a/usapiens.com/opnode/time-zones.

See https://sites.google.com/a/usapiens.com/opnode/time-zones for examples.

{
  "ntptime": {
    "0": {
        "ntpserver": "pool.ntp.org",
        "zone": "CET-1CEST,M3.5.0,M10.5.0/3"
    }
  }
}

Setup the Sensor and Logging

The DHT Sensor is connected using 2 GPIO pins:

Using the GND connection to power up the sensor makes using the DHT sensor more robust as they sometimes stop responding when permanently powered.

The onTemperature event is sending the value over to the Logging Element.

The Logging Element requires a filesystem to persist the incoming values in a file with the name given by the filename parameter. Using the averagetime the Logging Element collects samples during the 10 min. period and writes out the average of the collected values.

{
  "dht": {
    "on": {
      "pin": "D5",
      "type": "DHT22",
      "readtime": "30s",
      "restart": "true",
      "resendtime": "2m",
      "powerpin": "D6",
      "powerinvert": "true",
      "ontemperature": "log/t?value=$v"
    }
  },
  "log": {
    "t": {
      "description": "log temperature",
      "averagetime": "00:10:00",
      "filesize": "10000",
      "filename": "/templog.txt"
    }
  }
}

Tags

Recipe