dfrobot-environmental-sensor


Namedfrobot-environmental-sensor JSON
Version 2.1.1 PyPI version JSON
download
home_pageNone
SummaryPython 3.8+ library for the DFRobot SEN0500/SEN0501 environmental sensor on Raspberry Pi.
upload_time2025-08-23 22:57:19
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2010 DFRobot Co.Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords dfrobot sen0500 sen0501 environmental sensor i2c uart raspberry pi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🌍 DFRobot Environmental Sensor Library

Python library for the multifunctional **DFRobot Environmental Sensor (SEN0500/SEN0501)**.  
This sensor integrates **temperature 🌡️, humidity 💧, UV index ☀️, light intensity 💡, atmospheric pressure 🌪️, and altitude 🏔️** into one module.

It supports both **Gravity** and **Breakout** interfaces and communicates over **I²C** or **UART**.

👉 This is a **Python 3.8+ only** fork of the original DFRobot Arduino library, adapted for Raspberry Pi.

---

## 📦 Installation

Simply install with `pip`

```bash
pip install dfrobot-environmental-sensor
```

## 🚀 Pythonic API usage

The library also exposes a modern, Pythonic API for direct use.
At the top level you’ll find:

`EnvironmentalSensor` → the main driver class

`Units` → supported measurement units (temperature & pressure)

`UVSensor` → supported UV sensor variants

### 🐍 Minimal example

```python
from dfrobot_environmental_sensor import EnvironmentalSensor, Units, UVSensor

UV_VARIANT = UVSensor.LTR390UV  # or UVSensor.S12DS
# Create an I²C instance on bus 1
sensor = EnvironmentalSensor.i2c(bus=1, address=0x22, uv_sensor=UV_VARIANT)

if sensor.is_present():
    print("🌡️ Temperature:", sensor.read_temperature(Units.C), "°C")
    print("🌡️ Temperature:", sensor.read_temperature(Units.F), "°F")
    print("💧 Humidity:", sensor.read_humidity(), "%")
    print("☀️ UV Irradiance:", sensor.read_uv_irradiance(), "mW/cm²")
    print("💡 Light:", sensor.read_illuminance(), "lx")
    print("🌪️ Pressure:", sensor.read_pressure(Units.HPA), "hPa")
    print("🏔️ Altitude:", sensor.estimate_altitude(), "m")
else:
    print("❌ Sensor not detected.")
```

## 🛠️ Methods

```python
def is_present(self) -> bool:
    """Check if the sensor responds. Returns True if detected."""

def read_temperature(self, units: Units = Units.C) -> float:
    """Return ambient temperature in °C or °F."""

def read_humidity(self) -> float:
    """Return relative humidity (%)"""

def read_uv_irradiance(self) -> float:
    """Return UV irradiance (mW/cm²)."""

def read_illuminance(self) -> float:
    """Return ambient light level (lux)."""

def read_pressure(self, units: Units = Units.HPA) -> float:
    """Return atmospheric pressure in hPa or kPa."""

def estimate_altitude(self, sea_level_hpa: float = 1013.25) -> float:
    """Estimate altitude (m) from current pressure."""
```

## ✅ Compatibility

- Raspberry Pi (tested on Raspberry Pi 5)
- Python 3.8+ only

## 🔗 Product Links

|  |  |
|-------------------|-------------------|
| <img src="./images/SEN0500.png" alt="SEN0500" width="250"/> | <img src="./images/SEN0501.png" alt="SEN0501" width="250"/> |
| <p align="center">🌐 <a href="https://www.dfrobot.com/product-2522.html">SEN0500 – Fermion</a></p> | <p align="center">🌐 <a href="https://www.dfrobot.com/product-2528.html">SEN0501 – Gravity</a></p> |

## 📖 Changelog

The full changelog is available in [CHANGELOG.md](./CHANGELOG.md).

### Latest Release

- **[2.0.0 – 2025-08-20]** 💥 Python-only fork
  - ✅ Python 3.8+ support with `smbus3`
  - ✅ Modernized README and examples
  - ❌ Dropped Arduino and Python 2.x support

### Previous Release (DFRobot upstream)

- **[1.1.0 – 2024-12-18]** ⚡️ Code updates from DFRobot
- **[1.0.0 – 2021-12-20]** ✨ Initial release by DFRobot (Arduino-compatible)

## 🙌 Credits

