index.html 13 KB

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