Files
AI-on-the-edge-device-docs/Installation/index.html
2023-01-06 22:21:58 +00:00

382 lines
22 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><link rel="canonical" href="https://jomjol.github.io/AI-on-the-edge-device-docs/Installation/" />
<link rel="shortcut icon" href="../img/favicon.ico" />
<title>Installation - AI on the Edge Device</title>
<link rel="stylesheet" href="../css/theme.css" />
<link rel="stylesheet" href="../css/theme_extra.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
<script>
// Current page data
var mkdocs_page_name = "Installation";
var mkdocs_page_input_path = "Installation.md";
var mkdocs_page_url = "/AI-on-the-edge-device-docs/Installation/";
</script>
<script src="../js/jquery-3.6.0.min.js" defer></script>
<!--[if lt IE 9]>
<script src="../js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<img src=https://jomjol.github.io/AI-on-the-edge-device-docs//img/logo.png>
<a href=".." class="icon icon-home"> AI on the Edge Device
</a><div role="search">
<form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption"><span class="caption-text">Getting Started</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="..">Welcome</a>
</li>
<li class="toctree-l1 current"><a class="reference internal current" href="./">Installation</a>
<ul class="current">
<li class="toctree-l2"><a class="reference internal" href="#hardware">Hardware</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#esp32-cam">ESP32-CAM</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#usb-uart-interface">USB-&gt;UART interface</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#power-supply">Power supply</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#housing">Housing</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#wiring">Wiring</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#firmware-flashing">Firmware flashing</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#files">Files</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#flashing">Flashing</a>
<ul>
<li class="toctree-l4"><a class="reference internal" href="#1-web-installer">1. Web Installer</a>
</li>
<li class="toctree-l4"><a class="reference internal" href="#2-using-the-flash-tool-from-espressif">2. Using the Flash Tool from Espressif</a>
</li>
<li class="toctree-l4"><a class="reference internal" href="#3-using-esptool-in-python-directly">3. Using esptool in python directly</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#sd-card">SD-Card</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#notes">Notes</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#wlan">WLAN</a>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Hardware-Compatibility/">Hardware Compatibility</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Best-Practice/">Best Practice</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../FAQs/">Frequently Asked Questions</a>
</li>
</ul>
<p class="caption"><span class="caption-text">External Links</span></p>
<ul>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/releases">Releases</a>
</li>
<li class="toctree-l1"><a class="" href="https://jomjol.github.io/AI-on-the-edge-device/index.html">Web Installer/Console</a>
</li>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/issues">Place an Issues</a>
</li>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/discussions">Join a Discussions</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Configuration</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../ROI-Configuration/">ROI (Region of Interest)</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Graphical-Configuration/">Graphical Configuration</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Choosing-the-Model/">Model Selection</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Neural-Network-Types/">Neural Network Types</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../ota/">Over-The-Air (OTA) Update</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Advanced</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Integration-Home-Assistant/">Integration into Home Assistant</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../External-LED/">External LED</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../rolling-installation/">Living on the edge</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Configuration-Parameter-Details/">Configuration Parameter Details</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Configuration/">Configuration</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Watermeter-specific-analog---digital-transition/">Analog/Digital Transition on Watermeters</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Learn-models-with-your-own-images/">Learn a model with your own images</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Correction%20Algorithm/">Correction Algorithm</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Additional-Information/">Additional Information</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Troubleshooting</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Error-Codes/">Error Codes</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Error-Debugging/">Error Debugging</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Frequent-Reboots/">Frequent Reboots</a>
</li>
</ul>
<p class="caption"><span class="caption-text">API's</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../REST-API/">REST API</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../MQTT-API/">MQTT API</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Influx-DB/">Influx DB</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Build-Instructions/">Build the Project</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Demo-Mode/">Demo Mode</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Upload-files-by-script/">Scripted File Upload</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Testing/">Testing</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Release-creation/">Preparing for Release</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Old Pages (no longer maintained)</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../outdated--Integrated-Functions/">Integrated Functions</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../outdated--Gasmeter-Log-Downloader/">Gasmeter Log-Downloader</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../outdated--Migrate-Old-Config-To-New-Config/">Migration from water-meter „old“ to water-meter “AI-on-the-edge-device”</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Asorted Pages</span></p>
<ul>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="..">AI on the Edge Device</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href=".." class="icon icon-home" alt="Docs"></a> &raquo;</li>
<li>Getting Started &raquo;</li>
<li>Installation</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs/edit/main/docs/Installation.md" class="icon icon-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">
<h1 id="installation">Installation</h1>
<p>The installation requires multiple steps:</p>
<ol>
<li>Get the right hardware and wire it up</li>
<li>Flash the firmware onto the ESP32</li>
<li>Write the data to the SD-Card</li>
<li>Insert the SD-Card into the ESP32 board</li>
<li>Power/restart it. </li>
</ol>
<h2 id="hardware">Hardware</h2>
<h4 id="esp32-cam">ESP32-CAM</h4>
<ul>
<li>OV2640 camera module</li>
<li>Micro SD-Card slot </li>
<li>4 or 8 MB PSRAM. </li>
</ul>
<p>It can be easily found on the typical internet stores, searching for ESP32-CAM for less than 10 EUR.
How ever since the hardware is cheap and coming from China, you unluckily could pick a malfunction device. See <a href="../Hardware-Compatibility">Hardware Compatibility</a> for further advice! </p>
<h4 id="usb-uart-interface">USB-&gt;UART interface</h4>
<p>For first time flashing the firmware a USB -&gt; UART connector is needed. Later firmware upgrades than can be flashed via OTA.</p>
<h4 id="power-supply">Power supply</h4>
<p>For power supply a 5V source is needed. Most easily this can be done via an USB power supply. The power supply should support minimum 500mA. For buffering current peaks some users reported to use a large elco condensator like a 2200uF between ground and VCC.</p>
<p><strong>‼️ Attention:</strong> in several internet forums there are problems reported, in case the ESP32-CAM is only supplied with 3.3V.</p>
<h4 id="housing">Housing</h4>
<p>A small 3D-printable example for a very small case can be found in Thingiverse here: <a href="https://www.thingiverse.com/thing:4571627">https://www.thingiverse.com/thing:4571627</a></p>
<p><img alt="" src="../img/main.jpg" style="width:200px" />
<img alt="" src="../img/size.png" style="width:200px" /></p>
<p><strong>‼️ Attention</strong>: the focus of the OV2640 needs to be adjusted, as it is normally set from ~40cm to infinity. In order to get an image that is big enough, it needs to be changed to about 10cm. Therefore the sealing glue on the objective ring needs to be removed with a scalpel or sharp knife. Afterwards the objective can be rotated clockwise until the image is sharp again.</p>
<p><img alt="" src="../img/focus_adjustment.jpg" style="width:200px" /></p>
<h3 id="wiring">Wiring</h3>
<p>Beside the 5V power supply, only for the first flashing a connection to the USB-UART connector, including a short cut of GPIO0 to GND for bootloader start.</p>
<p>A example for wiring can be found here:</p>
<p><img alt="" src="../img/wiring.png" /></p>
<p><img alt="" src="../img/progammer_manual.jpg" /></p>
<p>It is also possible to use external LEDs for the illumination instead of the internal flash LED. This is described here: [[External-LED]]</p>
<h2 id="firmware-flashing">Firmware flashing</h2>
<h3 id="files">Files</h3>
<p>Grab the firmware from the</p>
<ul>
<li><a href="https://github.com/jomjol/AI-on-the-edge-device/releases">Releases page</a> (Stable, tested versions), or the</li>
<li><a href="https://github.com/jomjol/AI-on-the-edge-device/actions?query=branch%3Arolling">Automatically build development branch</a> (experimental, untested versions). Please have a look on https://github.com/jomjol/AI-on-the-edge-device/wiki/Install-a-rolling-%28unstable%29-release first!</li>
</ul>
<p>You need:</p>
<ul>
<li>partitions.bin</li>
<li>bootloader.bin</li>
<li>firmware.bin</li>
</ul>
<h3 id="flashing">Flashing</h3>
<p>There are several options to flash the firmware. Here three are described:</p>
<h4 id="1-web-installer">1. Web Installer</h4>
<p>There is a Web Installer available which will work right out of the web browser Edge and Chrome.
You can access it with the following link: https://jomjol.github.io/AI-on-the-edge-device</p>
<p>This is the preferred way for beginners as it also allows access to the USB Log:</p>
<p><a href="../img/web-console.png"><img alt="" src="../img/web-console.png" /></a></p>
<h4 id="2-using-the-flash-tool-from-espressif">2. Using the Flash Tool from Espressif</h4>
<p>The flashing of the firmware can be done with the "Flash Download Tool" from espressif, that can found <a href="https://www.espressif.com/en/support/download/other-tools">here</a> </p>
<p>Download and extract the Flash tool, after starting choose "Developer Mode", then "ESP32-DownloadTool" and you are in the setup of the flashing tool. Connect the ESP32-CAM with the USB-UART connection and identify the COM-Port. </p>
<p>‼️ <strong>Attention</strong>: if you reflashing the code again, it is strongly recommended to erase the flash memory before flashing the firmware. Especially if you used OTA in between, which might cause remaining information on the flash, to still boot from an old image in the OTA-area, which is not erased by a normal flash.</p>
<p>But your ESP32 in bootloader mode and push start, then it will identify the board and you can configure the bin-configuration according to the following table:</p>
<table>
<thead>
<tr>
<th>Filename</th>
<th align="right">Offset</th>
</tr>
</thead>
<tbody>
<tr>
<td>bootloader.bin</td>
<td align="right">0x1000</td>
</tr>
<tr>
<td>partitions.bin</td>
<td align="right">0x8000</td>
</tr>
<tr>
<td>firmware.bin</td>
<td align="right">0x10000</td>
</tr>
</tbody>
</table>
<p><img alt="" src="../img/Flash_Settings.png" /></p>
<p>Alternatively it can be directly flashed from the development environment - here PlatformIO. But this is rather for experienced users, as the whole development chain needs to be installed for compilation.</p>
<h4 id="3-using-esptool-in-python-directly">3. Using esptool in python directly</h4>
<p>For this you need a python environment (e.g. Anaconda in Win10).
Here you need to install the esptool:</p>
<pre><code>pip install esptool
</code></pre>
<p>Then connect the ESP32 with the USB-UART connector to the system, put it in bootmode and with the following command you can erase the flash and flash bootloader, partitions and firmware in two steps:</p>
<pre><code>esptool erase_flash
esptool write_flash 0x01000 bootloader.bin 0x08000 partitions.bin 0x10000 firmware.bin
</code></pre>
<ul>
<li>Maybe you need to specify the COM-port if it is not detected by default.</li>
<li>If the erase command throws the error <code>A fatal error occurred: ESP32 ROM does not support function erase_flash.</code>, your <code>esptool</code> might be too old, see https://techoverflow.net/2022/02/08/how-to-fix-esp32-a-fatal-error-occurred-esp32-rom-does-not-support-function-erase_flash/</li>
</ul>
<p>With some Python installations this may not work and youll receive an error, try <code>python -m pip install esptool</code> or <code>pip3 install esptool</code></p>
<p>Further recommendations can be found on the <a href="https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html">espressif webpage</a></p>
<h2 id="sd-card">SD-Card</h2>
<p>The program expects a SD-Card installed with certain directory and file structure in order to work properly.
For the first setup take the <code>initial_esp32_setup_*.zip</code> from the <a href="https://github.com/jomjol/AI-on-the-edge-device/releases">Release</a> page and extract the content of the contained <code>sd-card.zip</code> onto your SD-Card.</p>
<p>This must only be done once as further updates of the SD-Card are possible with the OTA Update.</p>
<h3 id="notes">Notes</h3>
<ul>
<li>Due to the limited availability of GPIOs (OV2640, Flash-Light, PSRAM &amp; SD-Card) the communication mode to the SD card is limited to 1-line SD-Mode. It showed up, that this results in problems with very large SD-Cards (64GB, sometimes 32 GB) and some no name low cost SD-cards.</li>
<li>There must be no partition table on the SD-card (no GPT, but only MBR for the single partition)</li>
<li>Following setting are necessary for formating the SD-card: <strong>SINGLE PARTITION, MBR, FAT32 - 32K. NOT exFAT</strong></li>
<li>Some ESP32 devices share their SD-card and/or camera GPIOs with the pins for TX and RX. If you see errors like “Failed to connect” then your chip is probably not entering the bootloader properly. Remove the respective modules temporarily to free the GPIOs for flashing. You may find more information about troubleshooting on the <a href="https://docs.espressif.com/projects/esptool/en/latest/esp8266/troubleshooting.html">homepage of Espressif</a>.</li>
</ul>
<p><strong>The ESP32 indicates problems with the SD card during startup with a fast not ending blinking.</strong>
<strong>In this case, please try another SD card.</strong> </p>
<h2 id="wlan">WLAN</h2>
<p>The access to the WLAN is configured in the "wlan.ini" directly on the root directory of the sd-card. Just write the corresponding SSID and password before the startup of the ESP32. This file is hidden from external access (e.g. via Filemanager) to protect the password.</p>
<p>After power on the connection status is indicated by 3x blinking of the red on board LED.</p>
<p>WLAN-Status indication:</p>
<ul>
<li><strong>5 x</strong> fast blinking (&lt; 1 second): connection still pending</li>
<li><strong>3 x</strong> slow blinking (1 second on/off): WLAN connection established</li>
</ul>
<p>It is normal that at first one or two times a pending connection is indicated.</p>
</div>
</div><footer>
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
<a href=".." class="btn btn-neutral float-left" title="Welcome"><span class="icon icon-circle-arrow-left"></span> Previous</a>
<a href="../Hardware-Compatibility/" class="btn btn-neutral float-right" title="Hardware Compatibility">Next <span class="icon icon-circle-arrow-right"></span></a>
</div>
<hr/>
<div role="contentinfo">
<!-- Copyright etc -->
</div>
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" role="note" aria-label="Versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span>
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs" class="fa fa-github" style="color: #fcfcfc"> GitHub</a>
</span>
<span><a href=".." style="color: #fcfcfc">&laquo; Previous</a></span>
<span><a href="../Hardware-Compatibility/" style="color: #fcfcfc">Next &raquo;</a></span>
</span>
</div>
<script>var base_url = '..';</script>
<script src="../js/theme_extra.js" defer></script>
<script src="../js/theme.js" defer></script>
<script src="../search/main.js" defer></script>
<script defer>
window.onload = function () {
SphinxRtdTheme.Navigation.enable(true);
};
</script>
</body>
</html>