# DIY IoT Doorbell Camera with MEMENTO

## Overview

![A door-mounted MEMENTO doorbell](https://cdn-learn.adafruit.com/assets/assets/000/127/345/medium800/adafruit_products_hero-mickey-door.jpg?1707233042)

https://youtu.be/DhoupbBY6yQ

## Doorbell Camera

Build a simple IoT doorbell camera using Adafruit's MEMENTO. Press a mini LED arcade button to snap a photo and display it on an Adafruit IO Dashboard. The electronics are housed in a 3D printed snap fit enclosure.&nbsp;

![adafruit_products_hero-orange.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/356/medium640/adafruit_products_hero-orange.jpg?1706636061)

## **Adafruit MEMENTO Camera**

Adafruit's MEMENTO Camera Board is a development board with everything you need to create programmable camera and vision projects. The OV5640 camera module onboard the MEMENTO is a 5MP camera sensor auto-focus motor and a JPEG encoder built-in for reducing the image size. The ESP32-S3 module on the MEMENTO runs CircuitPython and sends images over WiFi to&nbsp;[Adafruit.io](https://io.adafruit.com/).

![adafruit_products_hero-memento.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/357/medium640/adafruit_products_hero-memento.jpg?1706639039)

## Code with CircuitPython

This doorbell is programmed with CircuitPython which makes it easy to modify the project's code to fit your needs.&nbsp;

![adafruit_products_code_with_cp.png](https://cdn-learn.adafruit.com/assets/assets/000/127/478/medium640/adafruit_products_code_with_cp.png?1707156792)

## An IoT Doorbell with Privacy in Mind

This DIY doorbell won't share its&nbsp;[data with 3rd parties](https://www.consumerreports.org/home-garden/home-security-cameras/ring-google-simplisafe-could-share-footage-with-police-a1047736080/)&nbsp;as it adheres to&nbsp;[Adafruit's IoT Bill of Rights](https://www.adafruit.com/iotbor/#:~:text=Consumers%2C%20not%20companies%2C%20own%20the,by%20Internet%20of%20Things%20devices.). Data sent from the doorbell to Adafruit IO will be stored on a _private_ Adafruit IO feed, the photos captured by the doorbell are only viewable by you.

![adafruit_products_940_LRG-1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/126/841/medium640/adafruit_products_940_LRG-1.jpg?1703261630)

## Parts
### MEMENTO - Python Programmable DIY Camera - Bare Board

[MEMENTO - Python Programmable DIY Camera - Bare Board](https://www.adafruit.com/product/5420)
Make memories, or just a cool camera-based project,&nbsp;with **Adafruit's MEMENTO Camera Board**. It's a development board with everything you need to create programmable camera and vision projects: with a camera module, TFT preview screen, buttons, SD card slot and...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5420)
[Related Guides to the Product](https://learn.adafruit.com/products/5420/guides)
![Video of a DIY camera on a lazy susan.](https://cdn-shop.adafruit.com/product-videos/640x480/5420-05.jpg)

### Part: Mini LED Arcade Button
quantity: 1
24mm Translucent Clear
[Mini LED Arcade Button](https://www.adafruit.com/product/3429)

### Part: STEMMA JST PH 3-Pin
quantity: 2
JST PH 3-pin Cable - 200mm
[STEMMA JST PH 3-Pin](https://www.adafruit.com/product/3893)

### Part: 3.7V 420mAh LIPO Battery
quantity: 1
Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh
[3.7V 420mAh LIPO Battery](https://www.adafruit.com/product/4236)

### Part: Woven USB A to USB C Cable
quantity: 1
Pink and Purple Woven USB A to USB C Cable - 1 meter long
[Woven USB A to USB C Cable](https://www.adafruit.com/product/5153)

The following part is **optional and not required for the completion of this project.** However, if you would like to set up SMS alerts, as described later in the guide, you will need an _upgraded, paid,_ Adafruit IO subscription (Adafruit IO Plus).&nbsp;For information on what is included with an Adafruit IO Plus subscription, visit&nbsp;[io.adafruit.com/plus](https://io.adafruit.com/plus)

### Adafruit IO+ Subscription Pass – One Year

[Adafruit IO+ Subscription Pass – One Year](https://www.adafruit.com/product/3792)
The all-in-one Internet of Things service from Adafruit you know and love is now _even better_ with IO+. The 'plus' stands for MORE STUFF! More feeds, dashboards, storage, speed. Power up your [Adafruit IO](https://io.adafruit.com/) with the $99 pass for 1 year of the...

In Stock
[Buy Now](https://www.adafruit.com/product/3792)
[Related Guides to the Product](https://learn.adafruit.com/products/3792/guides)
![Text image that reads "IO+"](https://cdn-shop.adafruit.com/640x480/3792-01.jpg)

## Hardware

The following hardware is required for the assembly.

- 6x M3 x 6mm long machine screws
- [3/8 to 1/4-20 Tripod screw insert](https://www.adafruit.com/product/2392) (optional)

# DIY IoT Doorbell Camera with MEMENTO

## Get Started with Adafruit IO

Adafruit IO is integrated with your&nbsp;[adafruit.com account](https://accounts.adafruit.com/)&nbsp;so you don't need to create yet another online account! You need an Adafruit account to use Adafruit IO because we want to make sure the data you upload is available to only you (unless you decide to publish your data).

## I have an Adafruit.com Account already

**If you already have an Adafruit account, then you already have access to Adafruit IO**. It doesn't matter how you signed up, your account will make all three available.

To access Adafruit IO, simply visit [https://io.adafruit.com](https://io.adafruit.com) to start streaming, logging, and interacting with your data.

## Create an Adafruit Account (for Adafruit IO)

An Adafruit account makes Adafruit content and services available to you in one place. Your account provides access to the [Adafruit shop](https://www.adafruit.com/), the [Adafruit Learning System](https://learn.adafruit.com/), and [Adafruit IO](https://io.adafruit.com/). This means only one account, one username, and one password are necessary to engage with the content and services that Adafruit offers.

If you do not have an Adafruit account, signing up for a new Adafruit account only takes a couple of steps.

Begin by visiting [https://accounts.adafruit.com](https://accounts.adafruit.com).

**Click the Sign Up button** under the "Need An Adafruit Account?" title, below the Sign In section.

![](https://cdn-learn.adafruit.com/assets/assets/000/125/220/medium800/adafruit_io_Create_account_sign_in_up_page.png?1697479894)

This will take you to the **Sign Up** page.

**Fill in the requested information,** and **click the Create Account button.**

![](https://cdn-learn.adafruit.com/assets/assets/000/125/219/medium800/adafruit_io_Create_Account_info_entered.png?1697479894)

This takes you to your Adafruit Account home page. From here, you can access all the features of your account.

You can also access the Adafruit content and services right from this page. Along the top of the page, you'll see a series of links beginning with "Shop". To access any of these, simply click the link.

![](https://cdn-learn.adafruit.com/assets/assets/000/125/217/medium800/adafruit_io_Create_account_home_page.png?1697479894)

For example, **to begin working with Adafruit IO, click the IO link** to the right of the rest of the links. This is the same for the other links as well.

That's all there is to creating a new Adafruit account, and navigating to Adafruit IO.

![](https://cdn-learn.adafruit.com/assets/assets/000/125/218/medium800/adafruit_io_Create_Account_io_homepage.png?1697479770)

# DIY IoT Doorbell Camera with MEMENTO

## Create Adafruit IO Feed

Warning: 

Feeds are the core of the Adafruit IO system. A feed holds&nbsp; **data&nbsp;** and&nbsp; **meta-data** &nbsp;that you have sent to Adafruit IO.

- **Data** &nbsp;is the information you want Adafruit IO to store. For example, image data from the MEMENTO's camera.
- **Meta-data** &nbsp;includes settings for the data such as privacy settings and data retention options.

Before using the doorbell camera, a new Adafruit IO Feed must be created to store the camera's image. Then, the feed's history must be disabled to allow larger data points to be sent to Adafruit IO, such as a large amount of data to represent an image.&nbsp;

To create a feed, navigate to your [Adafruit IO Feeds](https://io.adafruit.com/feeds) page. Then, click _New Feed_.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/219/medium800/adafruit_products_new-feed.png?1706206187)

Name the feed&nbsp;_camera_ and click Create.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/220/medium800/adafruit_products_camera-feed.png?1706206202)

The feeds list now lists a _camera_ feed. Click this feed.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/218/medium800/adafruit_products_cam-feed-click.png?1706206179)

## Disable Feed History

On the camera feed's sidebar, click _Feed History_.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/221/medium800/adafruit_products_feed-his-1.png?1706206210)

Set _History_ to _OFF_ and click Save. This will change the feed's data storage from 1KB to 100KB, large enough to store image data.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/222/medium800/adafruit_products_feed-his-2.png?1706206216)

# DIY IoT Doorbell Camera with MEMENTO

## Wiring

## Circuit Diagram
![](https://cdn-learn.adafruit.com/assets/assets/000/126/795/medium800/adafruit_products_memento-cam_bb.png?1703176539)

Make the following connections between the MEMENTO camera board and the metal pushbutton:

- MEMENTO **A0 Signal** to pushbutton **NO**
- MEMENTO **A0 GND** to pushbutton **COM**
- MEMENTO **A1 Signal** to pushbutton **LED+**
- MEMENTO **A1 GND** to pushbutton **LED-**

## Power

The suggested battery for this project has a capacity of 420mAh for a total of about 1.55 Wh and plugs directly into the MEMENTO's 2-Pin JST-PH port.

### Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh

[Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh](https://www.adafruit.com/product/4236)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 420mAh for a total of about 1.55 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4236)
[Related Guides to the Product](https://learn.adafruit.com/products/4236/guides)
![Lithium Ion Polymer Battery 3.7v 420mAh with JST 2-PH connector and short cable](https://cdn-shop.adafruit.com/640x480/4236-04.jpg)

However, the MEMENTO does run out of battery power quickly. We suggest plugging the MEMENTO into USB-C and using a wall power supply.

### Vertical Wall Power Supply with USB C - 5V 3A Output and Switch

[Vertical Wall Power Supply with USB C - 5V 3A Output and Switch](https://www.adafruit.com/product/5801)
We love the Raspberry Pi 4 and 5, with their fancy new USB Type C power connectors. Now we have an even&nbsp;_better_&nbsp;power supply that can be used with either Pi 4 or even a Pi 5 with 5V output, 3A of current to handle builds with accessories and displays. The vertical-style plug...

In Stock
[Buy Now](https://www.adafruit.com/product/5801)
[Related Guides to the Product](https://learn.adafruit.com/products/5801/guides)
![5V 3A Switching Power Supply with USB C](https://cdn-shop.adafruit.com/640x480/5801-02.jpg)

# DIY IoT Doorbell Camera with MEMENTO

## 3D Printing

## 3D Printed Parts

STL files for 3D printing are oriented to print "as-is" on FDM style machines. Parts are designed to 3D print without any support material using PLA filament. Original design source files may be downloaded using the links below.

![adafruit_products_3d-parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/306/medium640/adafruit_products_3d-parts.jpg?1706548480)

[Download STLs.zip](https://cdn-learn.adafruit.com/assets/assets/000/127/343/original/STLs.zip?1706621928)
[Download CAD source](https://cdn-learn.adafruit.com/assets/assets/000/127/344/original/CAD.zip?1706622115)
## Build Volume

The parts require a 3D printer with a minimum build volume.

- 80mm (X) x 30mm (Y) x 66mm (Z)

![adafruit_products_cura-slice.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/303/medium640/adafruit_products_cura-slice.jpg?1706537050)

## CAD Assembly

The Memento PCB is secured to the PCB mount using machine screws. The PCB mount is secured to the camera case using machine screws. The mini LED arcade button is panel mounted to a sleeve and the button casing. The button case snap fits onto the camera case. The top and bottom covers snap fits on to the camera case.

![adafruit_products_cad.gif](https://cdn-learn.adafruit.com/assets/assets/000/127/304/medium640thumb/adafruit_products_cad.jpg?1706539158)

## Design Source Files

The project assembly was designed in Fusion 360. This can be downloaded in different formats like STEP, STL and more. Electronic components like Adafruit's boards, displays, connectors and more can be downloaded from the&nbsp;[Adafruit CAD parts GitHub Repo](https://github.com/adafruit/Adafruit_CAD_Parts/).

![adafruit_products_5420_MEMENTO.gif](https://cdn-learn.adafruit.com/assets/assets/000/127/342/medium640thumb/adafruit_products_5420_MEMENTO.jpg?1706621858)

# DIY IoT Doorbell Camera with MEMENTO

## Assembly

## JST Cables

Get the 3-pin JST cables ready by cutting off the red wires from the sets.&nbsp;

Using wire stripper, remove a bit of insulation from each wire.

Tin the tips of the wires with a bit of solder to keep the strands of wire from fraying.

![adafruit_products_JST-cables.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/307/medium640/adafruit_products_JST-cables.jpg?1706550959)

## Solder Cables

Solder one of the 3-pin JST cable to the LED pins on the mini LED arcade button.

Solder the remaining JST cable to the switch pins.

![adafruit_products_btn-led-wiring.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/308/medium640/adafruit_products_btn-led-wiring.jpg?1706550985)

![adafruit_products_btn-sw-wiring.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/309/medium640/adafruit_products_btn-sw-wiring.jpg?1706550999)

## Wired Button

Double check the wires have been properly soldered to the pins on the mini LED arcade button.

![adafruit_products_btn-wired.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/310/medium640/adafruit_products_btn-wired.jpg?1706551010)

## Memento PCB Mount

Get the Memento, PCB mount and hardware screws ready.

Place the PCB mount over the Memento PCB with the mounting holes lined up.

![adafruit_products_memento-pcb-mount.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/311/medium640/adafruit_products_memento-pcb-mount.jpg?1706551035)

![adafruit_products_memento-pcb-mount-fit.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/314/medium640/adafruit_products_memento-pcb-mount-fit.jpg?1706551079)

## Secure Memento

Use four M3 x 6mm long machine screws to secure the PCB mount to the standoffs on the Memento camera board.

![adafruit_products_memento-pcb-mount-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/312/medium640/adafruit_products_memento-pcb-mount-installing.jpg?1706551058)

![adafruit_products_memento-pcb-mount-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/313/medium640/adafruit_products_memento-pcb-mount-installed.jpg?1706551067)

## Button Parts

Get the mini LED arcade button case, sleeve and included hex nut ready.

![adafruit_products_button-case.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/315/medium640/adafruit_products_button-case.jpg?1706551095)

## Install Button

Insert the 3D printed sleeve over the mini arcade button.

Slide the two JST cables through the front hole of the 3D printed button case.

Slip the included mini arcade button hex nut over the two JST cables.

![adafruit_products_button-sleeve-install.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/316/medium640/adafruit_products_button-sleeve-install.jpg?1706551112)

![adafruit_products_button-nut-install.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/317/medium640/adafruit_products_button-nut-install.jpg?1706551122)

## Secure Button

Insert the mini arcade button with sleeve into the hole in the button case.

Secure the mini arcade button using the included hex nut.

![adafruit_products_button-secured.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/318/medium640/adafruit_products_button-secured.jpg?1706551135)

![adafruit_products_button-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/319/medium640/adafruit_products_button-installed.jpg?1706551144)

## Install Battery

Plug in the 420mAh lipo battery into the Memento's battery port.&nbsp;

Use a piece of a double sided tape or mounting tack to secure the battery to the Memento PCB.

![adafruit_products_memento-battery-install.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/320/medium640/adafruit_products_memento-battery-install.jpg?1706551164)

## Test Button

Locate the JST cable connected to the mini arcade button's LED and connect it to the A1 port on the Memento.

Plug in the JST cable from the buttons switch to the A0 port on the Memento.

Use the on-board slide switch to power on the Memento and test the circuit.

![adafruit_products_button-memento-test.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/321/medium640/adafruit_products_button-memento-test.jpg?1706551178)

## Connect Button to Memento

Disconnect the JST cables from them Memento.

Thread the two cables from the mini arcade button through the camera case.

Reconnect the JST cables&nbsp; to the Memento.

Double check the orientation of the board and case are correct.

![adafruit_products_memento-cables-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/322/medium640/adafruit_products_memento-cables-installing.jpg?1706551250)

## Install Memento

Carefully slide the Memento into the camera case.

![adafruit_products_memento-case-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/323/medium640/adafruit_products_memento-case-installing.jpg?1706551275)

## Camera Case

Push the PCB mount into the camera case so that the Memento's USB port lines up with the cutout.

![adafruit_products_memento-case-inserted.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/324/medium640/adafruit_products_memento-case-inserted.jpg?1706551292)

![adafruit_products_memento-usb.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/325/medium640/adafruit_products_memento-usb.jpg?1706551306)

## Snap Fit Cases

Adjust the excess wire from the JST cables so they're fitted inside the case.

Join the button case to the camera case by snap fitting them together.

![adafruit_products_camera-btn-case-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/326/medium640/adafruit_products_camera-btn-case-installing.jpg?1706551332)

![adafruit_products_camera-button-case-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/327/medium640/adafruit_products_camera-button-case-installed.jpg?1706551341)

## Secure PCB mount to Case

Use two M3 x 6mm long machine screws to secure the PCB mount to the camera case.

![adafruit_products_camera-case-secure.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/328/medium640/adafruit_products_camera-case-secure.jpg?1706551357)

![adafruit_products_camera-case-secure-B.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/329/medium640/adafruit_products_camera-case-secure-B.jpg?1706551426)

## Install Tripod Screw (Optional)

Get the 3/8 to 1/4-20 threaded tripod screw and bottom cover.

Insert and fasten the tripod screw into the thread on the bottom cover using a wide flat head tool.

![adafruit_products_bottom-tripod-screw.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/330/medium640/adafruit_products_bottom-tripod-screw.jpg?1706551452)

![adafruit_products_bottom-screw-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/331/medium640/adafruit_products_bottom-screw-installed.jpg?1706551459)

## Install Bottom Cover

Press the bottom cover into the bottom of the button case.

![adafruit_products_bottom-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/332/medium640/adafruit_products_bottom-installing.jpg?1706551480)

## Install Top Cover

Orient the top cover with the camera case so the built-in switch actuator is lined up with the Memento's built-in slide switch.

Press the top cover onto the camera case.

![adafruit_products_top-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/333/medium640/adafruit_products_top-installing.jpg?1706551496)

![adafruit_products_top-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/334/medium640/adafruit_products_top-installed.jpg?1706551504)

## Final Build

Use the switch actuator in the top cover to power on the Memento.

Congratulations on your build!

![adafruit_products_final-test.jpg](https://cdn-learn.adafruit.com/assets/assets/000/127/335/medium640/adafruit_products_final-test.jpg?1706551516)

# DIY IoT Doorbell Camera with MEMENTO

## Install CircuitPython

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the **CIRCUITPY** drive to iterate.

## CircuitPython Quickstart

Follow this step-by-step to quickly get CircuitPython running on your board.

Warning: Make sure you use CircuitPython 9.0.0 final or later. CircuitPython 9.0.0-beta.1 and earlier have a bug that can corrupt the fileystem.

```auto
import storage
storage.erase_filesystem()
```

Your board will reboot after running this.

[Download the latest version of CircuitPython for this board via circuitpython.org](https://circuitpython.org/board/adafruit_esp32s3_camera/)
Warning: As of CircuitPython 9, you'll need to create a folder called "sd" on your CIRCUITPY drive to mount the microSD card, if it's not already there.

[Follow these steps to create the /sd directory](https://learn.adafruit.com/adafruit-memento-camera-board/circuitpython-memento-starter-projects)
 **Click the link above to download the latest CircuitPython UF2 file.**

Save it wherever is convenient for you.

![install_circuitpython_on_most_boards_CircuitPython_downloaded.jpg](https://cdn-learn.adafruit.com/assets/assets/000/102/129/medium640/install_circuitpython_on_most_boards_CircuitPython_downloaded.jpg?1620922559)

![](https://cdn-learn.adafruit.com/assets/assets/000/126/734/medium800/adafruit_products_resetNeo.jpg?1702908010)

Plug your board into your computer, using a known-good data-sync cable, directly, or via an adapter if needed.

Double-click the **reset** button (highlighted in red above), and you will see the **RGB status LED(s)** turn green (highlighted in green above). If you see red, try another port, or if you're using an adapter or hub, try without the hub, or different adapter or hub.

For this board, tap reset and wait for the LED to turn purple, and as soon as it turns purple, tap reset again. The second tap needs to happen while the LED is still purple.

If you do not see the LED turning purple, you will need to reinstall the UF2 bootloader. See the **Factory Reset** page in this guide for details.

If double-clicking doesn't work the first time, try again. Sometimes it can take a few tries to get the rhythm right!

A lot of people end up using charge-only USB cables and it is very frustrating! **Make sure you have a USB cable you know is good for data sync.**

You will see a new disk drive appear called **CAMERABOOT**. Drag the **adafruit-circuitpython-adafruit\_esp32s3\_camera-etc.uf2** file to **CAMERABOOT**.

![adafruit_products_cameraboot.png](https://cdn-learn.adafruit.com/assets/assets/000/126/740/medium640/adafruit_products_cameraboot.png?1702932896)

The **BOOT** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

That's it!

![install_circuitpython_on_most_boards_CIRCUITPY.jpg](https://cdn-learn.adafruit.com/assets/assets/000/102/130/medium640/install_circuitpython_on_most_boards_CIRCUITPY.jpg?1620923145)

# DIY IoT Doorbell Camera with MEMENTO

## Create Your settings.toml File

CircuitPython works with WiFi-capable boards to enable you to make projects that have network connectivity. This means working with various passwords and API keys. As of [CircuitPython 8](https://circuitpython.org/downloads), there is support for a **settings.toml** file. This is a file that is stored on your **CIRCUITPY** drive, that contains all of your secret network information, such as your SSID, SSID password and any API keys for IoT services. It is designed to separate your sensitive information from your **code.py** file so you are able to share your code without sharing your credentials.

CircuitPython previously used a **secrets.py** file for this purpose. The **settings.toml** file is quite similar.

Warning: Your **settings.toml** file should be stored in the main directory of your **CIRCUITPY** drive. It should not be in a folder.

## CircuitPython **settings.toml** File

This section will provide a couple of examples of what your **settings.toml** file should look like, specifically for CircuitPython WiFi projects in general.

The most minimal **settings.toml** file must contain your WiFi SSID and password, as that is the minimum required to connect to WiFi. Copy this example, paste it into your **settings.toml** , and update:

- `your_wifi_ssid`
- `your_wifi_password`

```auto
CIRCUITPY_WIFI_SSID = "your_wifi_ssid"
CIRCUITPY_WIFI_PASSWORD = "your_wifi_password"
```

Many CircuitPython network-connected projects on the Adafruit Learn System involve using Adafruit IO. For these projects, you must _also_ include your Adafruit IO username and key. Copy the following example, paste it into your settings.toml file, and update:

- `your_wifi_ssid`
- `your_wifi_password`
- `your_aio_username`
- `your_aio_key`

```auto
CIRCUITPY_WIFI_SSID = "your_wifi_ssid"
CIRCUITPY_WIFI_PASSWORD = "your_wifi_password"
ADAFRUIT_AIO_USERNAME = "your_aio_username"
ADAFRUIT_AIO_KEY = "your_aio_key"
```

Some projects use different variable names for the entries in the **settings.toml** file. For example, a project might use `ADAFRUIT_AIO_ID` in the place of `ADAFRUIT_AIO_USERNAME`. **If you run into connectivity issues, one of the first things to check is that the names in the settings.toml file match the names in the code.**

Warning: Not every project uses the same variable name for each entry in the **settings.toml** file! Always verify it matches the code.

## **settings.toml** File Tips
Here is an example **settings.toml** file.

```auto
# Comments are supported
CIRCUITPY_WIFI_SSID = "guest wifi"
CIRCUITPY_WIFI_PASSWORD = "guessable"
CIRCUITPY_WEB_API_PORT = 80
CIRCUITPY_WEB_API_PASSWORD = "passw0rd"
test_variable = "this is a test"
thumbs_up = "\U0001f44d"
```

In a **settings.toml** file, it's important to keep these factors in mind:

- Strings are wrapped in double quotes; ex: `"your-string-here"`
- Integers are _ **not** _ quoted and may be written in decimal with optional sign (`+1`, `-1`, `1000`) or hexadecimal (`0xabcd`).
  - Floats (decimal numbers), octal (`0o567`) and binary (`0b11011`) are not supported.

- Use `\u` escapes for weird characters, `\x` and `\ooo` escapes are not available in **.toml** files
  - Example: `\U0001f44d` for 👍 (thumbs up emoji) and `\u20ac` for € (EUR sign)

- Unicode emoji, and non-ASCII characters, stand for themselves as long as you're careful to save in "UTF-8 without BOM" format

&nbsp;

&nbsp;

When your&nbsp; **settings.toml&nbsp;** file is ready, you can save it in your text editor with the **.toml** &nbsp;extension.

![adafruit_products_dotToml.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/071/medium640/adafruit_products_dotToml.jpg?1671034293)

## Accessing Your **settings.toml** Information in **code.py**
In your **code.py** file, you'll need to `import` the `os` library to access the **settings.toml** file. Your settings are accessed with the `os.getenv()` function. You'll pass your settings entry to the function to import it into the **code.py** file.

```python
import os

print(os.getenv("test_variable"))
```

![](https://cdn-learn.adafruit.com/assets/assets/000/117/072/medium800/adafruit_products_tomlOutput.jpg?1671034496)

In the upcoming CircuitPython WiFi examples, you'll see how the **settings.toml&nbsp;** file is used for connecting to your SSID and accessing your API keys.

# DIY IoT Doorbell Camera with MEMENTO

## Code

Once you've finished setting up your MEMENTO camera with CircuitPython, you can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the **&nbsp;Download Project Bundle** &nbsp;button in the window below. It will download to your computer as a zipped folder.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/MEMENTO/Memento_IOT_Doorbell/code.py

After downloading the Project Bundle, plug your MEMENTO into the computer's USB port with a known good USB data+power cable. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called&nbsp; **CIRCUITPY**. Unzip the folder and copy the following items to the MEMENTO's&nbsp; **CIRCUITPY** &nbsp;drive.

- **lib** &nbsp;folder
- **code.py**

Your MEMENTO&nbsp; **CIRCUITPY** &nbsp;drive should look like this after copying the&nbsp; **lib** &nbsp;folder and the&nbsp; **code.py** &nbsp;file.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/088/medium800/adafruit_products_circuitpy-drive.png?1705590012)

## Code Overview
### WiFi Connect

This section of code connects to the WiFi SSID defined by the **settings.toml** file.

```auto
### WiFi ###
# Add settings.toml to your filesystem CIRCUITPY_WIFI_SSID and CIRCUITPY_WIFI_PASSWORD keys
# with your WiFi credentials. DO NOT share that file or commit it into Git or other
# source control.

# Set your Adafruit IO Username, Key and Port in settings.toml
# (visit io.adafruit.com if you need to create an account,
# or if you need your Adafruit IO key.)
aio_username = os.getenv("ADAFRUIT_AIO_USERNAME")
aio_key = os.getenv("ADAFRUIT_AIO_KEY")

print(f"Connecting to {os.getenv('CIRCUITPY_WIFI_SSID')}")
wifi.radio.connect(
    os.getenv("CIRCUITPY_WIFI_SSID"), os.getenv("CIRCUITPY_WIFI_PASSWORD")
)
print(f"Connected to {os.getenv('CIRCUITPY_WIFI_SSID')}!")
```

### Initialize Adafruit IO

This section of code creates a new Adafruit IO client object, which uses the Adafruit IO HTTP API to communicate with the Internet. Using the Adafruit IO client object, it attempts to get the Adafruit IO "camera" feed. If it fails to obtain this feed, it will create a new feed.

```auto
# Create new socket and SSL context
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())

# Initialize an Adafruit IO HTTP API object
io = IO_HTTP(os.getenv("ADAFRUIT_AIO_USERNAME"), os.getenv("ADAFRUIT_AIO_KEY"), requests)

try:
    # Get the 'camera' feed from Adafruit IO
    feed_camera = io.get_feed("camera")
except AdafruitIO_RequestError:
    # If no 'camera' feed exists, create one
    feed_camera = io.create_new_feed("camera")
```

## Initialize Camera

The camera is initialized and the TFT's backlight is turned off (since we're putting it in an enclosure - we don't need to waste power). The camera's default pixel strand is deinitialized as the project uses the A1 pin which later will be used to control the button's LED.

```auto
# Initialize memento camera
pycam = adafruit_pycamera.PyCamera()
# Turn off TFT backlight
pycam.display.brightness = 0.0
# Deinitialize the MEMENTO's NeoPixels
# Why? The pixels use board.A1 and we want to use it to control the doorbell LED
pycam.pixels.deinit()
```

## Set up Push-button

The push button is configured as an input with a pull-up on the pin `A0`. Then, the push button's LED is configured as an output on the pin `A1`. This lets us read from the push-button and control the LED separately.&nbsp;

```auto
# Set up the button
pin_button = digitalio.DigitalInOut(board.A0)
pin_button.direction = digitalio.Direction.INPUT
pin_button.pull = digitalio.Pull.UP

# Set up the button's LED
led = digitalio.DigitalInOut(board.A1)
led.direction = digitalio.Direction.OUTPUT
led.value = True
```

## Main Loop

The code's main, `while True`, loop waits for the doorbell button to be pressed (`if not pin_button.``value`). If the button is pressed, the LED is turned off to signal that something is happening. The MEMENTO's speaker also plays a descending tone, like a doorbell. The `capture_send_image()` method is then called.

If a button press is not detected, the code waits 1 millisecond before running again. This delay is added for "debouncing" the button.

```auto
while True:
    # Wait until the doorbell is pressed
    if not pin_button.value:
        print("Doorbell pressed!")
        # Turn the doorbell LED off to signal that it has been pressed
        led.value = False
        # Play a doorbell tone using the speaker
        pycam.tone(95, 0.5)
        pycam.tone(70, 0.5)
        capture_send_image()
    time.sleep(0.01)
```

## Capturing an Image

Within the `capture_and_send_image() `method, the camera is forced to autofocus on the person pressing the button. Then an image is captured in JPEG format and its bytes are saved into an object, `jpeg`.

```auto
def capture_send_image():
    """Captures an image and send it to Adafruit IO."""
    # Force autofocus and capture a JPEG image
    pycam.autofocus()
    jpeg = pycam.capture_into_jpeg()
    print("Captured image!")
```

### Send the Image to Adafruit IO

While the image's binary data could be sent to Adafruit IO, we strongly recommend encoding images sent to Adafruit IO using base64 so you can store/retrieve it with REST and JSON. So, the image is encoded into base64 (`b2a_base64(jpeg)`)and sent (`io.send_data()`) to the camera feed on your Adafruit IO account.

This code section also contains a check for whether the image capture succeeded or failed (jpeg data would be `None`).

```auto
if jpeg is not None:
        # Encode JPEG data into base64 for sending to Adafruit IO
        print("Encoding image...")
        encoded_data = binascii.b2a_base64(jpeg).strip()
        # Send encoded_data to Adafruit IO camera feed
        print("Sending image to Adafruit IO...")
        io.send_data(feed_camera["key"], encoded_data)
        print("Sent image to IO!")
    else:
        print("ERROR: JPEG frame capture failed!")
```

# DIY IoT Doorbell Camera with MEMENTO

## Enable Email Notifications

In Adafruit IO, **Reactive**  **Actions** are a way to integrate basic logic into your IoT projects, without programming. At a basic level, they check if a feed's value is somehow comparable to a value or even another feed. If so, they can be configured to send an email notification, post a webhook, or even publish a message to another feed

Let's set up a Reactive Action to send an email when a new photo has been taken by the doorbell's camera.

On Adafruit.io, [navigate to the actions page](https://io.adafruit.com/actions). From the actions page, click the "+ New Action" button.

![](https://cdn-learn.adafruit.com/assets/assets/000/126/801/medium800/adafruit_products_new_action_click.png?1703179993)

On the next page, select the Reactive Action.

![](https://cdn-learn.adafruit.com/assets/assets/000/126/803/medium800/adafruit_products_choose_action.png?1703180086)

Configure the action **&nbsp;** to check if the _camera feed_ has _any new data&nbsp;_(such as a new image posted to the feed).

![adafruit_products_is_any.png](https://cdn-learn.adafruit.com/assets/assets/000/126/804/medium640/adafruit_products_is_any.png?1703180544)

Under **Then** , select _email me._ Select the _camera_ feed.

![adafruit_products_action_email_1.png](https://cdn-learn.adafruit.com/assets/assets/000/126/805/medium640/adafruit_products_action_email_1.png?1703180851)

At the bottom of the form, you can set the _subject_ and _body_ of the email.&nbsp;

The **Limit Every** option decides how often the action will run. If you want to receive an email every time the doorbell is pressed, set this option to run every _Ten Seconds_.&nbsp;

As an example, here's what my doorbell will email me when it is pressed:

![](https://cdn-learn.adafruit.com/assets/assets/000/126/806/medium800/adafruit_products_action_email_context.png?1703181963)

After configuring the action, click Submit. The new action is listed on the Actions page with the status set to Active.

![](https://cdn-learn.adafruit.com/assets/assets/000/126/807/medium800/adafruit_products_active_action.png?1703182642)

Since the camera feed hasn't received a value yet, this trigger has not been executed. We'll demonstrate this trigger on this guide's _Usage_ page by pressing the doorbell button.

# DIY IoT Doorbell Camera with MEMENTO

## Usage

## Doorbell Usage
Plug the MEMENTO into power. When the code is ready, the doorbell's LED will turn on.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/479/medium800/adafruit_products_memento_db.png?1707156858)

When someone pushes the button, the MEMENTO's buzzer will emit a chime and the LED will turn off.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/480/medium800/adafruit_products_cam_press.png?1707156970)

Behind the scenes, the MEMENTO's camera autofocuses and takes a picture. The image is encoded to reduce its size and is sent to Adafruit IO.&nbsp;

To see the image, navigate to your Adafruit IO Feeds page and click on the&nbsp;_camera_ feed.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/217/medium800/adafruit_products_cam-feed-click.png?1706205458)

The image captured by the camera should appear on the feed as a data-point and an image preview will be visible.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/224/medium800/adafruit_products_camera_feed.png?1706207587)

You should receive an email containing the photo captured by the MEMENTO doorbell, and a message saying there's a new visitor at your door.

![](https://cdn-learn.adafruit.com/assets/assets/000/127/226/medium800/adafruit_products_email-trigger.png?1706208056)


## Featured Products

### MEMENTO - Python Programmable DIY Camera - Bare Board

[MEMENTO - Python Programmable DIY Camera - Bare Board](https://www.adafruit.com/product/5420)
Make memories, or just a cool camera-based project,&nbsp;with **Adafruit's MEMENTO Camera Board**. It's a development board with everything you need to create programmable camera and vision projects: with a camera module, TFT preview screen, buttons, SD card slot and...

Out of Stock
[Buy Now](https://www.adafruit.com/product/5420)
[Related Guides to the Product](https://learn.adafruit.com/products/5420/guides)
### Mini LED Arcade Button - 24mm Translucent Clear

[Mini LED Arcade Button - 24mm Translucent Clear](https://www.adafruit.com/product/3429)
A button is a button, and a switch is a switch, but these translucent arcade buttons are in a class of their own. Particularly because they have **LEDs built right in!** That's right, you'll be button-mashing amidst a wash of beautiful light with these lil'...

In Stock
[Buy Now](https://www.adafruit.com/product/3429)
[Related Guides to the Product](https://learn.adafruit.com/products/3429/guides)
### Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh

[Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh](https://www.adafruit.com/product/4236)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 420mAh for a total of about 1.55 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4236)
[Related Guides to the Product](https://learn.adafruit.com/products/4236/guides)
### STEMMA JST PH 2mm 3-Pin to Male Header Cable - 200mm

[STEMMA JST PH 2mm 3-Pin to Male Header Cable - 200mm](https://www.adafruit.com/product/3893)
This cable will let you turn a JST PH 3-pin cable port into 3 individual wires with high-quality 0.1" male header plugs on the end. We're carrying these to match up with our Hallowing, for extending and connecting sensors or LEDs - and the wires are even color coded!

<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/3893)
[Related Guides to the Product](https://learn.adafruit.com/products/3893/guides)
### Pink and Purple Woven USB A to USB C Cable - 1 meter long

[Pink and Purple Woven USB A to USB C Cable - 1 meter long](https://www.adafruit.com/product/5153)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also made for USB C for our modernized breakout boards, Feathers, and more.&nbsp;&nbsp;[If you want something just like it but for Micro B, we...](https://www.adafruit.com/product/4111)

Out of Stock
[Buy Now](https://www.adafruit.com/product/5153)
[Related Guides to the Product](https://learn.adafruit.com/products/5153/guides)
### Adafruit IO+ Subscription Pass – One Year

[Adafruit IO+ Subscription Pass – One Year](https://www.adafruit.com/product/3792)
The all-in-one Internet of Things service from Adafruit you know and love is now _even better_ with IO+. The 'plus' stands for MORE STUFF! More feeds, dashboards, storage, speed. Power up your [Adafruit IO](https://io.adafruit.com/) with the $99 pass for 1 year of the...

In Stock
[Buy Now](https://www.adafruit.com/product/3792)
[Related Guides to the Product](https://learn.adafruit.com/products/3792/guides)
### Camera and Tripod 3/8" to 1/4" Adapter Screw

[Camera and Tripod 3/8" to 1/4" Adapter Screw](https://www.adafruit.com/product/2392)
_Whaddya got a screw loose or something?_

This **3/8" to 1/4"**  **Adapter Screw** is super handy if you're building projects that connect to a tripod or a camera. It's a simple fix for getting a tripod with a 1/4" machine screw...

In Stock
[Buy Now](https://www.adafruit.com/product/2392)
[Related Guides to the Product](https://learn.adafruit.com/products/2392/guides)

## Related Guides

- [Adafruit MEMENTO Camera Board](https://learn.adafruit.com/adafruit-memento-camera-board.md)
- [All the Internet of Things - Episode Four: Adafruit IO](https://learn.adafruit.com/all-the-internet-of-things-episode-four-adafruit-io.md)
- [ePaper Camera](https://learn.adafruit.com/epaper-camera.md)
- [Scan QR Codes with CircuitPython](https://learn.adafruit.com/scan-qr-codes-with-circuitpython.md)
- [Use Apple HomeKit Devices with itsaSNAP and Adafruit IO](https://learn.adafruit.com/use-apple-homekit-devices-with-itsasnap.md)
- [Quick Start: Pico W / 2W with WipperSnapper](https://learn.adafruit.com/quick-start-the-pico-w-with-wippersnapper.md)
- [Adafruit IO Basics: Feeds](https://learn.adafruit.com/adafruit-io-basics-feeds.md)
- [Ikea Vindriktning Hack with QT Py ESP32-S3 and Adafruit IO](https://learn.adafruit.com/ikea-vindriktning-hack-with-qt-py-esp32-s3-and-adafruit-io.md)
- [Using Piezo Buzzers with WipperSnapper](https://learn.adafruit.com/using-piezo-buzzers-with-wippersnapper.md)
- [Adafruit IO Basics: Analog Output](https://learn.adafruit.com/adafruit-io-basics-analog-output.md)
- [How to Add a New Board to WipperSnapper](https://learn.adafruit.com/how-to-add-a-new-board-to-wippersnapper.md)
- [OpenAI Image Descriptors with MEMENTO](https://learn.adafruit.com/openai-image-descriptors-with-memento.md)
- [Face Tracking Robot with MEMENTO](https://learn.adafruit.com/face-tracking-robot-with-memento.md)
- [Quickstart: Adafruit IO WipperSnapper ](https://learn.adafruit.com/quickstart-adafruit-io-wippersnapper.md)
- [No-Code IKEA Vindriktning Air Quality Sensor Hack with Adafruit IO](https://learn.adafruit.com/no-code-ikea-vindriktning-hack-with-qt-py-esp32-s3-and-adafruit-io.md)
- [Set up Web Workflow on the Adafruit MEMENTO](https://learn.adafruit.com/set-up-web-workflow-on-the-adafruit-memento.md)
