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
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
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
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
Thanks for the answer mam, but unfortunately it doesn’t work. I changed that line but It is same as earlier.
Thanks
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
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