Giter Club home page Giter Club logo

raspberrry-pi-dht22's Introduction

DHT22 for Raspberry Pi 0

This repository contains a reference implementation of a DHT22 temperature sensor that reports the sensor temperature and humidity to STDOUT and an MQTT broker.

Requirements

  • Raspberry Pi (tested on Pi 0 W, should also work on Pi 2/3 and I suspect any other Pi with a network connection available).
  • DHT22 temperature sensor
  • Docker installed on Raspberry Pi with Docker-compose (docker-compose convenient, but not required)

Wiring

Pinout From https://pinout.xyz.

This is how I have my DHT22 wired. A resistor is probably required or at least strongly recommended, but mine works fine without one. If one was required, my research suggested it should be 5k-10k resistor between the data and ground pins.

  1. 3.3v (bottom left) to left hand pin on DHT22 (with intake grill facing up)
  2. GPIO4 (4th from left) to second-from-left pin on DHT22
  3. Ground (bottom right) to right hand pin on DHT22

Operation

With the DHT22 set up as above, I run this using docker-compose up -d on my raspberry pi. Here are some notes that may help with your specific setup:

  • I have my own environment variables in docker-compose.yml. You will need to provide your own.
  • I have not added support for an MQTT username/password as my broker just operates within my local network.
  • GPIO pin 4 is hardcoded - just change it in fetch.py to whatever you'd prefer.
  • The privileged: true flag in docker-compose.yml is needed so that the Adafruit DHT22 library can see and communicate with GPIO. There are other ways of accessing GPIO with Docker, but privileged mode is the easiest and the one that consistently works.

License

See LICENSE. Please note that Adafruit_DHT is bootstrapped by the Dockerfile in this project and is MIT licensed as of release. See https://github.com/adafruit/Adafruit_Python_DHT/blob/master/LICENSE for more information.

raspberrry-pi-dht22's People

Contributors

joshmcarthur avatar jakezp avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.