A Python project for interacting with the Uni-T UT383BT Bluetooth LUX meter using BLE (Bluetooth Low Energy). This project enables real-time retrieval and optional logging of light intensity values (in LUX) from the UT383BT device. It uses the bleak
library for cross-platform BLE communication, specifically tested on macOS.
- Connects to the Uni-T UT383BT LUX meter via BLE.
- Sends a command to enable notifications for LUX values.
- Subscribes to the
Data Out
characteristic to receive real-time measurements. - Logs retrieved LUX values to a file for later analysis (optional).
- Modular structure for extensibility and testing.
- Python 3.8 or higher.
- Install the required Python packages listed in
requirements.txt
.
It is recommended to use a Python virtual environment to manage dependencies for this project.
-
Create the Virtual Environment:
python3 -m venv venv
-
Activate the Virtual Environment:
- On macOS/Linux:
source venv/bin/activate
- On Windows:
.\venv\Scripts\activate
- On macOS/Linux:
-
Install Dependencies: Once the virtual environment is activated, install the required packages:
pip install -r requirements.txt
-
Deactivate the Virtual Environment: When you're done, deactivate the environment:
deactivate
- OS: macOS (tested with BLE using LightBlue for initial device exploration).
- Device: Uni-T UT383BT Bluetooth LUX meter.
- Python Library:
bleak
(for BLE communication).
ut383bt-lux-ble-python/
├── README.md # Project documentation
├── LICENSE # License for the project
├── requirements.txt # Python dependencies
├── src/ # Source code
│ ├── __init__.py # Package initialization
│ ├── lux_reader.py # Reads LUX values via BLE
│ ├── lux_logger.py # Logs LUX values to a file
│ └── utils.py # Utility functions (optional)
├── logs/ # Log files
│ └── lux_data_example.log # Example of logged LUX data
└── tests/ # Unit tests
├── __init__.py # Package initialization
└── test_lux_reader.py # Unit tests for lux_reader.py
Run the lux_reader.py
script to connect to the UT383BT device and print LUX values to the console:
python src/lux_reader.py
Run the lux_logger.py
script to log LUX values to a file in the logs
directory:
python src/lux_logger.py
After running lux_logger.py
, a file like logs/lux_data_example.log
will be generated with entries similar to:
75LUX
80LUX
85LUX
Use the tests
folder to validate the functionality of your scripts:
python -m unittest discover tests
All dependencies are listed in requirements.txt
. Install them using:
pip install -r requirements.txt
bleak==0.20.2
- Connection: The script connects to the UT383BT via BLE using its UUID or MAC address.
- Command to Enable Notifications: A specific command (
0x5E
) is written to theData In
characteristic. - Receiving Notifications: LUX values are sent as notifications via the
Data Out
characteristic. - Logging (Optional): The values are logged to a file for later use.
Contributions are welcome! Feel free to fork the repository, open an issue, or submit a pull request.