Python 3.8+ library for the DFRobot SEN0500/SEN0501 environmental sensor on Raspberry Pi.
Project description
🌍 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.
[!IMPORTANT] This fork supports Python 3.8+ only; earlier versions or Arduino libraries are not supported.
📦 Installation
[!TIP] Use a virtual environment to avoid dependency conflicts and run:
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
[!CAUTION] Ensure the I²C bus is enabled and the sensor’s address matches your hardware; some boards may use a different bus or address than
0x22.
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.")
[!NOTE] If the sensor isn’t detected, double-check wiring, power, and address configuration.
🛠️ Methods
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
📖 Changelog
The full changelog is available in CHANGELOG.md.
Latest Release
[!WARNING] Version 2.0.0 removes Arduino and Python 2.x support; projects relying on these should remain on earlier releases.
- [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
- ✅ Python 3.8+ support with
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 (DFRobot), 2021
- Python 3.8+ fork maintained by kallegrens, 2025
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dfrobot_environmental_sensor-2.1.2.tar.gz.
File metadata
- Download URL: dfrobot_environmental_sensor-2.1.2.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c9cc3232b9a8bb49d439048d7f843c9a1924ac06c8e7bb840421efe76c44433
|
|
| MD5 |
736675fa7f936150b82a8f2327efbf5c
|
|
| BLAKE2b-256 |
884474aa53541a376ca68b2c73654bdf22c64f8d0ea1943bc8e86f7f350cb20a
|
Provenance
The following attestation bundles were made for dfrobot_environmental_sensor-2.1.2.tar.gz:
Publisher:
publish.yaml on kallegrens/dfrobot-environmental-sensor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dfrobot_environmental_sensor-2.1.2.tar.gz -
Subject digest:
0c9cc3232b9a8bb49d439048d7f843c9a1924ac06c8e7bb840421efe76c44433 - Sigstore transparency entry: 448637298
- Sigstore integration time:
-
Permalink:
kallegrens/dfrobot-environmental-sensor@0281c183505241992cf5fd603f71434cc03214cd -
Branch / Tag:
refs/tags/v2.1.2 - Owner: https://github.com/kallegrens
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@0281c183505241992cf5fd603f71434cc03214cd -
Trigger Event:
release
-
Statement type:
File details
Details for the file dfrobot_environmental_sensor-2.1.2-py3-none-any.whl.
File metadata
- Download URL: dfrobot_environmental_sensor-2.1.2-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72324740de7d259febfd845b9d17e803797a2a6196573d99147f6d0ca2c7832f
|
|
| MD5 |
cbe169dc8cdd8cfc007491f524376574
|
|
| BLAKE2b-256 |
eadaf77d809fee10572ca156e2ae4ba79fc4d6ea41df624f06cb8541192202f7
|
Provenance
The following attestation bundles were made for dfrobot_environmental_sensor-2.1.2-py3-none-any.whl:
Publisher:
publish.yaml on kallegrens/dfrobot-environmental-sensor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dfrobot_environmental_sensor-2.1.2-py3-none-any.whl -
Subject digest:
72324740de7d259febfd845b9d17e803797a2a6196573d99147f6d0ca2c7832f - Sigstore transparency entry: 448637318
- Sigstore integration time:
-
Permalink:
kallegrens/dfrobot-environmental-sensor@0281c183505241992cf5fd603f71434cc03214cd -
Branch / Tag:
refs/tags/v2.1.2 - Owner: https://github.com/kallegrens
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@0281c183505241992cf5fd603f71434cc03214cd -
Trigger Event:
release
-
Statement type: