Name | dht11-spi JSON |
Version |
1.0.5
JSON |
| download |
home_page | |
Summary | Python module to use the SPI bus to read DHT11/DHT22 sensors. |
upload_time | 2023-08-15 18:19:37 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.6 |
license | |
keywords |
dht11
dht22
spi
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# DHT11 / DHT22 over SPI
Homepage: https://www.learningtopi.com/python-modules-applications/dht11_spi/
DHT11/DHT22 python3 driver that uses the SPI to receive binary data from the
temp/humidity sensor. This driver uses a GPIO pin attached to a NPN transistor
to send the low signal required to start the communication.
General GPIO Pin (NOT an SPI CS) used to pull the signal pin low. The DHT11/DHT22
will then send its binary data by pulling the data pin low. SPI bus reads the
high and low data and determins the bits based on the time the sensor holds the
voltage high. Data is converted to temperature and humidity.
NOTE: Requires SPI bus to run at a minimum of 125kHz to properly read the data.
Only SPI0 on RPI4 functions properly. SPI1+ is not able to read data.
Parts:
- DHT11 / DHT22 (DHT11: https://amzn.to/3DCEH0W, DHT22: https://amzn.to/3Y2BTm5)
- NPN 2N5551 transistor (https://amzn.to/3YiM59Y)
- 1x 470ohm resistor (https://amzn.to/3HvG6I6)
- 1x 1k ohm resistor\___use for 5v to 3.3v level shift if board is 3.3v
- 1x 2k ohm resistor/ or use a level shifter (https://amzn.to/3X0jdSL)
- Linux SBC
Cabling:
-------------------------------------------
| |
| 5v |
| + |
.-. | |
2k| | |
| | | |
'-' ___ | |
|-----|1k_|---- | |
| | | |
| | o########## |
| | ########## |
SPI MISO o |-----------o#DHT11/22# |
___ |/ ########## |
GPIO o----|470|--| |----o########## |
|> | |
o 2N5551 | | |
| | |
GND o-----------------------------------------|
(created by AACircuit.py © 2020 JvO)
## Usage:
# Import DHT SPI class
from dht11_spi import DHT11_Spi, DHT22_Spi
# initialize device, use (DHT11_Spi or DHT22_Spi)
# cs_chip and cs_pin from "gpioinfo". gpiod used for platform compatibility.
dht = DHT22_Spi(spiBus=0, cs_chip=0, cs_pin=26)
reading = dht22.read() # returns instance of DhtReadings
print(reading)
# --or--
print(reading.temp_c, reading.temp_f, reading.humidity)
## Testing
Included in the module is a basic test script that can be executed with the following:
python3 -m dht11_spi [gpio]
Additional test options are available for interval, run time, dht22. Documentation is available using the "--help" option.
### Example Output
DHT11: 105/105 (100.0%): Temps (min/avg/max): 73.54/75.2/75.34 deg FHumidity (min/avg/max): 17.0/17.0/17.0 %
DHT22: 112/112 (100.0%): Temps (min/avg/max): 74.48/74.51/74.66 deg FHumidity (min/avg/max): 14.1/14.21/16.0 %
Raw data
{
"_id": null,
"home_page": "",
"name": "dht11-spi",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "dht11,dht22,spi",
"author": "",
"author_email": "Thomas Dunteman <git@learningtopi.com>",
"download_url": "https://files.pythonhosted.org/packages/c0/ef/7893cb51c5e406548a4adce2b617d9b0457b6f0bcf2e661a5b938ac84fcf/dht11_spi-1.0.5.tar.gz",
"platform": null,
"description": "# DHT11 / DHT22 over SPI\n\nHomepage: https://www.learningtopi.com/python-modules-applications/dht11_spi/\n\n\nDHT11/DHT22 python3 driver that uses the SPI to receive binary data from the\ntemp/humidity sensor. This driver uses a GPIO pin attached to a NPN transistor\nto send the low signal required to start the communication.\n\nGeneral GPIO Pin (NOT an SPI CS) used to pull the signal pin low. The DHT11/DHT22\nwill then send its binary data by pulling the data pin low. SPI bus reads the \nhigh and low data and determins the bits based on the time the sensor holds the\nvoltage high. Data is converted to temperature and humidity.\n\nNOTE: Requires SPI bus to run at a minimum of 125kHz to properly read the data.\n Only SPI0 on RPI4 functions properly. SPI1+ is not able to read data.\n\nParts:\n - DHT11 / DHT22 (DHT11: https://amzn.to/3DCEH0W, DHT22: https://amzn.to/3Y2BTm5)\n - NPN 2N5551 transistor (https://amzn.to/3YiM59Y)\n - 1x 470ohm resistor (https://amzn.to/3HvG6I6)\n - 1x 1k ohm resistor\\___use for 5v to 3.3v level shift if board is 3.3v \n - 1x 2k ohm resistor/ or use a level shifter (https://amzn.to/3X0jdSL)\n - Linux SBC\n\nCabling:\n\n ------------------------------------------- \n | | \n | 5v | \n | + | \n .-. | | \n 2k| | | \n | | | | \n '-' ___ | | \n |-----|1k_|---- | | \n | | | | \n | | o########## | \n | | ########## | \n SPI MISO o |-----------o#DHT11/22# | \n ___ |/ ########## | \n GPIO o----|470|--| |----o########## | \n |> | | \n o 2N5551 | | | \n | | | \n GND o-----------------------------------------| \n \n(created by AACircuit.py \u00a9 2020 JvO)\n\n## Usage:\n\n\n # Import DHT SPI class\n from dht11_spi import DHT11_Spi, DHT22_Spi\n\n # initialize device, use (DHT11_Spi or DHT22_Spi)\n # cs_chip and cs_pin from \"gpioinfo\". gpiod used for platform compatibility.\n dht = DHT22_Spi(spiBus=0, cs_chip=0, cs_pin=26)\n reading = dht22.read() # returns instance of DhtReadings\n print(reading)\n # --or--\n print(reading.temp_c, reading.temp_f, reading.humidity)\n\n## Testing\nIncluded in the module is a basic test script that can be executed with the following:\n\n python3 -m dht11_spi [gpio]\n\nAdditional test options are available for interval, run time, dht22. Documentation is available using the \"--help\" option.\n\n### Example Output\n\n DHT11: 105/105 (100.0%): Temps (min/avg/max): 73.54/75.2/75.34 deg FHumidity (min/avg/max): 17.0/17.0/17.0 %\n DHT22: 112/112 (100.0%): Temps (min/avg/max): 74.48/74.51/74.66 deg FHumidity (min/avg/max): 14.1/14.21/16.0 %\n",
"bugtrack_url": null,
"license": "",
"summary": "Python module to use the SPI bus to read DHT11/DHT22 sensors.",
"version": "1.0.5",
"project_urls": {
"Bug Tracker": "https://github.com/LearningToPi/dht11_spi/issues",
"Homepage": "https://www.learningtopi.com/python-modules-applications/dht11_spi/",
"Source Code": "https://github.com/LearningToPi/dht11_spi"
},
"split_keywords": [
"dht11",
"dht22",
"spi"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0524aca7d7baf596f302fe2b2076f9cec03af14eab8b598bda2fdcff54d22fac",
"md5": "cfb55fd01118d339a7d73181c04dd6e4",
"sha256": "1cae2fd142fdb0863cc643d6441fd908bd603b9b6d6e371287f3808f8004b161"
},
"downloads": -1,
"filename": "dht11_spi-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cfb55fd01118d339a7d73181c04dd6e4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 12192,
"upload_time": "2023-08-15T18:19:36",
"upload_time_iso_8601": "2023-08-15T18:19:36.278090Z",
"url": "https://files.pythonhosted.org/packages/05/24/aca7d7baf596f302fe2b2076f9cec03af14eab8b598bda2fdcff54d22fac/dht11_spi-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c0ef7893cb51c5e406548a4adce2b617d9b0457b6f0bcf2e661a5b938ac84fcf",
"md5": "38f8f2988dc1901b6435b7dec01311b8",
"sha256": "d16580928bb9bc9e9ecbd2044ce761ddeef2e54a59a8603ae216a0a1afcb6942"
},
"downloads": -1,
"filename": "dht11_spi-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "38f8f2988dc1901b6435b7dec01311b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 9899,
"upload_time": "2023-08-15T18:19:37",
"upload_time_iso_8601": "2023-08-15T18:19:37.332583Z",
"url": "https://files.pythonhosted.org/packages/c0/ef/7893cb51c5e406548a4adce2b617d9b0457b6f0bcf2e661a5b938ac84fcf/dht11_spi-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-15 18:19:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LearningToPi",
"github_project": "dht11_spi",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "dht11-spi"
}