{"id":16281257,"url":"https://github.com/carglglz/upydevice","last_synced_at":"2025-10-07T15:40:45.598Z","repository":{"id":35069203,"uuid":"202801075","full_name":"Carglglz/upydevice","owner":"Carglglz","description":"Python library to interface with MicroPython devices through Wifi (Websockets/WebREPL) , BLE or Serial connection (USB)","archived":false,"fork":false,"pushed_at":"2023-09-21T20:05:07.000Z","size":29754,"stargazers_count":17,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-24T21:20:16.083Z","etag":null,"topics":["ble","embedded","micropython","python","serial","webrepl","wifi"],"latest_commit_sha":null,"homepage":"","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/Carglglz.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","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":"2019-08-16T21:25:37.000Z","updated_at":"2024-03-05T16:11:02.000Z","dependencies_parsed_at":"2024-10-10T19:06:15.239Z","dependency_job_id":"768b7eaf-f664-404a-81c6-8a3d47226e1e","html_url":"https://github.com/Carglglz/upydevice","commit_stats":{"total_commits":197,"total_committers":2,"mean_commits":98.5,"dds":0.005076142131979711,"last_synced_commit":"5c16af1d6f54aff88378b4597cce039b355e9291"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fupydevice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fupydevice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fupydevice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fupydevice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Carglglz","download_url":"https://codeload.github.com/Carglglz/upydevice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244533820,"owners_count":20467944,"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":["ble","embedded","micropython","python","serial","webrepl","wifi"],"created_at":"2024-10-10T19:06:10.371Z","updated_at":"2025-10-07T15:40:40.571Z","avatar_url":"https://github.com/Carglglz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uPydevice\n\n[![PyPI version](https://badge.fury.io/py/upydevice.svg)](https://badge.fury.io/py/upydevice)[![PyPI license](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/ansicolortags/)\n\nPython library to interface with MicroPython devices through REPL*:\n\n- Websockets/WebREPL (WiFi)\n- BleREPL (Bluetooth Low Energy)\n- Serial REPL (USB)\n\n\\*  *Device REPL must be accesible.*\n\nUpydevice allows to integrate device interaction from simple scripts to automated services,  test suites, command line interfaces or even GUI applications.\n\n### Install\n\n`pip install upydevice`  or `pip install --upgrade upydevice`\n\n#### Example usage:\n\n### DEVICE: `Device`\n\n```python\n\u003e\u003e\u003e from upydevice import Device\n```\n\nThis will return a Device based on address (first argument) type.\n\ne.g.\n\n### Serial (USB)\n\n```python\n\u003e\u003e\u003e esp32 = Device('/dev/cu.usbserial-016418E3', init=True)\n\u003e\u003e\u003e esp32\nSerialDevice @ /dev/cu.usbserial-016418E3, Type: esp32, Class: SerialDevice\nFirmware: MicroPython v1.19.1-285-gc4e3ed964-dirty on 2022-08-12; ESP32 module with ESP32\nCP2104 USB to UART Bridge Controller, Manufacturer: Silicon Labs\n(MAC: 30:ae:a4:23:35:64)\n```\n\n### WiFi (WebSockets/WebREPL)\n\nThis requires [WebREPL](http://docs.micropython.org/en/latest/esp8266/tutorial/repl.html#webrepl-a-prompt-over-wifi) to be enabled in the device.\n\n```python\n\u003e\u003e\u003e esp32 = Device('192.168.1.53', 'mypass', init=True)\n\u003e\u003e\u003e esp32\nWebSocketDevice @ ws://192.168.1.53:8266, Type: esp32, Class: WebSocketDevice\nFirmware: MicroPython v1.19.1-285-gc4e3ed964-dirty on 2022-08-12; ESP32 module with ESP32\n(MAC: 30:ae:a4:23:35:64, Host Name: espdev, RSSI: -45 dBm)\n```\n\nIf device hostname name is set e.g. (in device `main.py`)\n\n```python\n....\nwlan = network.WLAN(network.STA_IF)\nwlan.active(True)\nwlan.config(hostname='espdev')\nwlan.connect('your-ssid', 'your-key')\n...\n```\n\nNow the device can be connected with mDNS name.\n\n```python\n\u003e\u003e\u003e esp32 = Device('espdev.local', 'mypass', init=True)\n\u003e\u003e\u003e esp32\nWebSocketDevice @ ws://192.168.1.53:8266, Type: esp32, Class: WebSocketDevice\nFirmware: MicroPython v1.19.1-285-gc4e3ed964-dirty on 2022-08-12; ESP32 module with ESP32\n(MAC: 30:ae:a4:23:35:64, Host Name: espdev, RSSI: -45 dBm)\n```\n\n### BLE (BleREPL)\n\nThis requires [BleREPL](https://upydev.readthedocs.io/en/latest/gettingstarted.html) to be enabled in the device. (This is still experimental and performance may be platform and device dependent)\n\n```python\n\u003e\u003e\u003e esp32 = Device('00FEFE2D-5983-4D6C-9679-01F732CBA9D9', init=True)\n\u003e\u003e\u003e esp32\nBleDevice @ 00FEFE2D-5983-4D6C-9679-01F732CBA9D9, Type: esp32 , Class: BleDevice\nFirmware: MicroPython v1.18-128-g2ea21abae-dirty on 2022-02-19; 4MB/OTA BLE module with ESP32\n(MAC: ec:94:cb:54:8e:14, Local Name: espble, RSSI: -38 dBm)\n```\n\nNow the device can recive commands and send back the output. e.g.\n\n```python\n\u003e\u003e\u003e esp32.wr_cmd('led.on()')\n\u003e\u003e\u003e esp32.wr_cmd(\"os.listdir()\")\n['boot.py', 'webrepl_cfg.py', 'main.py'] # this output is stored in [upydevice].output\n\n\u003e\u003e\u003e esp32.output\n['boot.py', 'webrepl_cfg.py', 'main.py']\n\u003e\u003e\u003e\u003e esp32.wr_cmd('x = [1,2,3];my_var = len(x);print(my_var)')\n3\n# Soft Reset:\n\u003e\u003e\u003e esp32.reset()\n    Rebooting device...\n    Done!\n```\n\n### Testing devices with Pytest:\n\nUnder `test` directory there are example tests to run with devices. This allows to test MicroPython code in devices interactively, e.g. button press, screen swipes, sensor calibration, actuators, servo/stepper/dc motors ...\ne.g.\n\n```python\n$ pytest test_esp_serial.py -s\n\n=========================================== test session starts ===========================================\nplatform darwin -- Python 3.7.9, pytest-7.1.2, pluggy-1.0.0\nbenchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)\nrootdir: /Users/carlosgilgonzalez/Desktop/IBM_PROJECTS/MICROPYTHON/TOOLS/upydevice_.nosync/test, configfile: pytest.ini\nplugins: benchmark-3.4.1\ncollected 7 items\n\ntest_esp_serial.py::test_devname PASSED                                                             [ 14%]\ntest_esp_serial.py::test_platform\n---------------------------------------------- live log call ----------------------------------------------\n00:13:26 [pytest] [sdev] [ESP32] : Running SerialDevice test...\n00:13:26 [pytest] [sdev] [ESP32] : DEV PLATFORM: esp32\n00:13:26 [pytest] [sdev] [ESP32] : DEV PLATFORM TEST: [✔]\nPASSED                                                                                              [ 28%]\ntest_esp_serial.py::test_blink_led\n---------------------------------------------- live log call ----------------------------------------------\n00:13:28 [pytest] [sdev] [ESP32] : BLINK LED TEST: [✔]\nPASSED                                                                                              [ 42%]\ntest_esp_serial.py::test_run_script\n---------------------------------------------- live log call ----------------------------------------------\n00:13:28 [pytest] [sdev] [ESP32] : RUN SCRIPT TEST: test_code.py\n00:13:31 [pytest] [sdev] [ESP32] : RUN SCRIPT TEST: [✔]\nPASSED                                                                                              [ 57%]\ntest_esp_serial.py::test_raise_device_exception\n---------------------------------------------- live log call ----------------------------------------------\n00:13:31 [pytest] [sdev] [ESP32] : DEVICE EXCEPTION TEST: b = 1/0\n00:13:31 [pytest] [sdev] [ESP32] : DEVICE EXCEPTION TEST: [✔]\nPASSED                                                                                              [ 71%]\ntest_esp_serial.py::test_reset\n---------------------------------------------- live log call ----------------------------------------------\n00:13:31 [pytest] [sdev] [ESP32] : DEVICE RESET TEST\n00:13:32 [pytest] [sdev] [ESP32] : DEVICE RESET TEST: [✔]\nPASSED                                                                                              [ 85%]\ntest_esp_serial.py::test_disconnect\n---------------------------------------------- live log call ----------------------------------------------\n00:13:32 [pytest] [sdev] [ESP32] : DEVICE DISCONNECT TEST\n00:13:32 [pytest] [sdev] [ESP32] : DEVICE DISCONNECT TEST: [✔]\nPASSED                                                                                              [100%]\n\n============================================ 7 passed in 6.74s ============================================\n```\n\n### Made with upydevice:\n\n- [upydev](https://github.com/Carglglz/upydev)\n- [Jupyter_upydevice_kernel](https://github.com/Carglglz/jupyter_upydevice_kernel)\n\n## [Examples (scripts, GUI ...)](https://github.com/Carglglz/upydevice/tree/develop/examples)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarglglz%2Fupydevice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarglglz%2Fupydevice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarglglz%2Fupydevice/lists"}