raspberry-sensors


Nameraspberry-sensors JSON
Version 2.1.2 PyPI version JSON
download
home_page
SummaryThis package for getting values from sensors mh_z19, DHT, ads1015
upload_time2024-01-26 11:51:26
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords raspberry_sensors adafruit-dht adafruit-circuitpython-ads1x15 mh-z19 raspberry raspberry pi sensors hardware iot python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

```python
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.

```python
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`).

```python
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`).

```python
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`).

```python
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}
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "raspberry-sensors",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "raspberry_sensors,Adafruit-DHT,adafruit-circuitpython-ads1x15,mh-z19,raspberry,raspberry pi,sensors,hardware,IoT,Python",
    "author": "",
    "author_email": "Develper <testerlzt@mail.ru>",
    "download_url": "https://files.pythonhosted.org/packages/bb/21/eac141c94b85c52f6c1ab11ca3bce81f83af038d519b6c083bde56929ddf/raspberry_sensors-2.1.2.tar.gz",
    "platform": null,
    "description": "# RaspberryPi Sensors Library\r\n\r\nThis 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.\r\n\r\n## Usage Examples\r\n\r\n### Initialization\r\n\r\nFirst, import the library and create an instance of the `Sensors` class.\r\n\r\n```python\r\nfrom raspberry_sensors import Sensors\r\nsensors = Sensors()\r\n```\r\n\r\n### Disabling Error Logging\r\n\r\nYou can disable error logging by passing the `logging_error` parameter equal to `False` when creating an instance of the `Sensors` class.\r\n\r\n```python\r\nsensors = Sensors(logging_error=False)\r\n```\r\n\r\n### Getting Values from DHT Sensor\r\n\r\nTo get values from the DHT sensor, use the `get_dht` method, passing the sensor type (`_type`) and the GPIO pin number (`gpio`).\r\n\r\n```python\r\nsensors.get_dht(_type=22, gpio=4)\r\n# _type=22 - DHT22\r\n# _type=11 - DHT11\r\n# gpio - GPIO pin\r\n\r\n# return data (dict)\r\n# {\"humidity\": 36.0, \"temperature\": 21.0}\r\n```\r\n\r\n### Getting Values from ADS Sensor\r\n\r\nTo 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`).\r\n\r\n```python\r\nsensors.get_ads(channel, interpolate=False, interpolate_min=0, interpolate_max=0)\r\n# channel - the channel that you want to get the voltage from\r\n# interpolate - getting the normal value using interpolation\r\n# interpolate_min (use if interpolate True) - minimum value at 0 V\r\n# interpolate_max (use if interpolate True) - maximum value at 0 V\r\n\r\n# return data (float)\r\n# if interpolate=False - voltage\r\n# if interpolate=True - the voltage value to which the interpolation formula is applied \r\n```\r\n\r\n### Getting Values from MH-Z19 Sensor\r\n\r\nTo 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`).\r\n\r\n```python\r\nsensors.get_mhz(gpio=12, pwm=False)\r\n# gpio - GPIO pin\r\n# pwm - if pwm is True it will be read using pwm otherwise it is default\r\n\r\n# return data (dict)\r\n# {\"co2\": 5000}\r\n```\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This package for getting values from sensors mh_z19, DHT, ads1015",
    "version": "2.1.2",
    "project_urls": null,
    "split_keywords": [
        "raspberry_sensors",
        "adafruit-dht",
        "adafruit-circuitpython-ads1x15",
        "mh-z19",
        "raspberry",
        "raspberry pi",
        "sensors",
        "hardware",
        "iot",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f5bc781746d956d911778e51bdcf0b0104078276c40e8debac6c7f1f152b13ae",
                "md5": "b13b53d78ff547d316b203353b11f018",
                "sha256": "52e675c780348f49ad8d3b9b133d8b21d3e82fb349d5844be99614e4d5559c2c"
            },
            "downloads": -1,
            "filename": "raspberry_sensors-2.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b13b53d78ff547d316b203353b11f018",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4467,
            "upload_time": "2024-01-26T11:51:23",
            "upload_time_iso_8601": "2024-01-26T11:51:23.916369Z",
            "url": "https://files.pythonhosted.org/packages/f5/bc/781746d956d911778e51bdcf0b0104078276c40e8debac6c7f1f152b13ae/raspberry_sensors-2.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb21eac141c94b85c52f6c1ab11ca3bce81f83af038d519b6c083bde56929ddf",
                "md5": "e682e840ebf7a2fa8a89dbe7e8b162c1",
                "sha256": "b0a8b29b6a727c9f0fbbf53b51e017319fff007e71bd9523525bc22042be4153"
            },
            "downloads": -1,
            "filename": "raspberry_sensors-2.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e682e840ebf7a2fa8a89dbe7e8b162c1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3991,
            "upload_time": "2024-01-26T11:51:26",
            "upload_time_iso_8601": "2024-01-26T11:51:26.127995Z",
            "url": "https://files.pythonhosted.org/packages/bb/21/eac141c94b85c52f6c1ab11ca3bce81f83af038d519b6c083bde56929ddf/raspberry_sensors-2.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-26 11:51:26",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "raspberry-sensors"
}
        
Elapsed time: 0.17316s