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.
👉 This is a Python 3.8+ only fork of the original DFRobot Arduino library, adapted for Raspberry Pi.
📦 Installation
Simply install with pip
pip install git+https://github.com/kallegrens/dfrobot_environmental_sensor.git@master
⚡️ Package will soon be available on PyPi!
🚀 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
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
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
- [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.0.0.tar.gz.
File metadata
- Download URL: dfrobot_environmental_sensor-2.0.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae779bde62afcc4654de4e1e86d1522b3e34ac56eac1e85bbdd1ffe2009cf0b
|
|
| MD5 |
32340dbe70d48613229c1855a48083d3
|
|
| BLAKE2b-256 |
1278e62311d4ae4e1491fe55ded1acbb7e6a81a4bec2eac0f7575584e4412a48
|
File details
Details for the file dfrobot_environmental_sensor-2.0.0-py3-none-any.whl.
File metadata
- Download URL: dfrobot_environmental_sensor-2.0.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79b3336d21827f4ae2696b4cf9588fb8fae1fb2a7b26ee41ac68df5f6aafb84e
|
|
| MD5 |
f8389b1fb6ed5517dcdbfc4fa354705d
|
|
| BLAKE2b-256 |
10ee7d6dcc7baf3289ac0606a82484b1f6a79e5b7b8802c9348a325c597d81ad
|