Skip to content

Pure Python library for reading DHT sensor (DHT11, DHT22, AM2302) on Pycom

License

Notifications You must be signed in to change notification settings

JurassicPork/DHT_PyCom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DHT Pure Python library for Pycom board

This simple class can be used for reading temperature and humidity values from DHT11 and DTH22 sensors on Pycom Board. Thanks to szazo for the original source code.

Usage

  1. Instantiate the DHT class with the pin number and type of sensor (0=DTH11, 1=DTH22) as constructor parameters.
  2. Call read() method, which will return DHTResult object with actual values and error code.

For example:

import pycom
import time
from machine import Pin
from dth import DTH

pycom.heartbeat(False)
pycom.rgbled(0x000008) # blue
th = DTH(Pin('P3', mode=Pin.OPEN_DRAIN),0)
time.sleep(2)
result = th.read()
if result.is_valid():
    pycom.rgbled(0x001000) # green
    print("Temperature: %d C" % result.temperature)
    print("Humidity: %d %%" % result.humidity)

For working example, see `dht11_example.py` (you probably need to adjust pin for your configuration)


# License

This project is licensed under the terms of the MIT license.

About

Pure Python library for reading DHT sensor (DHT11, DHT22, AM2302) on Pycom

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%