• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 CAM Project without deep sleep mode

Q&A Forum › Category: ESP32 › ESP32 CAM Project without deep sleep mode
0 Vote Up Vote Down
Ashish Garg asked 3 years ago

Hello,

I am trying to use ESP32 CAM for taking a pic when the magnetic switch is open, save to the SD card, then email the picture. And I want to publish  (eg. front gate open) and subscribe it with MQTT.

And I don’t want ESP32 CAM to go into deep sleep mode. Actually I used https://raw.githubusercontent.com/RuiSantosdotme/ESP32-CAM-Arduino-IDE/master/ESP32-CAM-Change-Settings/ESP32-CAM-Change-Settings.ino

The reason for choosing this is that I am really confused about which part I should put in the void loop in the case of the esp32cam module.

That’s why I found this https://raw.githubusercontent.com/RuiSantosdotme/ESP32-CAM-Arduino-IDE/master/ESP32-CAM-Change-Settings/ESP32-CAM-Change-Settings.ino  and used.

At present in the following code, I only tried to take a pic, store in the SD card, and glow the LED (pin 16 as output) when the magnetic switch (pin 13 as input pull up) is high.

code: https://pastebin.com/pSGyaJvp

Serial Monitor: https://imgur.com/59L3Q4J

Kindly help me where I am getting wrong.

Thanks

Question Tags: ESP32-Cam
7 Answers
1 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.

You’re using GPIO 13 to attach the magnetic reed switch.
However, GPIO13 is used by the microSD card. That’s why you get that initialization error.

If you initialize the microSD card as follows:

SD_MMC.begin("/sdcard", true)

Instead of

SD_MMC.begin()

You’ll be able to control GPIO 4 as an output, if I’m not wrong. Can you try attaching your LED to GPIO 4 instead?

Regards,
Sara

0 Vote Up Vote Down
Ashish Garg answered 3 years ago

Thanks for the help mam. I tried further as per your recommendation and added the email part. Now the problem is it does not attach the picture in the email. My code is as follows:
Code: https://pastebin.com/mddCrsJf
Serial monitor: https://imgur.com/00wfff9
email: https://imgur.com/qP5cRuX
Please help me, what I am missing.
Thanks
 

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
Thanks for sharing your code with us.
In line 304, you have

smtpData.addAttachFile(path);

replace with:

smtpData.addAttachFile(path, "image/jpg");

Then, tell me if it solved the problem.
Regards,
Sara

0 Vote Up Vote Down
Ashish Garg answered 3 years ago

Thanks for the answer mam, but unfortunately it doesn’t work. I changed that line but It is  same as earlier.
Thanks

1 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
Move the incrementation of the picture number (pictureNumber++) after sending the email. Otherwise you’re trying to send a photo with a number that doesn’t exist yet.

//Take and Save Photo
if (digitalRead(16)==HIGH){
takeSavePhoto(path);
Serial.printf("Picture file name: %s\n", path.c_str());
email();
pictureNumber++;

Now, it should work.
Regards,
Sara

0 Vote Up Vote Down
Ashish Garg answered 3 years ago

Thanks a lot, Mam, it is working. I appreciate your help. Thanks, mam. Now I will add the MQTT part (publishing and subscribing) in this code.
Thanks

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Great!
I’ll close this question.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.