Skip to content

Pi Zero W Temperature/Humidity sensor (DHT22) script and InfluxDB integration

Notifications You must be signed in to change notification settings

schambers/temp-sensors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pizero-temp

Pi Zero W Temperature/Humidity sensor script. Runs on a pi zero W (or any hardware that can leverage a temperature/humidity sensor) via DHT22 digital temperature sensor. Sends readings to InfluxDB for time series and visualization on Grafana/etc.

Sample script from playing with a Pi Zero W and a DHT22 temperature sensor

Python requirements include:

  • pip install Adafruit_DHR
  • pip install influxdb
  • pip install --no-cache-dir --no-binary pyyaml pyyaml

Create a config.yaml in the root of your project that contains the following settings:

influxdb:
    host: influxdb_host_or_ip
    port: influxdb_port
    database: influxdb_database

I'm sure there's an easier way to document python package requirements but the requirements are minimal here I assumed it'd be easier to just list the two required packages.

Sends metrics to InfluxDB, once every 60 seconds in the form of the following document:

[{
    "measurement": "temp_event",
    "tags": {
        "host": "pizero-garage"
    },
    "fields": {
        "temperature": 75.4,
        "humidity": 41
    }
}]

Create a service after installation:

  • Copy temp.service to /etc/systemd/system/pizero-temp.service

Run the following commands to enable the service and start

systemctl enable pizero-temp
systemctl daemon-reload
systemctl start pizero-temp

About

Pi Zero W Temperature/Humidity sensor (DHT22) script and InfluxDB integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published