Skip to main content

This package for getting values from sensors mh_z19, DHT, ads1015

Project description

RaspberryPi Sensors Library

This library provides functions to retrieve data from mh_z19, DHT, and ads1015 sensors on a Raspberry Pi. Note that in case of errors, no exceptions are thrown, and the cached sensor value is also returned in case of an error.

Usage Examples

Initialization

First, import the library and create an instance of the Sensors class.

from raspberry_sensors import Sensors
sensors = Sensors()

Disabling Error Logging

You can disable error logging by passing the logging_error parameter equal to False when creating an instance of the Sensors class.

sensors = Sensors(logging_error=False)

Getting Values from DHT Sensor

To get values from the DHT sensor, use the get_dht method, passing the sensor type (_type) and the GPIO pin number (gpio).

sensors.get_dht(_type=22, gpio=4)
# _type=22 - DHT22
# _type=11 - DHT11
# gpio - GPIO pin

# return data (dict)
# {"humidity": 36.0, "temperature": 21.0}

Getting Values from ADS Sensor

To get values from the ADS sensor, use the get_ads method, passing the channel you want to get the voltage from (channel), whether to get the normal value using interpolation (interpolate), and the minimum and maximum values at 0V (interpolate_min and interpolate_max).

sensors.get_ads(channel, interpolate=False, interpolate_min=0, interpolate_max=0)
# channel - the channel that you want to get the voltage from
# interpolate - getting the normal value using interpolation
# interpolate_min (use if interpolate True) - minimum value at 0 V
# interpolate_max (use if interpolate True) - maximum value at 0 V

# return data (float)
# if interpolate=False - voltage
# if interpolate=True - the voltage value to which the interpolation formula is applied 

Getting Values from MH-Z19 Sensor

To get values from the MH-Z19 sensor, use the get_mhz method, passing the GPIO pin number (gpio) and whether to read using PWM (pwm).

sensors.get_mhz(gpio=12, pwm=False)
# gpio - GPIO pin
# pwm - if pwm is True it will be read using pwm otherwise it is default

# return data (dict)
# {"co2": 5000}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raspberry_sensors-2.1.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raspberry_sensors-2.1.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file raspberry_sensors-2.1.2.tar.gz.

File metadata

  • Download URL: raspberry_sensors-2.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for raspberry_sensors-2.1.2.tar.gz
Algorithm Hash digest
SHA256 b0a8b29b6a727c9f0fbbf53b51e017319fff007e71bd9523525bc22042be4153
MD5 e682e840ebf7a2fa8a89dbe7e8b162c1
BLAKE2b-256 bb21eac141c94b85c52f6c1ab11ca3bce81f83af038d519b6c083bde56929ddf

See more details on using hashes here.

File details

Details for the file raspberry_sensors-2.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for raspberry_sensors-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 52e675c780348f49ad8d3b9b133d8b21d3e82fb349d5844be99614e4d5559c2c
MD5 b13b53d78ff547d316b203353b11f018
BLAKE2b-256 f5bc781746d956d911778e51bdcf0b0104078276c40e8debac6c7f1f152b13ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page