{"id":18077404,"url":"https://github.com/parisneo/bleak_ble_tools","last_synced_at":"2026-02-25T20:05:45.197Z","repository":{"id":98194770,"uuid":"588091784","full_name":"ParisNeo/Bleak_BLE_tools","owner":"ParisNeo","description":"A set of tools to use bluetooth devices with python","archived":false,"fork":false,"pushed_at":"2023-01-12T15:21:30.000Z","size":38,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-19T21:46:20.557Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ParisNeo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-01-12T09:59:20.000Z","updated_at":"2023-10-09T10:28:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"528f0a99-8d90-49e2-b93f-1aad5b1183d3","html_url":"https://github.com/ParisNeo/Bleak_BLE_tools","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ParisNeo/Bleak_BLE_tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FBleak_BLE_tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FBleak_BLE_tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FBleak_BLE_tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FBleak_BLE_tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ParisNeo","download_url":"https://codeload.github.com/ParisNeo/Bleak_BLE_tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2FBleak_BLE_tools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29837546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T19:08:47.527Z","status":"ssl_error","status_checked_at":"2026-02-25T18:59:04.705Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-31T11:24:45.782Z","updated_at":"2026-02-25T20:05:45.178Z","avatar_url":"https://github.com/ParisNeo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BLE Data Logger\n\n[![GitHub release](https://badgen.net/github/release/ParisNeo/Bleak_BLE_tools)](https://github.com/ParisNeo/Bleak_BLE_tools/releases)\n[![GitHub license](https://badgen.net/github/license/ParisNeo/Bleak_BLE_tools)](https://github.com/ParisNeo/Bleak_BLE_tools/blob/master/LICENSE)\n\nFile: logger.py\n\nAuthor: Saifeddine ALOUI + ChatGPT\n## Description\nThis script uses the Bleak library to connect to a BLE device and logs data from a specific characteristic of the device. The logged data is saved to a CSV file. The script supports two modes:\n\nNotification mode: The script subscribes to notifications from the characteristic and logs the data as it is received. The logging can be stopped by pressing 'q'.\nPolling mode: The script periodically reads the characteristic and logs the data. This mode can be used when the characteristic does not support notifications.\nInstallation\nThe script requires the following libraries:\n\n- asyncio\n- argparse\n- bleak\n- struct\nTo install these libraries, use the following command:\n\n```bash\npip install asyncio argparse bleak struct\n```\n## Usage\nThe script can be run from the command line by providing the following arguments:\n\n- mac_address: The MAC address of the device.\n- service_uuid: The UUID of the service that the characteristic belongs to.\n- characteristic_uuid: The UUID of the characteristic to log data from.\n- -p, --path: The path to the CSV file to be created. Default is ./log.csv.\n- -t, --timeout: The timeout in seconds for the BLE device to respond. Default is 5.0.\n- -f, --force_read: Forces the script to use polling mode even if the characteristic supports notifications.\n- -e, --entry_format: The format of the data, defaults to '\u003cHiii' (little endian, short, 3 ints)\n- -h, --file_header: The header of the csv file, defaults to \"timestamp, acc_x, acc_y, acc_z\"\n\n```bash\npython logger.py \u003cmac_address\u003e \u003cservice_uuid\u003e \u003ccharacteristic_uuid\u003e [-p \u003cfile_path\u003e] [-t \u003ctimeout\u003e] [-f] [-e \u003centry_format\u003e] [-h \u003cfile_header\u003e]\n```\n\n## Customization explaining\nThe end user can control the file header and the data format through the call arguments of the script logger.py. The arguments file_header and entry_format allow the user to specify the format of the data and the header of the csv file respectively.\n\nFor example, if the user wants to log data from a temperature sensor that sends data in the format of a float in degrees Celsius, the user can set file_header to \"timestamp, temperature (C)\" and entry_format to '\u003cHf' (little endian, short, float). Assuming a service uuid of 1234 and characteristic 5678, the user can then run the script with these arguments:\n```bash\npython logger.py -a \"AA:BB:CC:DD:EE:FF\" \"1234\" \"5678\" -p \"./temperature.csv\" -H \"timestamp, temperature (C)\" -F '\u003cHf'\n```\nAnother example, if the user wants to log data from an accelerometer sensor that sends data in the format of 3 integers representing the X, Y, and Z axis values respectively, the user can set file_header to \"timestamp, acc_x, acc_y, acc_z\" and entry_format to '\u003cHiii' (little endian, short, 3 ints). The user can then run the script with these arguments:\n\n```bash\npython logger.py -a \"AA:BB:CC:DD:EE:FF\" \"1234\" \"5678\" -p \"./accelerometer.csv\" -H \"timestamp, acc_x, acc_y, acc_z\" -F '\u003cHiii'\n```\n\nIt is important to note that the entry_format argument should be set according to the data format of the sensor and the file_header argument should match the format of the data in the entry_format argument.\n\n## Other examples\nLog data from the accelerometer that sends data in format timestamp:uint16,accx:int32,accy:int32,accz:int32 through service (UUID: 0xABCD)  characteristic (UUID: 0xABCD) of a device with MAC address 12:34:56:78:90:AB and save the data to ./accelerometer.csv:\n```bash\npython logger.py 12:34:56:78:90:AB 0xABCD 0xABCD  -p ./accelerometer.csv -H \"timestamp, acc_x, acc_y, acc_z\" -F \"\u003cHiii\"\n```\n\n## Note\n`For some devices, the notification mode may not work. In this case, you can use the polling mode by adding -f to the request. This will force using the read method instead of notification.`\n\n\n## Exeting the application\nTo exit the application, you just need to press q.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisneo%2Fbleak_ble_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparisneo%2Fbleak_ble_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisneo%2Fbleak_ble_tools/lists"}