<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title><![CDATA[Dobrica Pavlinušić's random unstructured stuff: ESP32CAM]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?esp32cam</link>
<description></description>
<pubDate>Tue, 06 Aug 2024 10:06:36 -0000</pubDate>
<webMaster>root@saturn.ffzg.hr</webMaster>
<generator>Socialtext Workspace v2.19.0.2</generator>

<item>
<title><![CDATA[ESP32CAM]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?esp32cam</link>
<description><![CDATA[<div>Creator: Dobrica Pavlinušić</div><hr/><div>Tags: home-assistant</div><hr/><div class="wiki">
<div class="nlw_phrase"><table class="wafl_container">
  <tr>
    <td>
      <div class="wafl_box">
        
          <div class="wafl_titlebox">
            <div class="wafl_title">
              
                Contents: [Dobrica Pavlinušić's random unstructured stuff]
              
            </div>
          </div>
          <div class="wafl_items">
            
              <div class="wiki">
<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#connection_flashing">Dobrica Pavlinušić's random unstructured stuff (connection, flashing)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] connection, flashing} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#spi">Dobrica Pavlinušić's random unstructured stuff (spi)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] spi} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#improved_example_app">Dobrica Pavlinušić's random unstructured stuff (improved example app)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] improved example app} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#timelapse">Dobrica Pavlinušić's random unstructured stuff (timelapse)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] timelapse} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#ocr_on_device">Dobrica Pavlinušić's random unstructured stuff (ocr on device)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] ocr on device} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#old_obsolete_problems">Dobrica Pavlinušić's random unstructured stuff (old, obsolete problems)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] old, obsolete problems} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#home_assistant">Dobrica Pavlinušić's random unstructured stuff (Home Assistant)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Home Assistant} --></span></li>
</ul>
</div>

            
            
          </div>
        
      </div>
    </td>
  </tr>
</table>
<!-- wiki: {toc: }
--></div><br /><br /><p>
<a target="_blank" title="(external link)" href="https://github.com/raphaelbs/esp32-cam-ai-thinker/blob/master/docs/about-esp32-cam.md">https://github.com/raphaelbs/esp32-cam-ai-thinker/blob/master/docs/about-esp32-cam.md</a></p>
<h1 id="connection_flashing">connection, flashing</h1>
<p>
connected to pl2303 serial</p>
<table style="border-collapse: collapse;" class="formatter_table">
<tr>
<td style="border: 1px solid black;padding: .2em;">pl2303</td>
<td style="border: 1px solid black;padding: .2em;">esp32cam</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">3v3</td>
<td style="border: 1px solid black;padding: .2em;">not connected</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">rxd</td>
<td style="border: 1px solid black;padding: .2em;">UnR</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">rxd</td>
<td style="border: 1px solid black;padding: .2em;">UOT</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">gnd</td>
<td style="border: 1px solid black;padding: .2em;">GND</td>
</tr>
<tr>
<td style="border: 1px solid black;padding: .2em;">5v</td>
<td style="border: 1px solid black;padding: .2em;">5V</td>
</tr>
</table>
<br /><span class="nlw_phrase"><img alt="ESP32-CAM-pinout-new.png" src="https://saturn.ffzg.hr/rot13/index.cgi/ESP32-CAM-pinout-new.png?action=attachments_download;page_name=esp32cam;id=20200420083349-7-8048" /><!-- wiki: {image: ESP32-=CAM-=pinout-=new.png} --></span><br /><br /><p>
To program the board, I userd jumper to jump GPIO0 with GND pin next to it.</p>
<p>
<a target="_blank" title="(external link)" href="https://github.com/raphaelbs/esp32-cam-ai-thinker/blob/master/docs/esp32cam-pin-notes.md">https://github.com/raphaelbs/esp32-cam-ai-thinker/blob/master/docs/esp32cam-pin-notes.md</a></p>
<h2 id="spi">spi</h2>
<p>
SDI = IO12</p>
<p>
SDO = IO13</p>
<p>
SCK = IO14</p>
<p>
CS = IO15</p>
<h1 id="improved_example_app">improved example app</h1>
<p>
<a target="_blank" title="(external link)" href="https://github.com/easytarget/esp32-cam-webserver">https://github.com/easytarget/esp32-cam-webserver</a></p>
<pre>
   cp myconfig.sample.h myconfig.h
   vi myconfig.h
dpavlin@nuc:/nuc/esp32/esp32-cam-webserver$ platformio run

dpavlin@nuc:/nuc/esp32/esp32-cam-webserver$ pio run -t upload --upload-port /dev/ttyUSB2
&quot;/home/dpavlin/.platformio/penv/bin/python&quot; &quot;/home/dpavlin/.platformio/packages/tool-esptoolpy/esptool.py&quot; \
--chip esp32 --port &quot;/dev/ttyUSB3&quot; --baud 460800 --before default_reset --after hard_reset \
write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect \
0x1000 /home/dpavlin/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin \
0x8000 /nuc/esp32/esp32-cam-webserver/.pio/build/esp32cam/partitions.bin \
0xe000 /home/dpavlin/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin \
0x10000 .pio/build/esp32cam/firmware.bin
</pre>
<br /><h1 id="timelapse">timelapse</h1>
<ul>
<li><a target="_blank" title="(external link)" href="https://bitluni.net/esp32camtimelapse">https://bitluni.net/esp32camtimelapse</a></li>
<li><a target="_blank" title="(external link)" href="https://github.com/bitluni/ESP32CamTimeLapse">https://github.com/bitluni/ESP32CamTimeLapse</a></li>
</ul>
<h1 id="ocr_on_device">ocr on device</h1>
<p>
<a target="_blank" title="(external link)" href="https://github.com/jomjol/AI-on-the-edge-device">https://github.com/jomjol/AI-on-the-edge-device</a></p>
<p>
<a target="_blank" title="(external link)" href="https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation">https://github.com/jomjol/AI-on-the-edge-device/wiki/Installation</a></p>
<p>
Remove glue from lens (very hard, using sharp knife), and rotate lens by 45 degrees until<br />
picture is sharp (I had to use pliers to do this).</p>
<pre>
dpavlin@nuc:/nuc/esp32/AI-on-the-edge-device$ vi sd-card/wlan.ini

dpavlin@nuc:/nuc/esp32/AI-on-the-edge-device/code$ pio run

dpavlin@nuc:/nuc/esp32/AI-on-the-edge-device/code$ pio run -v -t upload --upload-port /dev/ttyUSB3

&quot;/home/dpavlin/.platformio/penv/bin/python&quot; &quot;/home/dpavlin/.platformio/packages/tool-esptoolpy/esptool.py&quot; \
--chip esp32 --port &quot;/dev/ttyUSB3&quot; --baud 460800 --before default_reset --after hard_reset \
write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect \
0x1000 /nuc/esp32/AI-on-the-edge-device/code/.pio/build/esp32cam/bootloader.bin \
0x8000 /nuc/esp32/AI-on-the-edge-device/code/.pio/build/esp32cam/partitions.bin \
0xd000 /nuc/esp32/AI-on-the-edge-device/code/.pio/build/esp32cam/ota_data_initial.bin \
0x10000 .pio/build/esp32cam/firmware.bin

# original flashing instructions
esptool write_flash 0x01000 bootloader.bin 0x08000 partitions.bin 0x10000 firmware.bin

# download raw picture
wget 192.168.3.112/img_tmp/raw.jpg

</pre>
<br /><hr />
<h1 id="old_obsolete_problems">old, obsolete problems</h1>
<p>
It seems that my module is usually known as AI thinker variant. It has terrible picture which starts with huge green bias.</p>
<p>
It also doesn't work for me in resolutions below 1024x768 (in current esp32 example as of 2019-08-02).</p>
<p>
Plugging it into external 5V power supply did not helped much.</p>
<hr />
<p>
To solve green tint, I just left esp32cam module plugged in whole day and night. I guess that image sensor got discharged during night, but next day picture was fine.</p>
<p>
Problem with image resolution was fixed by updating to more recent version of ESP32 support for Arduino (as of 2020-04-20 it works fine)</p>
<h1 id="home_assistant"><a href="https://saturn.ffzg.hr/rot13/index.cgi?home_assistant" title="(37 months)  TV power button .pre show_name true show_icon true type button tap_action action call-service servi...">Home Assistant</a></h1>
<p>
<a target="_blank" title="(external link)" href="https://jamesachambers.com/cheap-esp32-cam-home-assistant-esphome-camera-guide/">https://jamesachambers.com/cheap-esp32-cam-home-assistant-esphome-camera-guide/</a></p>
<pre>
esphome:
  name: esp32cam
  friendly_name: esp32cam

esp32:
  board: esp32cam
  framework:
    type: arduino

# Enable logging
logger:
  level: VERBOSE
  tx_buffer_size: 256

# Enable Home Assistant API
api:
  encryption:
    key: &quot;MsJJJiDv9FTjZ1w8dfoy3Z8cQWjGOsk0m4Wgge0B+8w=&quot;
  services:  # change camera parameters on-the-fly
  - service: camera_set_param
    variables:
      name: string
      value: int
    then:
      - lambda: |-
          bool state_return = false;
          if ((&quot;contrast&quot; == name) &amp;&amp; (value &gt;= -2) &amp;&amp; (value &lt;= 2)) { id(espcam).set_contrast(value); state_return = true; }
          if ((&quot;brightness&quot; == name) &amp;&amp; (value &gt;= -2) &amp;&amp; (value &lt;= 2)) { id(espcam).set_brightness(value); state_return = true; }
          if ((&quot;saturation&quot; == name) &amp;&amp; (value &gt;= -2) &amp;&amp; (value &lt;= 2)) { id(espcam).set_saturation(value); state_return = true; }
          if ((&quot;special_effect&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 6U)) { id(espcam).set_special_effect((esphome::esp32_camera::ESP32SpecialEffect)value); state_return = true; }
          if ((&quot;aec_mode&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 1U)) { id(espcam).set_aec_mode((esphome::esp32_camera::ESP32GainControlMode)value); state_return = true; }
          if ((&quot;aec2&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 1U)) { id(espcam).set_aec2(value); state_return = true; }
          if ((&quot;ae_level&quot; == name) &amp;&amp; (value &gt;= -2) &amp;&amp; (value &lt;= 2)) { id(espcam).set_ae_level(value); state_return = true; }
          if ((&quot;aec_value&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 1200U)) { id(espcam).set_aec_value(value); state_return = true; }
          if ((&quot;agc_mode&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 1U)) { id(espcam).set_agc_mode((esphome::esp32_camera::ESP32GainControlMode)value); state_return = true; }
          if ((&quot;agc_value&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 30U)) { id(espcam).set_agc_value(value); state_return = true; }
          if ((&quot;agc_gain_ceiling&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 6U)) { id(espcam).set_agc_gain_ceiling((esphome::esp32_camera::ESP32AgcGainCeiling)value); state_return = true; }
          if ((&quot;wb_mode&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 4U)) { id(espcam).set_wb_mode((esphome::esp32_camera::ESP32WhiteBalanceMode)value); state_return = true; }
          if ((&quot;test_pattern&quot; == name) &amp;&amp; (value &gt;= 0U) &amp;&amp; (value &lt;= 1U)) { id(espcam).set_test_pattern(value); state_return = true; }
          if (true == state_return) {
            id(espcam).update_camera_parameters();
          }
          else {
            ESP_LOGW(&quot;esp32_camera_set_param&quot;, &quot;Error in name or data range&quot;);
          }

ota:
  password: &quot;09e4b58a1d186b8b33d100548f33d796&quot;

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  power_save_mode: none

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: &quot;Esp32Cam Fallback Hotspot&quot;
    password: &quot;GTIKgjitx2Re&quot;

captive_portal:

# Example configuration entry
esp32_camera:
  id: espcam
  name: esp-cam
  external_clock:
    pin: GPIO0
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22
  power_down_pin: GPIO32

  resolution: 800x600
  jpeg_quality: 10  # max. 63
  max_framerate: 1.0fps
  idle_framerate: 0.2fps
  vertical_flip: true
  horizontal_mirror: false
  brightness: 2 # -2 to 2
  contrast: 1 # -2 to 2
  special_effect: none
  # exposure settings
  aec_mode: auto
  aec2: false
  ae_level: 0
  aec_value: 300
  # gain settings
  agc_mode: auto
  agc_gain_ceiling: 2x
  agc_value: 0
  # white balance setting
  wb_mode: auto
output:
# white LED
  - platform: ledc
    channel: 2
    pin: GPIO4
    id: espCamLED
# red status light
  - platform: gpio
    pin:
      number: GPIO33
      inverted: True
    id: gpio_33
light:
  - platform: monochromatic
    output: espCamLED
    name: esp-cam light
  - platform: binary
    output: gpio_33
    name: esp-cam led
switch:
  - platform: restart
    name: esp-cam restart
binary_sensor:
  - platform: status
    name: esp-cam status
</pre>
</div>
<hr/><div>Attachments: ESP32-CAM-pinout-new.png</div>]]></description>
<author>Dobrica Pavlinu&#x161;i&#x107;</author>
<category>home-assistant</category>
<guid isPermaLink="true">https://saturn.ffzg.hr/rot13/index.cgi?esp32cam</guid>
<pubDate>Tue, 06 Aug 2024 10:06:36 -0000</pubDate>
</item>
</channel>
</rss>