{"id":26163473,"url":"https://github.com/electromake/usb-thermometer-python","last_synced_at":"2026-04-16T06:02:49.498Z","repository":{"id":278655889,"uuid":"936347558","full_name":"electromake/usb-thermometer-python","owner":"electromake","description":"Python library for USB Thermometer (DS18B20 sensor).","archived":false,"fork":false,"pushed_at":"2025-03-05T14:35:59.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-25T18:59:28.657Z","etag":null,"topics":["ds18b20","electromake","iot","python","raspberry-pi","thermometer","usb","usb-thermometer"],"latest_commit_sha":null,"homepage":"https://electromake.pl/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/electromake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-20T23:39:12.000Z","updated_at":"2025-03-05T14:36:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"414c031e-bd45-407f-8497-30aab8648115","html_url":"https://github.com/electromake/usb-thermometer-python","commit_stats":null,"previous_names":["electromake/usb-thermometer-python"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/electromake/usb-thermometer-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electromake%2Fusb-thermometer-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electromake%2Fusb-thermometer-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electromake%2Fusb-thermometer-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electromake%2Fusb-thermometer-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/electromake","download_url":"https://codeload.github.com/electromake/usb-thermometer-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electromake%2Fusb-thermometer-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31873607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ds18b20","electromake","iot","python","raspberry-pi","thermometer","usb","usb-thermometer"],"created_at":"2025-03-11T14:27:13.267Z","updated_at":"2026-04-16T06:02:49.466Z","avatar_url":"https://github.com/electromake.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# USB Thermometer Python library\n![alt text](https://electromake.pl/wp-content/uploads/2024/12/USB_Thermometer_3D_model_rendering_top-1.png)\n\n## Overview\nThis project provides a Python 3 library for interfacing with DS18B20 temperature sensors via a USB-based 1-Wire interface. The library implements the 1-Wire protocol over a serial port, allowing you to discover connected sensors, read temperature measurements, configure sensor settings (precision, alarm thresholds), and perform low-level bit manipulations required for proper communication with the sensors.\n\n## Features\n\n- **Sensor Discovery:** Detect all DS18B20 sensors on the 1-Wire bus.\n- **Temperature Reading:** Continuously read sensor temperature values.\n- **Sensor Configuration:** Write to and read from the sensor scratchpad, set measurement precision and alarm thresholds.\n- **Utilities:** Functions for converting bit lists to hexadecimal strings/bytearrays and computing CRC8 checksums.\n- **Examples:** Three comprehensive examples demonstrate:\n  1. Discovering sensors and continuously reading their temperatures.\n  2. Storing sensor data in an SQL database using SQLAlchemy.\n  3. Configuring sensor settings (precision and alarm thresholds).\n\n## Project Structure\n\n- **wire.py**  \n  Implements the `USBThermometer` class which manages communication with DS18B20 sensors via a serial port.\n\n- **sensors.py**  \n  Contains the `DS18B20` class that represents individual temperature sensors, handling their ROM codes, serial numbers, and configuration registers.\n\n- **utils.py**  \n  Provides utility functions for bit manipulation, hexadecimal conversion, and CRC8 calculation.\n\n- **tests**  \n  Unit tests for verifying the functionality of the library.\n\n- **examples**  \n  Example scripts demonstrating different use cases:\n  - `example1.py`: Discover sensors and continuously read temperatures until interrupted.\n  - `example2.py`: Record sensor samples to a SQL database (SQLite or PostgreSQL) using SQLAlchemy.\n  - `example3.py`: Configure sensor settings such as precision and alarm thresholds.\n\n## Installation\n\n1. **Clone the repository:**\n    ```bash\n    git clone https://github.com/electromake/usb-thermometer-python.git\n    cd usb-thermometer-python\n    ```\n\n2. **Install required dependencies:**\n    ```bash\n    pip install pyserial sqlalchemy\n    # If you would like to run SQL example, run also:\n    pip install sqlalchemy\n    ```\n\n## Usage\n\n### Example 1: Continuous Temperature Reading\n\nDiscover all sensors and continuously read their temperatures until a keyboard interrupt (Ctrl+C) is detected.\n```bash\npython example1.py\n```\n### Example 2: Storing Sensor Samples in a Database\nDiscover sensors and store temperature samples (with timestamps) in a SQL database. The database contains two tables: one for sensor details (ROM codes) and one for temperature samples.\n```bash\npython example2.py\n```\n### Example 3: Configuring Sensor Settings\nConfigure sensor settings by adjusting measurement precision and alarm thresholds. The example shows how to write new settings to the sensor's scratchpad and verify them.\n```bash\npython example3.py\n```\n\n### Testing\nTo run the unit tests, execute:\n```bash\npython -m unittest discover\n```\n\n### More resources\n- [DS18B20 Datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/DS18B20.pdf)  \n- [1-wire serial port implementation](https://www.analog.com/en/resources/technical-articles/using-a-uart-to-implement-a-1wire-bus-master.html)  \n\n### Author\nElectromake  \n[https://electromake.pl/](https://electromake.pl) ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectromake%2Fusb-thermometer-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felectromake%2Fusb-thermometer-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectromake%2Fusb-thermometer-python/lists"}