index.html 15 KB

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