{"id":15369157,"url":"https://github.com/developit/espz","last_synced_at":"2025-04-15T13:43:28.503Z","repository":{"id":143374696,"uuid":"326830210","full_name":"developit/espz","owner":"developit","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-18T03:26:39.000Z","size":193,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T11:16:07.368Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/developit.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}},"created_at":"2021-01-04T23:13:14.000Z","updated_at":"2024-12-28T04:05:41.000Z","dependencies_parsed_at":"2023-09-14T01:30:25.073Z","dependency_job_id":null,"html_url":"https://github.com/developit/espz","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":"0.19999999999999996","last_synced_commit":"22e0f6d0cfb012df0a8cfdfe9585db1c2f5312c7"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fespz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fespz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fespz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fespz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developit","download_url":"https://codeload.github.com/developit/espz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249082102,"owners_count":21209807,"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":[],"created_at":"2024-10-01T13:34:27.447Z","updated_at":"2025-04-15T13:43:28.485Z","avatar_url":"https://github.com/developit.png","language":"JavaScript","readme":"# espz\n\nhttps://npmjs.com/pacakge/espz\n\n`espz` is a simple CLI for interacting with Espruino devices.\n\nBoth the REPL and flasher run your code through Babel to add modern syntax support with minimal overhead.\n\nFlashed code is bundled and optimized via Rollup and Terser, so you can use ES Modules.\n\n## Getting Started\n\nIn order to use this tool, you need to first flash Espruino onto your ESP8266:\n\n1. Download the firmware files from [espruino.com/EspruinoESP8266](http://www.espruino.com/EspruinoESP8266#firmware-updates)\n\n2. Plug in your device using a USB cable that supports data (it's ridiculous how many of them don't)\n\n3. Flash the firmware according to [these instructions](http://www.espruino.com/ESP8266_Flashing). For example, if you're on MacOS:\n    \n     ```sh\n    esptool.py --port /dev/tty.usbserial-* --baud 115200 write_flash --flash_freq 80m --flash_mode dio --flash_size 32m \\\n    0x0000 \"boot_v1.6.bin\" 0x1000 espruino_esp8266_user1.bin 0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin\n    ```\n\n4. You can now send code to the device or [access a REPL](#repl) using espz.\n\n5. Once you've flashed code that [connects to your wifi network](https://github.com/developit/espz/blob/f3303ea279c9ed18cab313daca8e6e29076f359c/demo/homectrl/index.js#L97-L119), you can send code or launch the REPL over wifi via `--address HOSTNAME_OR_IP`.\n\n## Usage\n\n### REPL\n\nThe REPL is just like Espruino's REPL, except that it supports ES2017.\n\n\u003e **Note:** `Ctrl+C` sends a reset signal, which will destroy any currently-executing timers and event handlers.\n\u003e I'll probably change this at some point because it's rarely desirable.\n\u003e For now, just type `exit` and hit enter to leave the REPL without sending a reset.\n\n```sh\n# connect to a local device:\nespz repl --address /dev/cu.usbserial*\n\n# connect to an ESP8266 over TCP:\nespz repl --address 192.168.55.200\n```\n\n### Compile and execute code on device\n\nThere are two options here: run the code immediately, or flash the code to `.bootcde` so that it runs on boot. Personally I find the latter more useful and reliable.\n\n**Compile a module and run it on the device:**\n\n```sh\nespz send --address 192.168.55.200 src/index.js\n```\n\n**Compile a module and flash it as the device's boot code, then restart:**\n\n```sh\nespz send --boot --address 192.168.55.200 src/index.js\n\n# you can also re-connect to the REPL after rebooting:\nespz send --boot --tail --address 192.168.55.200 src/index.js\n```\n\n### Compile code for your device to a local file on disk\n\nI'm not sure why you'd ever use this, but if you want to compile code based on a connected device and then store it on your computer rather than flashing it:\n\n```sh\nespz build --address 192.168.55.200 src/index.js --out out.js\n```\n\n### Writing files to the device's flash storage\n\nThis is the manual way to add files, not usually important.\n\n```sh\nespz write --address 192.168.55.200 index.html favicon.ico\n```\n\n## CLI Usage\n\n```sh\nUsage\n$ espz \u003ccommand\u003e [options]\n\nAvailable Commands\nbuild    Compile modern JS modules for espruino\nsend     Compile and send modules to espruino\ninfo     Print device information\nrepl     Start Espruino REPL for the device\nwrite    Write file to device storage\n\nFor more info, run any command with the `--help` flag\n$ espz build --help\n$ espz send --help\n\nOptions\n--address        TCP host to connect to (espruino.local:23)  (default espruino.local:23)\n-v, --version    Displays current version\n-h, --help       Displays this message\n```\n\n## Example Application\n\n`espz` includes ambient TypeScript definitions for Espruino's APIs and modules, which extend the official Espruino types with a bunch of things they're missing. The only thing that can be unclear from reading Espruino's docs and the TypeScript defintions is how best to initialize your code, since the technique varies depending on how you choose to flash (as boot code, versus executing the code immediately).\n\nMy recommendation is to flash to bootcode via `espz send --boot --tail --address x:x:x:x`, and use `E.on('init')` to initialize your application after a short delay:\n\n```js\nimport Wifi from 'Wifi';\n\nfunction start() {\n\t// put your startup logic in here.\n\tWifi.connect('foo', { password: 'bar' }, (err) =\u003e {\n\t\tWifi.save();\n\t\t// etc\n\t});\n}\n\ntry {\n\tE.on('init', () =\u003e setTimeout(start, 1000));\n} catch (e) {}\n```\n\n\u003e **Side Note:** the `.on()` mixin used by Espruino's API's doesn't seem to support multiple event handlers like it would imply. Register stuff up-front and delegate in your code instead.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fespz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopit%2Fespz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fespz/lists"}