index.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <html>
  2. <head>
  3. <meta charset="utf-8" />
  4. <title>ESP Web Tools</title>
  5. <meta
  6. name="description"
  7. content="Easily allow users to flash new firmware for their ESP-devices on the web."
  8. />
  9. <meta name="viewport" content="width=device-width" />
  10. <meta property="og:title" content="ESP Web Tools" />
  11. <meta property="og:site_name" content="ESP Web Tools" />
  12. <meta
  13. property="og:url"
  14. content="https://esphome.github.io/esp-web-tools/"
  15. />
  16. <meta property="og:type" content="website" />
  17. <meta
  18. property="og:description"
  19. content="Easily allow users to flash new firmware for their ESP-devices on the web."
  20. />
  21. <meta
  22. property="og:image"
  23. content="https://esphome.github.io/esp-web-tools/static/social.png"
  24. />
  25. <meta name="twitter:card" content="summary_large_image" />
  26. <meta name="twitter:title" content="ESP Web Tools" />
  27. <meta
  28. name="twitter:description"
  29. content="Easily allow users to flash new firmware for their ESP-devices on the web."
  30. />
  31. <meta
  32. name="twitter:image"
  33. content="https://esphome.github.io/esp-web-tools/static/social.png"
  34. />
  35. <style>
  36. body {
  37. font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI",
  38. Roboto, Ubuntu, sans-serif;
  39. padding: 0;
  40. margin: 0;
  41. line-height: 1.4;
  42. }
  43. .content {
  44. max-width: 600px;
  45. margin: 0 auto;
  46. padding: 12px;
  47. }
  48. .project .logo {
  49. float: right;
  50. }
  51. .project .logo img {
  52. height: 50px;
  53. }
  54. a {
  55. color: #03a9f4;
  56. }
  57. .videoWrapper {
  58. position: relative;
  59. padding-bottom: 56.25%; /* 16:9 */
  60. height: 0;
  61. margin-bottom: 25px;
  62. background: #000;
  63. }
  64. .videoWrapper iframe {
  65. position: absolute;
  66. top: 0;
  67. left: 0;
  68. width: 100%;
  69. height: 100%;
  70. }
  71. .content pre {
  72. max-width: 100%;
  73. overflow-y: scroll;
  74. }
  75. .footer {
  76. margin-top: 24px;
  77. border-top: 1px solid #ccc;
  78. padding-top: 24px;
  79. text-align: center;
  80. }
  81. .footer .initiative {
  82. font-style: italic;
  83. margin-top: 16px;
  84. }
  85. table {
  86. border-spacing: 0;
  87. }
  88. td {
  89. padding: 8px;
  90. border-bottom: 1px solid #ccc;
  91. }
  92. @media (prefers-color-scheme: dark) {
  93. body {
  94. background-color: #333;
  95. color: #fff;
  96. }
  97. a {
  98. color: #58a6ff;
  99. }
  100. }
  101. </style>
  102. <script module>
  103. import(
  104. // In development we import locally.
  105. window.location.hostname === "localhost"
  106. ? "/dist/web/install-button.js"
  107. : "https://unpkg.com/esp-web-tools@4.0.0/dist/web/install-button.js?module"
  108. );
  109. </script>
  110. </head>
  111. <body>
  112. <div class="content">
  113. <h1>ESP Web Tools</h1>
  114. <p>
  115. ESP Web Tools is a set of open source tools to allow working with ESP
  116. devices in the browser.
  117. <a href="https://github.com/esphome/esp-web-tools"
  118. >The code is available on GitHub.</a
  119. >
  120. </p>
  121. <p>
  122. To try it out and install
  123. <a href="https://esphome.io">ESPHome</a> on an ESP, connect it to your
  124. computer and hit the button:
  125. </p>
  126. <esp-web-install-button
  127. log-console
  128. erase-first
  129. manifest="static/firmware_build/manifest.json"
  130. ></esp-web-install-button>
  131. <p>
  132. <i>
  133. Note, this only works in desktop Chrome and Edge. Android support
  134. should be possible but has not been implemented yet. If you don't see
  135. your ESP device, you might miss <a href="#drivers">drivers</a>.
  136. </i>
  137. </p>
  138. <p>
  139. This works by combining
  140. <a
  141. href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API"
  142. >Web Serial</a
  143. >
  144. with a manifest which describes the firmware. It will automatically
  145. detect the type of the connected ESP device and find the right firmware
  146. files in the manifest.
  147. </p>
  148. <div class="videoWrapper">
  149. <iframe
  150. width="560"
  151. height="315"
  152. src="https://www.youtube-nocookie.com/embed/k88BS8zgWq0"
  153. title="YouTube video player"
  154. frameborder="0"
  155. allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  156. allowfullscreen
  157. ></iframe>
  158. </div>
  159. <h2 id="used-by">Projects using ESP Web Tools</h2>
  160. <div class="project">
  161. <a href="https://wled.me" class="logo"
  162. ><img src="static/logos/wled.png" alt="WLED logo"
  163. /></a>
  164. <h3>WLED</h3>
  165. <p>
  166. A fast and feature-rich implementation of an ESP8266/ESP32 firmware to
  167. control NeoPixel (WS2812B, WS2811, SK6812) LEDs or also SPI based
  168. chipsets like the WS2801 and APA102.
  169. </p>
  170. <p>
  171. <a href="https://install.wled.me" target="_blank"
  172. >Installation Website</a
  173. >
  174. </p>
  175. </div>
  176. <div class="project">
  177. <a href="https://tasmota.github.io" class="logo"
  178. ><img src="static/logos/tasmota.svg" alt="Tasmota logo"
  179. /></a>
  180. <h3>Tasmota</h3>
  181. <p>
  182. Alternative firmware for ESP8266 with easy configuration using webUI,
  183. OTA updates, automation using timers or rules, expandability and
  184. entirely local control over MQTT, HTTP, Serial or KNX.
  185. </p>
  186. <p>
  187. <a href="https://arendst.github.io/Tasmota-firmware/" target="_blank"
  188. >Installation Website</a
  189. >
  190. </p>
  191. </div>
  192. <div class="project">
  193. <a href="http://www.espeasy.com/" class="logo"
  194. ><img src="static/logos/espeasy.png" alt="ESPEasy logo"
  195. /></a>
  196. <h3>ESPEasy</h3>
  197. <p>Easy MultiSensor device based on ESP8266/ESP32.</p>
  198. <p>
  199. <a href="https://td-er.nl/ESPEasy/" target="_blank"
  200. >Installation Website</a
  201. >
  202. </p>
  203. </div>
  204. <h2 id="add-website">Adding ESP Web Tools to your website</h2>
  205. <p>
  206. To add this to your own website, create a manifest and add the button to
  207. your website. Make sure you update the manifest attribute to point at
  208. your manifest.
  209. </p>
  210. <p>
  211. You can import ESP Web Tools directly from the unpkg CDN or
  212. <a href="https://unpkg.com/browse/esp-web-tools/dist/web/"
  213. >download the files</a
  214. >
  215. and put them on your website.
  216. </p>
  217. <pre>
  218. &lt;script
  219. type="module"
  220. src="https://unpkg.com/esp-web-tools@4.0.0/dist/web/install-button.js?module"
  221. >&lt;/script>
  222. &lt;esp-web-install-button
  223. manifest="static/firmware_build/manifest.json"
  224. >&lt;/esp-web-install-button></pre
  225. >
  226. <p>
  227. Your website needs to be served over <code>https://</code>. If your
  228. manifest is hosted on another server, make sure you configure
  229. <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS"
  230. >the CORS-headers</a
  231. >
  232. for your manifest and firmware files such that your website is allowed
  233. to fetch those files by adding the header
  234. <code
  235. >Access-Control-Allow-Origin: https://domain-of-your-website.com</code
  236. >.
  237. </p>
  238. <p>
  239. Add the attribute <code>erase-first</code> if you want to first fully
  240. erase the ESP prior to installation.
  241. </p>
  242. <p>
  243. ESP Web Tools can also be integrated in your projects by installing it
  244. via NPM:<br />
  245. <code>npm install --save esp-web-tools</code>
  246. </p>
  247. <h3 id="manifest">Creating your manifest</h3>
  248. <p>
  249. ESP Web Tools manifest describe the firmware that you want to install.
  250. It allows specifying different builds for the different types of ESP
  251. devices. Current supported chip families are <code>ESP8266</code>,
  252. <code>ESP32</code>, <code>ESP32C3</code> and <code>ESP32S2</code>. The
  253. correct build will be automatically selected based on the type of the
  254. ESP device we detect via the serial port.
  255. </p>
  256. <pre>
  257. {
  258. "name": "ESPHome",
  259. "version": "2021.11.0",
  260. "builds": [
  261. {
  262. "chipFamily": "ESP32",
  263. "parts": [
  264. { "path": "bootloader.bin", "offset": 4096 },
  265. { "path": "partitions.bin", "offset": 32768 },
  266. { "path": "ota.bin", "offset": 57344 },
  267. { "path": "firmware.bin", "offset": 65536 }
  268. ]
  269. },
  270. {
  271. "chipFamily": "ESP8266",
  272. "parts": [
  273. { "path": "esp8266.bin", "offset": 0 }
  274. ]
  275. }
  276. ]
  277. }</pre
  278. >
  279. <p>
  280. Each build contains a list of parts to be flashed to the ESP device.
  281. Each part consists of a path to the file and an offset on the flash
  282. where it should be installed. Part paths are resolved relative to the
  283. path of the manifest, but can also be URLs to other hosts.
  284. </p>
  285. <h3 id="improv">Wi-Fi provisioning</h3>
  286. <p>
  287. ESP Web Tools has support for the
  288. <a href="https://www.improv-wifi.com/serial"
  289. >Improv Wi-Fi serial standard</a
  290. >. This is an open standard to allow configuring Wi-Fi via the serial
  291. port.
  292. </p>
  293. <p>
  294. If Improv is supported, a user will be guided to connect the device to
  295. the network after installation. It also allows the user to connect
  296. already installed devices and re-configure the wireless network
  297. settings.
  298. </p>
  299. <p>TODO EXAMPLE VIDEO</p>
  300. <!-- <p>
  301. Each build also allows you to specify if it supports
  302. <a href="https://www.improv-wifi.com">the Improv Wi-Fi standard</a>. If
  303. it does, the user will be offered to configure the Wi-Fi after
  304. installation is done as can be seen in the video below.
  305. </p>
  306. <div class="videoWrapper">
  307. <iframe
  308. width="560"
  309. height="315"
  310. src="https://www.youtube-nocookie.com/embed/k88BS8zgWq0?start=33"
  311. title="YouTube video player"
  312. frameborder="0"
  313. allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  314. allowfullscreen
  315. ></iframe>
  316. </div> -->
  317. <h3 id="customize">Customizing the look and feel</h3>
  318. <p>
  319. There are multiple options to change the look and feel of the button and
  320. other elements.
  321. </p>
  322. <h4>Change colors</h4>
  323. <p>
  324. You can change the colors of the default UI elements with CSS custom
  325. properties (variables), the following variables are available:
  326. </p>
  327. <ul>
  328. <li><code>--esp-tools-button-color</code></li>
  329. <li><code>--esp-tools-button-text-color</code></li>
  330. <li><code>--esp-tools-success-color</code></li>
  331. <li><code>--esp-tools-error-color</code></li>
  332. <li><code>--esp-tools-progress-color</code></li>
  333. <li><code>--esp-tools-log-background</code></li>
  334. <li><code>--esp-tools-log-text-color</code></li>
  335. </ul>
  336. <p>There are also some attributes that can be used for styling:</p>
  337. <table>
  338. <tr>
  339. <td><code>install-supported</code></td>
  340. <td>Added if installing firmware is supported</td>
  341. </tr>
  342. <tr>
  343. <td>
  344. <code>install-unsupported</code>
  345. </td>
  346. <td>Added if installing firmware is not supported</td>
  347. </tr>
  348. <tr>
  349. <td><code>active</code></td>
  350. <td>Added when flashing is active</td>
  351. </tr>
  352. </table>
  353. <p>
  354. When you are using a custom button, you should disable it when the
  355. <code>active</code> attribute is present.
  356. </p>
  357. <h4>Replace the button and message with a custom one</h4>
  358. <p>
  359. You can replace both the activation button and the message that is shown
  360. when the user uses an unsupported browser or non-secure context with
  361. your own elements. This can be done using the <code>activate</code>,
  362. <code>unsupported</code> and <code>not-allowed</code> slots:
  363. </p>
  364. <pre>
  365. &lt;esp-web-install-button
  366. manifest="static/firmware_build/manifest.json"
  367. show-log
  368. erase-first
  369. >
  370. &lt;button slot="activate">Custom install button&lt;/button>
  371. &lt;span slot="unsupported">Ah snap, your browser doesn't work!&lt;/span>
  372. &lt;span slot="not-allowed">Ah snap, you are not allowed to use this on HTTP!&lt;/span>
  373. &lt;/esp-web-install-button>
  374. </pre
  375. >
  376. <h4>Show or hide the progress bar and log</h4>
  377. <p>
  378. By default there is a progress bar showing the state and progress of the
  379. flashing progress, you can change this progress bar to a log view with
  380. the <code>show-log</code> attribute.
  381. </p>
  382. <p>
  383. You can also hide all progress indicators by adding the
  384. <code>hide-progress</code>
  385. attribute. This will hide both the progress bar and the log view. You
  386. can then implement your own progress elements using the
  387. <a href="#state-events">state events</a>.
  388. </p>
  389. <h3 id="state-events">State events</h3>
  390. <p>
  391. During the flash progress the button will fire
  392. <code>state-changed</code> events for every step of the progress and to
  393. signal progress in the writing.
  394. </p>
  395. <p>
  396. With these events you can create your own progress UI or trigger certain
  397. actions. You can also find the current state as the
  398. <code>state</code> property of the
  399. <code>esp-web-install-button</code> element.
  400. </p>
  401. <p>Events for the following states are fired:</p>
  402. <ul>
  403. <li>initializing</li>
  404. <li>manifest</li>
  405. <li>preparing</li>
  406. <li>erasing</li>
  407. <li>writing</li>
  408. <li>finished</li>
  409. <li>error</li>
  410. </ul>
  411. <p>
  412. A <code>state-changed</code> event contains the following information:
  413. </p>
  414. <table>
  415. <tr>
  416. <td><code>state</code></td>
  417. <td>The current state; one of the above</td>
  418. </tr>
  419. <tr>
  420. <td><code>message</code></td>
  421. <td>A description of the current state</td>
  422. </tr>
  423. <tr>
  424. <td><code>manifest</code></td>
  425. <td>The loaded manifest</td>
  426. </tr>
  427. <tr>
  428. <td><code>build</code></td>
  429. <td>The manifest's build that was selected</td>
  430. </tr>
  431. <tr>
  432. <td><code>chipFamily</code></td>
  433. <td>
  434. The chip that was detected;
  435. <code>"ESP32" | "ESP8266" | "ESP32-S2" | "Unknown Chip"</code>
  436. </td>
  437. </tr>
  438. <tr>
  439. <td><code>details</code></td>
  440. <td>
  441. An optional extra field that is different
  442. <a
  443. href="https://github.com/esphome/esp-web-tools/blob/main/src/const.ts"
  444. >per state</a
  445. >
  446. </td>
  447. </tr>
  448. </table>
  449. <p>An example that logs all state events:</p>
  450. <pre>
  451. &lt;esp-web-install-button
  452. manifest="static/firmware_build/manifest.json"
  453. >&lt;/esp-web-install-button>
  454. &lt;script>
  455. const espWebInstallButton = document.querySelector("esp-web-install-button");
  456. espWebInstallButton.addEventListener(
  457. "state-changed", (ev) => { console.log(ev.detail) }
  458. );
  459. &lt;/script>
  460. </pre>
  461. <h3 id="drivers">USB Serial Drivers</h3>
  462. <p>
  463. If the serial port is not showing up, your computer might be missing the
  464. drivers for the USB serial chip used in your ESP device. These drivers
  465. work for most ESP devices:
  466. </p>
  467. <ul>
  468. <li>
  469. CP2102 (square chip):
  470. <a
  471. href="https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers"
  472. >driver</a
  473. >
  474. </li>
  475. <li>
  476. CH341:
  477. <a
  478. href="https://github.com/nodemcu/nodemcu-devkit/tree/master/Drivers"
  479. >driver</a
  480. >
  481. </li>
  482. </ul>
  483. <div class="footer">
  484. <div>
  485. ESP Web Tools –
  486. <a href="https://github.com/esphome/esp-web-tools">GitHub</a>
  487. </div>
  488. <div class="initiative">
  489. ESP Web Tools is a project by
  490. <a href="https://esphome.io">ESPHome</a>.<br />
  491. Development is funded by
  492. <a href="https://www.nabucasa.com">Nabu Casa</a>.
  493. </div>
  494. </div>
  495. </div>
  496. </body>
  497. </html>