[![CircleCI](https://dl.circleci.com/status-badge/img/gh/valletw/pyummeter/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/valletw/pyummeter/tree/main)
# Python UM-Meter interface
Support RDTech UM24C, UM25C, UM34C.
## Library usage
Open an UM-Meter interface and request data:
```python
from pyummeter import UMmeter, UMmeterInterfaceTTY
with UMmeter(UMmeterInterfaceTTY("/path/to/serial/port")) as meter:
data = meter.get_data()
print(f"{data['voltage']} V / {data['power']} W")
```
It is also possible to export the data to a CSV file:
```python
from datetime import datetime
from pyummeter import UMmeter, UMmeterInterfaceTTY
from pyummeter.export_csv import ExportCSV
csv = ExportCSV("/path/to/csv")
with UMmeter(UMmeterInterfaceTTY("/path/to/serial/port")) as meter:
csv.update(datetime.now(), meter.get_data())
```
List of data available:
- `model`: UM-Meter model name (*exported to CSV*)
- `voltage`: Voltage (V) (*exported to CSV*)
- `intensity`: Intensity (A) (*exported to CSV*)
- `power`: Power (W) (*exported to CSV*)
- `resistance`: Resistance (Ohm) (*exported to CSV*)
- `usb_voltage_dp`: USB Voltage D+ (V) (*exported to CSV*)
- `usb_voltage_dn`: USB Voltage D- (V) (*exported to CSV*)
- `charging_mode`: Charging mode short name (*exported to CSV*)
- `charging_mode_full`: Charging mode full name
- `temperature_celsius`: Temperature (°C) (*exported to CSV*)
- `temperature_fahrenheit`: Temperature (°F)
- `data_group_selected`: Selected data group (index)
- `data_group`: Data for each data group (list) (*exported to CSV, only the selected group*)
- `capacity`: Capacity (Ah)
- `energy`: Energy (Wh)
- `record_capacity_threshold`: [Record mode] Capacity threshold (Ah) (*exported to CSV*)
- `record_energy_threshold`: [Record mode] Energy threshold (Wh) (*exported to CSV*)
- `record_intensity_threshold`: [Record mode] Intensity threshold (A) (*exported to CSV*)
- `record_duration`: [Record mode] Duration (seconds) (*exported to CSV*)
- `record_enabled`: [Record mode] Enable status (*exported to CSV*)
- `screen_index`: Screen index
- `screen_timeout`: Screen timeout
- `screen_brightness`: Screen brightness
- `checksum`: Checksum of all data
Meter control managed (not available on all model):
- Screen control:
- Change (next/previous)
- Rotate
- Set timeout (0 to 9 minutes)
- Set brightness (0 to 5)
- Data group control:
- Select (0 to 9, next)
- Clear
- Record threshold (0 to 300 mA)
## Running example
### Bluetooth initialisation
```shell
$ sudo killall rfcomm
$ rfkill block bluetooth
$ rfkill unblock bluetooth
$ sudo bluetoothctl
[bluetooth] power on
[bluetooth] agent on
[bluetooth] scan on
[bluetooth] pair <MAC>
$ sudo rfcomm connect /dev/rfcomm0 <MAC>
```
### Demo application usage
```shell
poetry install
poetry run task demo -t /dev/rfcomm0
```
Raw data
{
"_id": null,
"home_page": "https://github.com/valletw/pyummeter",
"name": "pyummeter",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "ummeter",
"author": "William Vallet",
"author_email": "valletw@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ec/47/fccddc6f0e953d0e5634013be52bdd06cd6d612e7bce13f659cc89bbfc92/pyummeter-0.2.0.tar.gz",
"platform": null,
"description": "[![CircleCI](https://dl.circleci.com/status-badge/img/gh/valletw/pyummeter/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/valletw/pyummeter/tree/main)\n\n# Python UM-Meter interface\n\nSupport RDTech UM24C, UM25C, UM34C.\n\n## Library usage\n\nOpen an UM-Meter interface and request data:\n\n```python\nfrom pyummeter import UMmeter, UMmeterInterfaceTTY\n\nwith UMmeter(UMmeterInterfaceTTY(\"/path/to/serial/port\")) as meter:\n data = meter.get_data()\n print(f\"{data['voltage']} V / {data['power']} W\")\n```\n\nIt is also possible to export the data to a CSV file:\n\n```python\nfrom datetime import datetime\nfrom pyummeter import UMmeter, UMmeterInterfaceTTY\nfrom pyummeter.export_csv import ExportCSV\n\ncsv = ExportCSV(\"/path/to/csv\")\nwith UMmeter(UMmeterInterfaceTTY(\"/path/to/serial/port\")) as meter:\n csv.update(datetime.now(), meter.get_data())\n```\n\nList of data available:\n\n- `model`: UM-Meter model name (*exported to CSV*)\n- `voltage`: Voltage (V) (*exported to CSV*)\n- `intensity`: Intensity (A) (*exported to CSV*)\n- `power`: Power (W) (*exported to CSV*)\n- `resistance`: Resistance (Ohm) (*exported to CSV*)\n- `usb_voltage_dp`: USB Voltage D+ (V) (*exported to CSV*)\n- `usb_voltage_dn`: USB Voltage D- (V) (*exported to CSV*)\n- `charging_mode`: Charging mode short name (*exported to CSV*)\n- `charging_mode_full`: Charging mode full name\n- `temperature_celsius`: Temperature (\u00b0C) (*exported to CSV*)\n- `temperature_fahrenheit`: Temperature (\u00b0F)\n- `data_group_selected`: Selected data group (index)\n- `data_group`: Data for each data group (list) (*exported to CSV, only the selected group*)\n - `capacity`: Capacity (Ah)\n - `energy`: Energy (Wh)\n- `record_capacity_threshold`: [Record mode] Capacity threshold (Ah) (*exported to CSV*)\n- `record_energy_threshold`: [Record mode] Energy threshold (Wh) (*exported to CSV*)\n- `record_intensity_threshold`: [Record mode] Intensity threshold (A) (*exported to CSV*)\n- `record_duration`: [Record mode] Duration (seconds) (*exported to CSV*)\n- `record_enabled`: [Record mode] Enable status (*exported to CSV*)\n- `screen_index`: Screen index\n- `screen_timeout`: Screen timeout\n- `screen_brightness`: Screen brightness\n- `checksum`: Checksum of all data\n\nMeter control managed (not available on all model):\n\n- Screen control:\n - Change (next/previous)\n - Rotate\n - Set timeout (0 to 9 minutes)\n - Set brightness (0 to 5)\n- Data group control:\n - Select (0 to 9, next)\n - Clear\n- Record threshold (0 to 300 mA)\n\n## Running example\n\n### Bluetooth initialisation\n\n```shell\n$ sudo killall rfcomm\n$ rfkill block bluetooth\n$ rfkill unblock bluetooth\n$ sudo bluetoothctl\n[bluetooth] power on\n[bluetooth] agent on\n[bluetooth] scan on\n[bluetooth] pair <MAC>\n$ sudo rfcomm connect /dev/rfcomm0 <MAC>\n```\n\n### Demo application usage\n\n```shell\npoetry install\npoetry run task demo -t /dev/rfcomm0\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python UM-Meter interface",
"version": "0.2.0",
"split_keywords": [
"ummeter"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "80a7980d0ef71543052f216dc009e21e",
"sha256": "3ab83c8d4ee25a0df714caa5b094ac8e601f0159fd8f69565137045b569a1688"
},
"downloads": -1,
"filename": "pyummeter-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "80a7980d0ef71543052f216dc009e21e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 7367,
"upload_time": "2022-12-24T16:04:15",
"upload_time_iso_8601": "2022-12-24T16:04:15.796145Z",
"url": "https://files.pythonhosted.org/packages/e8/93/72c5e2031529b690526e1be70a111f1a7e2011bb416ba98ccb7f6e26349c/pyummeter-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "57aef4f4a0afec8e1ff9ac9983258d0a",
"sha256": "def19bd72fb238f1ebb225caf5b7d7b254a79aa7b8bd4f0e6249a1c18eb98962"
},
"downloads": -1,
"filename": "pyummeter-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "57aef4f4a0afec8e1ff9ac9983258d0a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 7176,
"upload_time": "2022-12-24T16:04:16",
"upload_time_iso_8601": "2022-12-24T16:04:16.738049Z",
"url": "https://files.pythonhosted.org/packages/ec/47/fccddc6f0e953d0e5634013be52bdd06cd6d612e7bce13f659cc89bbfc92/pyummeter-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-24 16:04:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "valletw",
"github_project": "pyummeter",
"travis_ci": false,
"coveralls": true,
"github_actions": false,
"circle": true,
"lcname": "pyummeter"
}