- Originally written by [tangjie133](https://github.com/tangjie133) (DFRobot), 2021
- Python 3.8+ fork maintained by [kallegrens](https://github.com/kallegrens), 2025

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dfrobot-environmental-sensor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Karl Lundgren <karl.lundgren@ri.se>",
    "keywords": "DFRobot, SEN0500, SEN0501, environmental, sensor, I2C, UART, Raspberry Pi",
    "author": null,
    "author_email": "\"DFRobot (original library)\" <jie.tang@dfrobot.com>",
    "download_url": "https://files.pythonhosted.org/packages/a0/01/00194330eef07cda3c3fd4cc64d6b72c1e0d1b6d51cb4697db0ad3b53c74/dfrobot_environmental_sensor-2.1.1.tar.gz",
    "platform": null,
    "description": "# \ud83c\udf0d DFRobot Environmental Sensor Library\n\nPython library for the multifunctional **DFRobot Environmental Sensor (SEN0500/SEN0501)**.  \nThis sensor integrates **temperature \ud83c\udf21\ufe0f, humidity \ud83d\udca7, UV index \u2600\ufe0f, light intensity \ud83d\udca1, atmospheric pressure \ud83c\udf2a\ufe0f, and altitude \ud83c\udfd4\ufe0f** into one module.\n\nIt supports both **Gravity** and **Breakout** interfaces and communicates over **I\u00b2C** or **UART**.\n\n\ud83d\udc49 This is a **Python 3.8+ only** fork of the original DFRobot Arduino library, adapted for Raspberry Pi.\n\n---\n\n## \ud83d\udce6 Installation\n\nSimply install with `pip`\n\n```bash\npip install dfrobot-environmental-sensor\n```\n\n## \ud83d\ude80 Pythonic API usage\n\nThe library also exposes a modern, Pythonic API for direct use.\nAt the top level you\u2019ll find:\n\n`EnvironmentalSensor` \u2192 the main driver class\n\n`Units` \u2192 supported measurement units (temperature & pressure)\n\n`UVSensor` \u2192 supported UV sensor variants\n\n### \ud83d\udc0d Minimal example\n\n```python\nfrom dfrobot_environmental_sensor import EnvironmentalSensor, Units, UVSensor\n\nUV_VARIANT = UVSensor.LTR390UV  # or UVSensor.S12DS\n# Create an I\u00b2C instance on bus 1\nsensor = EnvironmentalSensor.i2c(bus=1, address=0x22, uv_sensor=UV_VARIANT)\n\nif sensor.is_present():\n    print(\"\ud83c\udf21\ufe0f Temperature:\", sensor.read_temperature(Units.C), \"\u00b0C\")\n    print(\"\ud83c\udf21\ufe0f Temperature:\", sensor.read_temperature(Units.F), \"\u00b0F\")\n    print(\"\ud83d\udca7 Humidity:\", sensor.read_humidity(), \"%\")\n    print(\"\u2600\ufe0f UV Irradiance:\", sensor.read_uv_irradiance(), \"mW/cm\u00b2\")\n    print(\"\ud83d\udca1 Light:\", sensor.read_illuminance(), \"lx\")\n    print(\"\ud83c\udf2a\ufe0f Pressure:\", sensor.read_pressure(Units.HPA), \"hPa\")\n    print(\"\ud83c\udfd4\ufe0f Altitude:\", sensor.estimate_altitude(), \"m\")\nelse:\n    print(\"\u274c Sensor not detected.\")\n```\n\n## \ud83d\udee0\ufe0f Methods\n\n```python\ndef is_present(self) -> bool:\n    \"\"\"Check if the sensor responds. Returns True if detected.\"\"\"\n\ndef read_temperature(self, units: Units = Units.C) -> float:\n    \"\"\"Return ambient temperature in \u00b0C or \u00b0F.\"\"\"\n\ndef read_humidity(self) -> float:\n    \"\"\"Return relative humidity (%)\"\"\"\n\ndef read_uv_irradiance(self) -> float:\n    \"\"\"Return UV irradiance (mW/cm\u00b2).\"\"\"\n\ndef read_illuminance(self) -> float:\n    \"\"\"Return ambient light level (lux).\"\"\"\n\ndef read_pressure(self, units: Units = Units.HPA) -> float:\n    \"\"\"Return atmospheric pressure in hPa or kPa.\"\"\"\n\ndef estimate_altitude(self, sea_level_hpa: float = 1013.25) -> float:\n    \"\"\"Estimate altitude (m) from current pressure.\"\"\"\n```\n\n## \u2705 Compatibility\n\n- Raspberry Pi (tested on Raspberry Pi 5)\n- Python 3.8+ only\n\n## \ud83d\udd17 Product Links\n\n|  |  |\n|-------------------|-------------------|\n| <img src=\"./images/SEN0500.png\" alt=\"SEN0500\" width=\"250\"/> | <img src=\"./images/SEN0501.png\" alt=\"SEN0501\" width=\"250\"/> |\n| <p align=\"center\">\ud83c\udf10 <a href=\"https://www.dfrobot.com/product-2522.html\">SEN0500 \u2013 Fermion</a></p> | <p align=\"center\">\ud83c\udf10 <a href=\"https://www.dfrobot.com/product-2528.html\">SEN0501 \u2013 Gravity</a></p> |\n\n## \ud83d\udcd6 Changelog\n\nThe full changelog is available in [CHANGELOG.md](./CHANGELOG.md).\n\n### Latest Release\n\n- **[2.0.0 \u2013 2025-08-20]** \ud83d\udca5 Python-only fork\n  - \u2705 Python 3.8+ support with `smbus3`\n  - \u2705 Modernized README and examples\n  - \u274c Dropped Arduino and Python 2.x support\n\n### Previous Release (DFRobot upstream)\n\n- **[1.1.0 \u2013 2024-12-18]** \u26a1\ufe0f Code updates from DFRobot\n- **[1.0.0 \u2013 2021-12-20]** \u2728 Initial release by DFRobot (Arduino-compatible)\n\n## \ud83d\ude4c Credits\n\n- Originally written by [tangjie133](https://github.com/tangjie133) (DFRobot), 2021\n- Python 3.8+ fork maintained by [kallegrens](https://github.com/kallegrens), 2025\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2010 DFRobot Co.Ltd\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "Python 3.8+ library for the DFRobot SEN0500/SEN0501 environmental sensor on Raspberry Pi.",
    "version": "2.1.1",
    "project_urls": {
        "Changelog": "https://github.com/kallegrens/dfrobot-environmental-sensor/blob/master/CHANGELOG.md",
        "Homepage": "https://github.com/kallegrens/dfrobot-environmental-sensor",
        "Issues": "https://github.com/kallegrens/dfrobot-environmental-sensor/issues",
        "Source": "https://github.com/kallegrens/dfrobot-environmental-sensor"
    },
    "split_keywords": [
        "dfrobot",
        " sen0500",
        " sen0501",
        " environmental",
        " sensor",
        " i2c",
        " uart",
        " raspberry pi"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a2e0c6086a954236aa205d67df02f7fc2b200923230a9500d16627741fca86dd",
                "md5": "016d97d2bf46c3e1ff765a9d052ae35f",
                "sha256": "557ee73336ea6360f9d896fc954bc1374986be74fa799447e797c120ceb8e55f"
            },
            "downloads": -1,
            "filename": "dfrobot_environmental_sensor-2.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "016d97d2bf46c3e1ff765a9d052ae35f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12116,
            "upload_time": "2025-08-23T22:57:17",
            "upload_time_iso_8601": "2025-08-23T22:57:17.935019Z",
            "url": "https://files.pythonhosted.org/packages/a2/e0/c6086a954236aa205d67df02f7fc2b200923230a9500d16627741fca86dd/dfrobot_environmental_sensor-2.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a00100194330eef07cda3c3fd4cc64d6b72c1e0d1b6d51cb4697db0ad3b53c74",
                "md5": "9f77ae7fe9fa128b01606ba7f2c7cfcf",
                "sha256": "404f3f8918d4d9b5065c602cb7467ef91ac16309dd74f23dd642c626b962ae1e"
            },
            "downloads": -1,
            "filename": "dfrobot_environmental_sensor-2.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9f77ae7fe9fa128b01606ba7f2c7cfcf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11885,
            "upload_time": "2025-08-23T22:57:19",
            "upload_time_iso_8601": "2025-08-23T22:57:19.377867Z",
            "url": "https://files.pythonhosted.org/packages/a0/01/00194330eef07cda3c3fd4cc64d6b72c1e0d1b6d51cb4697db0ad3b53c74/dfrobot_environmental_sensor-2.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-23 22:57:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kallegrens",
    "github_project": "dfrobot-environmental-sensor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dfrobot-environmental-sensor"
}
        
Elapsed time: 1.24466s