{"componentChunkName":"component---src-templates-blog-post-js","path":"/tutorials/ring-door-bell-clone-p1/","result":{"data":{"site":{"siteMetadata":{"title":"TinoIoT","author":"TinoIoT Officers"}},"markdownRemark":{"id":"b0b49784-b0be-59d5-8e9d-d7f32449a14c","html":"<h1>Introduction</h1>\n<p>In this project we will be using the ESP32-CAM to create a Ring Door Bell type device. This small microcontroller has multiple capabilities, including:</p>\n<ul>\n<li>Camera Capability</li>\n<li>Wifi</li>\n<li>Bluetooth</li>\n<li>General Purpose Input Output (GPIO)</li>\n</ul>\n<p>These features make it ideal for many applications, as it can interface with sensors and other hardware, and also communicate over Wifi or Bluetooth. During this project, we will be taking advantage of all of these features to create a Ring Door Bell device with this functionality:</p>\n<ul>\n<li>Detect motion</li>\n<li>Stream video</li>\n<li>Notify user</li>\n<li>Save images for later</li>\n<li>Have a web interface</li>\n<li>Have a case</li>\n</ul>\n<h1>Requesting Parts</h1>\n<p>If you would like to request the ESP32-CAM Microcontroller, please:</p>\n<ul>\n<li>Fill out the form <a href=\"https://docs.google.com/forms/d/e/1FAIpQLScAbV7mz54nFYIpLaKZpQZFn_UysMwr27sUhh9jkwMGNngwtg/viewform\">here</a></li>\n<li>\n<p>Select kit option with ESP32-CAM</p>\n<ul>\n<li>If you have a base kit, you can receive just the ESP-32 CAM</li>\n</ul>\n</li>\n<li>Donate <a href=\"https://tracks.activenetwork.com/CPTHS/iot-kit-donation\">here </a>if you can!</li>\n</ul>\n<h1>Board Overview</h1>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 225px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/9bcc56e67bcfa3bfab21df3d420a2278/3684f/espfront-and-back.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 100%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base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XjOdPXcZetSPi8vb+PnKdu+zBNjU1ERRURF1dXXU1tZaFhoaGghUKEjLSBeqGoVa/T6G/nZ6HrRyv1tPZ/cdyspLhTvtSkCAGwv7GYp5E31tbc3iEmBwWDiJGg3e/v6CkGN4Mj7I458HGBjq5X5PG6VleaSmXSYk2I0ls+noHEqyaWxsxNPXj4BgBZ7+Fzgj6C2/MIeCohxKviygpLSIcm0x54Mu4ODkwNTUrwerLLkkm/b2dkEu0SQkXyEuUYM6MQVVTCyqywIjQSa+587h5eeHzM0NRVjYQdk8r2OLnUh0sUeKKRHZbwlxY2Pz2fzq6uqzHmppsIeBJLD/+huQ3v8HZu/wVjNybwIAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/9bcc56e67bcfa3bfab21df3d420a2278/94563/espfront-and-back.webp 163w,\n/static/9bcc56e67bcfa3bfab21df3d420a2278/d7e55/espfront-and-back.webp 225w\"\n              sizes=\"(max-width: 225px) 100vw, 225px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/9bcc56e67bcfa3bfab21df3d420a2278/222b7/espfront-and-back.png 163w,\n/static/9bcc56e67bcfa3bfab21df3d420a2278/3684f/espfront-and-back.png 225w\"\n            sizes=\"(max-width: 225px) 100vw, 225px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/9bcc56e67bcfa3bfab21df3d420a2278/3684f/espfront-and-back.png\"\n            alt=\"espfront and back\"\n            title=\"espfront and back\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Looking at the front and back of the board, we can see multiple features. On the front of the board, we can see the camera at the center. This camera is connected to the board with a thin ribbon cable, so be careful with the microcontroller. Youre camera might have a piece of tape to protect the lens which you can remove. Underneath the camera is a metal square. This square is a microSD card slot that can be used to save images to or other data. On the bottom left, there is a white square. This is a small LED that can be used to illuminate the subject of the camera. It is very bright, so don’t look directly into it from a close distance.</p>\n<p>On the backside of the board, you can see the main chip in the silver rectangle. The gold snake like path is an antenna band. If you need to, it is possible to extend the range of Wifi by connecting an antenna to the white circle on the bottom right side of the chip, as this is an antenna port. On the top left side of the board, look carefully for a button. It is directly to the left of the yellow square. This is the reset/program button. We will be using it to let the microcontroller know if it is in programming mode or not.</p>\n<h1>Programming the Board</h1>\n<p>You may have noticed that the board does not have a USB port on it. To program it, we need a special device called an FTDI programmer. This device converts USB signals into a form of data the microcontroller can understand.</p>\n<p>To connect the FTDI programmer, connect it to your microcontroller according to this wiring diagram using the parts in your kit. Pay attention to the arrow. This connects IO0 to GND. This wire is used to put the device into programming mode. I will be calling this “the jumper wire”</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 650px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/f5100127c3531a7878870774affde3c6/2bef9/esp32-cam-prog-1024x470.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 46.012269938650306%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAIAAAC9o5sfAAAACXBIWXMAAAsTAAALEwEAmpwYAAABdklEQVQoz41RS0sCURQeaBMt+jMtg9pWVJuCIAJp0aY/ELjKCLSFUC0Ce2ibUrN8NIVRYZBhswuaaRWOaOO8nBkfc8V5T3fSkZAWfRy+c+Dc736ccxD7B9av+D8QhwzDqjfsdtsGALLVbMGwRanTbDEsy7OswNd0VTV13TJNy4LksCPuWpE4/pLPY4XXQu5JEoUWkG1dBzxXpiiK5xhRbCvKH87dP0iSjIRPDvZ2b2MJkuRZDqgi0GWVeC6cL68dL62GFzxn8yvZzR2WYQiCEEVR07SeuFShrk5D6VDwHs3SklDm6tVSVWCrmeD+xtDo2PDINIJsI8jDViCD3gT8fq/X6/P5euLPIplNXeTScTR+WSG/hBKtSJKhdN7uHiNTi4eTc0cTs+HxmZhnvcZy0BYAAIXOwmDCMCyZTGWu0UQ0KksNuML+YLphVHiuSFOqpv09M03TOI5/EMQ7jstw5y6crmnCZLtFH+6puo/cAl5iwKHfHcA3yybahwcaWs4AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/f5100127c3531a7878870774affde3c6/94563/esp32-cam-prog-1024x470.webp 163w,\n/static/f5100127c3531a7878870774affde3c6/647a8/esp32-cam-prog-1024x470.webp 325w,\n/static/f5100127c3531a7878870774affde3c6/c1dc5/esp32-cam-prog-1024x470.webp 650w,\n/static/f5100127c3531a7878870774affde3c6/1e975/esp32-cam-prog-1024x470.webp 975w,\n/static/f5100127c3531a7878870774affde3c6/a9a89/esp32-cam-prog-1024x470.webp 1024w\"\n              sizes=\"(max-width: 650px) 100vw, 650px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/f5100127c3531a7878870774affde3c6/222b7/esp32-cam-prog-1024x470.png 163w,\n/static/f5100127c3531a7878870774affde3c6/ff46a/esp32-cam-prog-1024x470.png 325w,\n/static/f5100127c3531a7878870774affde3c6/a6d36/esp32-cam-prog-1024x470.png 650w,\n/static/f5100127c3531a7878870774affde3c6/e548f/esp32-cam-prog-1024x470.png 975w,\n/static/f5100127c3531a7878870774affde3c6/2bef9/esp32-cam-prog-1024x470.png 1024w\"\n            sizes=\"(max-width: 650px) 100vw, 650px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/f5100127c3531a7878870774affde3c6/a6d36/esp32-cam-prog-1024x470.png\"\n            alt=\"esp32 cam prog 1024x470\"\n            title=\"esp32 cam prog 1024x470\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Next, download the Arduino IDE here and follow these tutorials to set it up depending on your system (Windows here, Mac/Linux here)</p>\n<p>Then, select the ESP32-CAM Thinker Module and COM port through the Tools menu. Open the example code at “ File > Examples > ESP32 > Camera > Camera Web Server.” Change the SSID and password fields (leave the quotes in). Add ”//” in front of CAMERA_MODEL_WROVER_KIT and remove the ”//” in front of CAMERA_MODEL_AI_THINKER  and save the file. To push the example code to the device, follow these instructions:</p>\n<ol>\n<li>Connect FTDI Programmer as shown previously</li>\n<li>Connect GND to IO0 (The jumper wire)</li>\n<li>Press reset button under board</li>\n<li>Push code from Arduino IDE</li>\n<li>Disconnect GND and IO0</li>\n<li>Press reset button under board</li>\n</ol>\n<p>Now, open the serial monitor through the “Tools” menu and wait until a URL with an IP address appears. Make sure your computer is connected to the same network that you programmed the ESP32-CAM to connect to, and open the URL in your web browser. You can now start the camera stream and see the video displayed by your device. Try different resolutions and adjust the settings. There may be some issues with lag in the video depending on the quality of your network connection and other factors.</p>\n<h1>ESP32-CAM Code Explanation</h1>\n<p>Let’s run through the example code so you know how it works.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">\"esp_camera.h\"</span></span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;WiFi.h></span></span>\n\n<span class=\"token comment\">//</span>\n<span class=\"token comment\">// WARNING!!! Make sure that you have either selected ESP32 Wrover Module,</span>\n<span class=\"token comment\">//            or another board which has PSRAM enabled</span>\n<span class=\"token comment\">//</span>\n\n<span class=\"token comment\">// Select camera model</span>\n<span class=\"token comment\">//define CAMERA_MODEL_WROVER_KIT</span>\n<span class=\"token comment\">//#define CAMERA_MODEL_ESP_EYE</span>\n<span class=\"token comment\">//#define CAMERA_MODEL_M5STACK_PSRAM</span>\n<span class=\"token comment\">//#define CAMERA_MODEL_M5STACK_WIDE</span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">define</span> <span class=\"token macro-name\">CAMERA_MODEL_AI_THINKER</span></span>\n\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">\"camera_pins.h\"</span></span>\n\n<span class=\"token keyword\">const</span> <span class=\"token keyword\">char</span><span class=\"token operator\">*</span> ssid <span class=\"token operator\">=</span> <span class=\"token string\">\"****\"</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">const</span> <span class=\"token keyword\">char</span><span class=\"token operator\">*</span> password <span class=\"token operator\">=</span> <span class=\"token string\">\"******\"</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">void</span> <span class=\"token function\">startCameraServer</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<p>Lines 1-2 start by including files and libraries that the code needs to use. These store a bunch of code in the background so you have to do less work.</p>\n<p>Lines 9-14 tell the compiler what type of board we’re using. In our club, we use the AI Thinker model, so we uncommented that line. The // comments out lines. It tells the compiler to ignore that line.</p>\n<p>On the next few lines, we tell the microcontroller what our Wifi information is, and then start the Camera Server that runs on the ESP32-CAM.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token keyword\">void</span> <span class=\"token function\">setup</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  Serial<span class=\"token punctuation\">.</span><span class=\"token function\">begin</span><span class=\"token punctuation\">(</span><span class=\"token number\">115200</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  Serial<span class=\"token punctuation\">.</span><span class=\"token function\">setDebugOutput</span><span class=\"token punctuation\">(</span>true<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  Serial<span class=\"token punctuation\">.</span><span class=\"token function\">println</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token class-name\">camera_config_t</span> config<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>ledc_channel <span class=\"token operator\">=</span> LEDC_CHANNEL_0<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>ledc_timer <span class=\"token operator\">=</span> LEDC_TIMER_0<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_d0 <span class=\"token operator\">=</span> Y2_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_d1 <span class=\"token operator\">=</span> Y3_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_d2 <span class=\"token operator\">=</span> Y4_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_d3 <span class=\"token operator\">=</span> Y5_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_d4 <span class=\"token operator\">=</span> Y6_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_d5 <span class=\"token operator\">=</span> Y7_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_d6 <span class=\"token operator\">=</span> Y8_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_d7 <span class=\"token operator\">=</span> Y9_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_xclk <span class=\"token operator\">=</span> XCLK_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_pclk <span class=\"token operator\">=</span> PCLK_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_vsync <span class=\"token operator\">=</span> VSYNC_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_href <span class=\"token operator\">=</span> HREF_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_sscb_sda <span class=\"token operator\">=</span> SIOD_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_sscb_scl <span class=\"token operator\">=</span> SIOC_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_pwdn <span class=\"token operator\">=</span> PWDN_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pin_reset <span class=\"token operator\">=</span> RESET_GPIO_NUM<span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>xclk_freq_hz <span class=\"token operator\">=</span> <span class=\"token number\">20000000</span><span class=\"token punctuation\">;</span>\n  config<span class=\"token punctuation\">.</span>pixel_format <span class=\"token operator\">=</span> PIXFORMAT_JPEG<span class=\"token punctuation\">;</span></code></pre></div>\n<p>On lines 2-4, we are setting up the serial monitor. This is the way the ESP talks to the Arduino IDE’s serial monitor. Serial is the name of the method used to communicate with the ESP and computer. 115200 is some information about the speed of the serial connection.</p>\n<p>On lines 6-26, we’re letting the microcontroller know what ports to use to connect to the camera. This is so the microcontroller can read camera data. We also set up some camera format and speed options.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token comment\">//init with high specs to pre-allocate larger buffers</span>\n  <span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span><span class=\"token function\">psramFound</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">{</span>\n    config<span class=\"token punctuation\">.</span>frame_size <span class=\"token operator\">=</span> FRAMESIZE_UXGA<span class=\"token punctuation\">;</span>\n    config<span class=\"token punctuation\">.</span>jpeg_quality <span class=\"token operator\">=</span> <span class=\"token number\">10</span><span class=\"token punctuation\">;</span>\n    config<span class=\"token punctuation\">.</span>fb_count <span class=\"token operator\">=</span> <span class=\"token number\">2</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\n    config<span class=\"token punctuation\">.</span>frame_size <span class=\"token operator\">=</span> FRAMESIZE_SVGA<span class=\"token punctuation\">;</span>\n    config<span class=\"token punctuation\">.</span>jpeg_quality <span class=\"token operator\">=</span> <span class=\"token number\">12</span><span class=\"token punctuation\">;</span>\n    config<span class=\"token punctuation\">.</span>fb_count <span class=\"token operator\">=</span> <span class=\"token number\">1</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">if</span> <span class=\"token expression\"><span class=\"token function\">defined</span><span class=\"token punctuation\">(</span>CAMERA_MODEL_ESP_EYE<span class=\"token punctuation\">)</span></span></span>\n  <span class=\"token function\">pinMode</span><span class=\"token punctuation\">(</span><span class=\"token number\">13</span><span class=\"token punctuation\">,</span> INPUT_PULLUP<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token function\">pinMode</span><span class=\"token punctuation\">(</span><span class=\"token number\">14</span><span class=\"token punctuation\">,</span> INPUT_PULLUP<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">endif</span></span></code></pre></div>\n<p>In this part, we set up some information about the camera size and streaming mode. On Lines 12-15, we check what type of microcontroller we’re using and set up a different mode. We can disregard this.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token comment\">// camera init</span>\n  <span class=\"token class-name\">esp_err_t</span> err <span class=\"token operator\">=</span> <span class=\"token function\">esp_camera_init</span><span class=\"token punctuation\">(</span><span class=\"token operator\">&amp;</span>config<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>err <span class=\"token operator\">!=</span> ESP_OK<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    Serial<span class=\"token punctuation\">.</span><span class=\"token function\">printf</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"Camera init failed with error 0x%x\"</span><span class=\"token punctuation\">,</span> err<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token keyword\">return</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n\n  <span class=\"token class-name\">sensor_t</span> <span class=\"token operator\">*</span> s <span class=\"token operator\">=</span> <span class=\"token function\">esp_camera_sensor_get</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token comment\">//initial sensors are flipped vertically and colors are a bit saturated</span>\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>s<span class=\"token operator\">-></span>id<span class=\"token punctuation\">.</span>PID <span class=\"token operator\">==</span> OV3660_PID<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    s<span class=\"token operator\">-></span><span class=\"token function\">set_vflip</span><span class=\"token punctuation\">(</span>s<span class=\"token punctuation\">,</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span><span class=\"token comment\">//flip it back</span>\n    s<span class=\"token operator\">-></span><span class=\"token function\">set_brightness</span><span class=\"token punctuation\">(</span>s<span class=\"token punctuation\">,</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span><span class=\"token comment\">//up the blightness just a bit</span>\n    s<span class=\"token operator\">-></span><span class=\"token function\">set_saturation</span><span class=\"token punctuation\">(</span>s<span class=\"token punctuation\">,</span> <span class=\"token operator\">-</span><span class=\"token number\">2</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span><span class=\"token comment\">//lower the saturation</span>\n  <span class=\"token punctuation\">}</span>\n  <span class=\"token comment\">//drop down frame size for higher initial frame rate</span>\n  s<span class=\"token operator\">-></span><span class=\"token function\">set_framesize</span><span class=\"token punctuation\">(</span>s<span class=\"token punctuation\">,</span> FRAMESIZE_QVGA<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">if</span> <span class=\"token expression\"><span class=\"token function\">defined</span><span class=\"token punctuation\">(</span>CAMERA_MODEL_M5STACK_WIDE<span class=\"token punctuation\">)</span></span></span>\n  s<span class=\"token operator\">-></span><span class=\"token function\">set_vflip</span><span class=\"token punctuation\">(</span>s<span class=\"token punctuation\">,</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  s<span class=\"token operator\">-></span><span class=\"token function\">set_hmirror</span><span class=\"token punctuation\">(</span>s<span class=\"token punctuation\">,</span> <span class=\"token number\">1</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">endif</span></span></code></pre></div>\n<p>On lines 2-6, we make sure that we were able to start the camera successfully. We then adjust the image, as by default it is flipped and colors aren’t that great on lines 8 to 16. Finally, we check the camera type and modify the camera flip options if it we’re using a certain type of camera.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\">WiFi<span class=\"token punctuation\">.</span><span class=\"token function\">begin</span><span class=\"token punctuation\">(</span>ssid<span class=\"token punctuation\">,</span> password<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token keyword\">while</span> <span class=\"token punctuation\">(</span>WiFi<span class=\"token punctuation\">.</span><span class=\"token function\">status</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">!=</span> WL_CONNECTED<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token function\">delay</span><span class=\"token punctuation\">(</span><span class=\"token number\">500</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    Serial<span class=\"token punctuation\">.</span><span class=\"token function\">print</span><span class=\"token punctuation\">(</span><span class=\"token string\">\".\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n  Serial<span class=\"token punctuation\">.</span><span class=\"token function\">println</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  Serial<span class=\"token punctuation\">.</span><span class=\"token function\">println</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"WiFi connected\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token function\">startCameraServer</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  Serial<span class=\"token punctuation\">.</span><span class=\"token function\">print</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"Camera Ready! Use 'http://\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  Serial<span class=\"token punctuation\">.</span><span class=\"token function\">print</span><span class=\"token punctuation\">(</span>WiFi<span class=\"token punctuation\">.</span><span class=\"token function\">localIP</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  Serial<span class=\"token punctuation\">.</span><span class=\"token function\">println</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"' to connect\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>Here, we’re almost ready. We connect to Wifi. Lines 3-8 just wait until we connect to wifi. Next, we start the camera server and print the IP Address information.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token keyword\">void</span> <span class=\"token function\">loop</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token comment\">// put your main code here, to run repeatedly:</span>\n  <span class=\"token function\">delay</span><span class=\"token punctuation\">(</span><span class=\"token number\">10000</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>In this final part of the code, we can add any code that we want to run.</p>\n<h1>Next Steps</h1>\n<p>In our next blog post, we will be working on receiving camera information with Python. We will also be working on some facial detection applications with python. As always, if you have any questions feel free to email cupertinoiot@gmail.com.</p>","snippet":" In this project we will be using the ESP32-CAM to create a Ring Door Bell type device. This small microcontroller…","fields":{"keywords":["config","camera","board","wifi","esp32"],"slug":"/tutorials/ring-door-bell-clone-p1/"},"frontmatter":{"title":"Ring Door Bell Clone Part 1","keywords":["tinoiot","iot","doorbell","esp32-cam"],"description":null,"author":"TinoIoT Officers","date":"February 13, 2021","featuredImage":{"childImageSharp":{"fluid":{"src":"/static/66f0b8f3773a833485ef8158cc588a80/db955/slightly-better-esp32-ish-3-.png","srcSet":"/static/66f0b8f3773a833485ef8158cc588a80/7e7e9/slightly-better-esp32-ish-3-.png 225w,\n/static/66f0b8f3773a833485ef8158cc588a80/62b1f/slightly-better-esp32-ish-3-.png 450w,\n/static/66f0b8f3773a833485ef8158cc588a80/db955/slightly-better-esp32-ish-3-.png 900w,\n/static/66f0b8f3773a833485ef8158cc588a80/8e9fc/slightly-better-esp32-ish-3-.png 1195w","aspectRatio":1.2640449438202248,"sizes":"(max-width: 900px) 100vw, 900px","base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAIAAACZeshMAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAD20lEQVQozwHQAy/8AMKQar6+vc7U1tbY19jZ2MzQ0oyaoRwwQnKCis3Pxba8sa+ztLG6ura/vbe/uauxrbG6sbK4uK+zuK6xtgDbhk65gVe5sq3R193c29jX29lrgo4cM0aBmpzV1M/o5tzY29HU2M+orq1kcnScpqW1vLCqsqKfqKGvtrsA2ot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TtJ+UsdzRa5qP3xQNk47NCYsNR4fIEMoGHdAKIVHLIJFLJJNMZpTM55WNaddOId8gM2Nam4WAAAAAElFTkSuQmCC","srcWebp":"/static/66f0b8f3773a833485ef8158cc588a80/210c1/slightly-better-esp32-ish-3-.webp","srcSetWebp":"/static/66f0b8f3773a833485ef8158cc588a80/975bf/slightly-better-esp32-ish-3-.webp 225w,\n/static/66f0b8f3773a833485ef8158cc588a80/b8a88/slightly-better-esp32-ish-3-.webp 450w,\n/static/66f0b8f3773a833485ef8158cc588a80/210c1/slightly-better-esp32-ish-3-.webp 900w,\n/static/66f0b8f3773a833485ef8158cc588a80/0c572/slightly-better-esp32-ish-3-.webp 1195w"}}}}}},"pageContext":{"slug":"/tutorials/ring-door-bell-clone-p1/","pinned":false,"previous":{"fields":{"slug":"/blogs/first-meeting-of-second-semester/","pinned":false,"source":"regular"},"snippet":"Hi everyone! Make sure to join our meeting today at 12pm with meet.tinoiot.com to learn about what projects we will…","frontmatter":{"title":"First Meeting of Second Semester","category":"blog","thumbnailText":null,"author":"TinoIoT Officers","date":"January 12, 2021","redirect_from":null,"featuredImage":{"childImageSharp":{"fluid":{"src":"/static/0d1a5715b0c84155a3956acd81f49c2a/497c6/tino-1-.png","srcSet":"/static/0d1a5715b0c84155a3956acd81f49c2a/65e33/tino-1-.png 100w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/69585/tino-1-.png 200w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/497c6/tino-1-.png 400w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/2a4de/tino-1-.png 600w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/ee604/tino-1-.png 800w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/05d05/tino-1-.png 1080w","aspectRatio":1,"sizes":"(max-width: 400px) 100vw, 400px","base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAE8UlEQVQ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9L6xadQTwWYnLIodiYf9Auaq3SozbxlJWZYqU58kztVX1eS65Dn2nRFKm6q3cN0qKzxPyvQhdmaia0SEFlABQ1ideUsRukNg3MEKOruiiYiijpEL14ziflG3x2X8BnTx0+8jxE2vGVWl2oqVFScpFwtl8M28jKmsusqhkQWCMz5WW9eFQv5veVtoxULZdjIbJikEXnJgg/0M3M1HoCRKVKO6xEpk304TY2Wb0kyskuqepmo/UWC8u7NKCC+WnAZgLy2/BNbWDuMQ8rB5+ROAJrh54S13iHIAGqCC2woVtV72X5mQGiK3tY3fg90WIXlaaftJK/Fs1a30Y33SestJN3Xb+TcB0+HJokaXSKrd5nrO38iQgZIKptdfMq+wg92MW8014iD3Xin6lgVvyzpUclFDRcUg3Js7Kg1stqDzIzp2R2TrFhdJJPbjxhx8SUjMBfmFsmKQeYxBJHRwks6tROVYEM+2wvQk5RTZqwQgdRRwZ5r+sRCZ7nrB2e0qb7lrGnfDr+F9u/fcTu25N8MXQfnbF8iKCiDlHTrM2zF2HTTKoMH1XWQWzTz8QP/ssHQ89JfKlu441J7W/jc+8Tdt56TPLEn6Tffsh/gpzGS++7iVIAAAAASUVORK5CYII=","srcWebp":"/static/0d1a5715b0c84155a3956acd81f49c2a/1f5c5/tino-1-.webp","srcSetWebp":"/static/0d1a5715b0c84155a3956acd81f49c2a/d1f52/tino-1-.webp 100w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/61e93/tino-1-.webp 200w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/1f5c5/tino-1-.webp 400w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/ad85c/tino-1-.webp 600w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/58556/tino-1-.webp 800w,\n/static/0d1a5715b0c84155a3956acd81f49c2a/54d25/tino-1-.webp 1080w"}}}}},"next":{"fields":{"slug":"/blogs/questions-and-answers/","pinned":true,"source":"pinned"},"snippet":"Hi everyone! Below is a list of commonly asked questions (along with answers) during the first meeting today. Feel free…","frontmatter":{"title":"Common Questions","category":"blog","thumbnailText":"Q & A","author":"Ethan Zhang","date":"September 24, 2020","redirect_from":["/blogs/q-and-a/"],"featuredImage":null}}}},"staticQueryHashes":["2390832784"]}