Make DHT11 available on Raspberry Pi + python (memo)

DHT11 Introduced inexpensive thermo-hygrometer [DHT11](https://www.amazon.co.jp/s/ref=nb_sb_noss?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB% Introduced python library to use E3% 83% 8A & url = search-alias% 3Daps & field-keywords = DHT11 & rh = i% 3Aaps% 2Ck% 3ADHT11) quickly. Just download).

git clone https://github.com/szazo/DHT11_Python

The dht11_example.py published above is the start program.

dht11_example.py


import RPi.GPIO as GPIO
import dht11
import time
import datetime

# initialize GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.cleanup()

# read data using pin 14
instance = dht11.DHT11(pin=14)

while True:
    result = instance.read()
    if result.is_valid():
        print("Last valid input: " + str(datetime.datetime.now()))
        print("Temperature: %d C" % result.temperature)
        print("Humidity: %d %%" % result.humidity)

time.sleep(1)

Recommended Posts

Make DHT11 available on Raspberry Pi + python (memo)
Raspberry Pi + Python + OpenGL memo
[Python] Make pip available on macOS
Detect "brightness" using python on Raspberry Pi 3!
Adafruit Python BluefruitLE works on Raspberry Pi.
Run servomotor on Raspberry Pi 3 using python
Detect temperature using python on Raspberry Pi 3!
Working with GPS on Raspberry Pi 3 Python
Detect slide switches using python on Raspberry Pi 3!
Detect magnet switches using python on Raspberry Pi 3!
Use Grove-Temperature & Humidity Sensor (DHT11) on Raspberry Pi
Sound the buzzer using python on Raspberry Pi 3!
Raspberry Pi 4 setup memo
Cython on Raspberry Pi
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Try debugging Python on Raspberry Pi with Visual Studio.
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Install pyenv on Raspberry Pi and version control Python
Output to "7-segment LED" using python on Raspberry Pi 3!
Make MeCab available from Python3
Make iPython available on OSGeo4W
Made python available on macOS
Make Cython available on Windows.
Make Opencv available in Python
raspberry pi 1 model b, python
Introduced pyenv on Raspberry Pi
Use NeoPixel on Raspberry Pi
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
VScode intellisense doesn't work on Raspberry Pi OS 64bit! (Python)
Run AWS IoT Device SDK for Python on Raspberry Pi
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
Access google spreadsheet using python on raspberry pi (for myself)
Python environment construction memo on Windows 10
Use vl53l0x with Raspberry Pi (python)
MQTT on Raspberry Pi and Mac
raspberry pi 4 centos7 install on docker
Python environment construction memo on Mac
Try using ArUco on Raspberry Pi
OpenCV installation procedure on Raspberry Pi
[Lambda] Make import requests available [python]
Power on / off Raspberry pi on Arduino
Detect switch status on Raspberry Pi 3
Install OpenMedia Vault 5 on Raspberry Pi 4
L Chika on Raspberry Pi C #
[Memo] Tweet on twitter with python
[Raspberry Pi] Changed Python default to Python3
Build wxPython on Ubuntu 20.04 on raspberry pi 4
Control the motor with a motor driver using python on Raspberry Pi 3!
Resolved an error when putting pygame in python3 on raspberry pi
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
How to play music (wav / mp3) files on Raspberry Pi python
Use BME280 temperature / humidity / barometric pressure sensor from Python on Raspberry Pi 2
"Honwaka Notification Lamp" on Raspberry Pi Part 2
Detect analog signals with A / D converter using python on Raspberry Pi 3!
USB boot on Raspberry Pi 4 Model B
python memo
Raspberry Pi Security Infrared Camera (Python Edition)
"Honwaka Notification Lamp" on Raspberry Pi Part 1
Enable UART + serial communication on Raspberry Pi