esp-idf-smtp-camera

Take a picture and Publish it via SMTP.

MIT License

Stars
6

esp-idf-smtp-camera

Take a picture and Publish it via SMTP. This project use ESP32 Camera Driver.

Hardware requirements

ESP32 development board with OV2640 camera. If you use other camera, edit sdkconfig.default. From the left:

  • Aithinker ESP32-CAM
  • Freenove ESP32-WROVER CAM
  • UICPAL ESPS3 CAM
  • Freenove ESP32S3-WROVER CAM (Clone)

Software requirements

ESP-IDF V5.0 or later. ESP-IDF V4.4 release branch reached EOL in July 2024.

Installation

For AiThinker ESP32-CAM, you need to use a USB-TTL converter and connect GPIO0 to GND.

ESP-32 USB-TTL
U0TXD RXD
U0RXD TXD
GPIO0 GND
5V 5V
GND GND
git clone https://github.com/nopnop2002/esp-idf-smtp-camera
cd esp-idf-smtp-camera
chmod 777 getpem.sh
./getpem.sh
idf.py set-target {esp32/esp32s3}
idf.py menuconfig
idf.py flash monitor

Start firmware

For AiThinker ESP32-CAM, Change GPIO0 to open and press the RESET button.

Configuration

Set the following items using menuconfig.

Wifi Setting

You can connect using the mDNS hostname instead of the IP address. config-wifi-2

You can use static IP. config-wifi-3

SMTP Server Setting

I've only tested with a Gmail account. If you want to use a non-gmail account, you need to change gmail_root_cert.pem according to this instruction.

Note about Gmail: To help keep your account secure, from May 30, 2022, Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password. Due to this change, you can no longer log in to Google from ESP-IDF using only your username and password. You will need to generate a special app password as described here. An app password is a 16-character code generated by your device. Use this code as your password.

Attached File Name Setting

You can select the file name to write to the shared folder from the following.

  • Always the same file name
  • File name based on date and time
    When you choose date and time file name, you will need an NTP server.
    The file name will be YYYYMMDD-hhmmss.jpg.
  • Add FrameSize to Remote file Name
    When this is enabled, FrameSize is added to remote file name like this.
    20210520-165740_800x600.jpg

Select Board

Select Frame Size

Large frame sizes take longer to take a picture.

Select Shutter

You can choose one of the following shutter methods

  • Shutter is the Enter key on the keyboard
    For operation check
  • Shutter is a GPIO toggle

    • Initial Sate is PULLDOWN The shutter is prepared when it is turned from OFF to ON, and a picture is taken when it is turned from ON to OFF.

    • Initial Sate is PULLUP The shutter is prepared when it is turned from ON to OFF, and a picture is taken when it is turned from OFF to ON.

I confirmed that the following GPIO can be used.

GPIO PullDown PullUp
GPIO12 OK NG
GPIO13 OK OK
GPIO14 OK OK
GPIO15 OK OK
GPIO16 NG NG
  • Shutter is TCP Socket
    You can use tcp_send.py as shutter.
    python3 ./tcp_send.py
  • Shutter is UDP Socket
    You can use udp_send.py as shutter.
    Requires netifaces.
    python3 ./udp_send.py
  • Shutter is a MQTT Publish You can use mosquitto_pub as shutter. mosquitto_pub -h broker.emqx.io -t "/take/picture" -m "hello world"

    MQTT broker is specified by one of the following.

    • IP address
      192.168.10.20
    • mDNS host name
      mqtt-broker.local
    • Fully Qualified Domain Name
      broker.emqx.io

Specifies the username and password if the server requires a password when connecting.

Flash Light

ESP32-CAM by AI-Thinker have flash light on GPIO4.

PSRAM

When you use ESP32S3-WROVER CAM, you need to set the PSRAM type.