{"id":22718457,"url":"https://github.com/lemariva/upym5ble","last_synced_at":"2025-04-13T17:51:45.394Z","repository":{"id":55988952,"uuid":"237674240","full_name":"lemariva/uPyM5BLE","owner":"lemariva","description":"This project is about using the BLE module of an M5Stack running MicroPython","archived":false,"fork":false,"pushed_at":"2020-12-02T16:56:03.000Z","size":281,"stargazers_count":21,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T08:48:15.323Z","etag":null,"topics":["bluetooth","m5stack","micropython"],"latest_commit_sha":null,"homepage":"https://lemariva.com/blog/2020/02/m5stack-micropython-and-bluetooth-ble","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemariva.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}},"created_at":"2020-02-01T20:34:47.000Z","updated_at":"2025-01-09T21:27:22.000Z","dependencies_parsed_at":"2022-08-15T10:50:55.971Z","dependency_job_id":null,"html_url":"https://github.com/lemariva/uPyM5BLE","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyM5BLE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyM5BLE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyM5BLE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyM5BLE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemariva","download_url":"https://codeload.github.com/lemariva/uPyM5BLE/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248758331,"owners_count":21156957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bluetooth","m5stack","micropython"],"created_at":"2024-12-10T14:11:16.867Z","updated_at":"2025-04-13T17:51:45.372Z","avatar_url":"https://github.com/lemariva.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uPyM5BLE\nThis project is about using the BLE module of an M5Stack running MicroPython. \n\nThe [M5Stack official](https://github.com/m5stack/M5Stack_MicroPython) and [LoBo](https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/) MicroPython stacks still do not support BLE. However, the [official firmware version](http://micropython.org/download#esp32) built with ESP-IDF v4.x has support for BLE (but no for LAN or PPP). \n\nThis project is a code example, which reads the IMU information (in my case an [MPU9250](https://www.invensense.com/products/motion-tracking/9-axis/mpu-9250/) -this varies depending on the M5Stack version) and the button states, and then publishes and notifies the values using BLE. Furthermore, it offers a write position, which controls the display state (on/off). \n\n## MicroPython\nDownload the version [GENERIC-SPIRAM (built with ESP-IDF v4.x)](http://micropython.org/resources/firmware/esp32spiram-idf4-20191220-v1.12.bin) -for M5Stacks with 16MB RAM- and program your board using the [esptool.py](https://github.com/espressif/esptool) program. If you are flashing MicroPython on your board for the first time then you should first erase the entire flash using:\n\n```\nesptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash\n```\nThen, program the firmware starting at address 0x1000 using e.g.:\n\n```\nesptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32spiram-idf4-20191220-v1.12.bin\n```\n\n## Upload the Project\nClone the repository using:\n```\ngit clone --recursive https://github.com/lemariva/uPyM5BLE.git\n```\nand use [VSCode](https://code.visualstudio.com/) and the PyMakr extension to upload the project to the M5Stack. A tutorial is available [here](https://lemariva.com/blog/2018/12/micropython-visual-studio-code-as-ide).\n\n## Read and write data from/to the device\nThe device can have a fixed MAC address (e.g. PYBD) or a random address (e.g. ESP32). Thus, to connect to the M5Stack, I use the [BLE Scanner](https://play.google.com/store/apps/details?id=com.macdom.ble.blescanner\u0026hl=de). The application searches for BLE devices, and lets you read data (see Fig. 1) and write values (see Fig. 2). Additionally, you can see the MAC address of the device (see Fig. 3). \n\nThe read values included in this example are from:\n* 3-axis accelerometer - 3 shorts \u0026 accuracy 0.01g\n* 3-axis magnetometer - 3 ints \u0026 accuracy 0.01uT\n* 3-axis gyroscope - 3 ints \u0026 accuracy 0.01°/s\n* Temperature sensor - 1 short \u0026 accuracy 0.01°C\n* Button A, B and C states.\n\n| |\n|:--|\n|![BLE Scanner](images/ble_scanner_read.png?raw=true \"BLE Scanner\")|\n|Fig. 1: BLE Scanner Application - Reading data from the M5Stack|\n\n| |\n|:--|\n|![BLE Scanner](images/ble_scanner_write.png?raw=true \"BLE Scanner\")|\n|Fig. 2: BLE Scanner Application - Writing a variable value|\n\n| |\n|:--|\n|![BLE Scanner](images/ble_scanner_mac.png?raw=true \"BLE Scanner\")|\n|Fig. 2: BLE Scanner Application - Getting Device MAC address|\n\n## Extra \n\nOther examples are included inside the folder `ble_examples`. These were taken from the [MicroPython official repository](https://github.com/micropython/micropython/tree/master/examples/bluetooth).\n\nAdditional information about the `ubluetooth` module can be found [here](https://docs.micropython.org/en/latest/library/ubluetooth.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemariva%2Fupym5ble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemariva%2Fupym5ble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemariva%2Fupym5ble/lists"}