• 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

ESPCAM :237:1: error: no return statement

Q&A Forum › Category: Other › ESPCAM :237:1: error: no return statement
0 Vote Up Vote Down
Jean Pierre Daviau asked 5 years ago

 Hi,
https://randomnerdtutorials.com/esp32-cam-send-photos-email/     

I am trying to compile (the code from the pdf v1.1) and I have this complain 

In function 'boolean sendPhoto()':
motionDetectorEmailRuis:237:1: error: no return statement in function returning non-void [-Werror=return-type]tart your code here

Regards,
 
JPD

Question Tags: email, espcam, motionDetector, no return statement
10 Answers
0 Vote Up Vote Down
Jean Pierre Daviau answered 5 years ago

Ok, I wrote a return true;  and it works.
 
Except for the flash… does not flash.
 
Regards,
 
JPD 

0 Vote Up Vote Down
Steve Mercer answered 5 years ago

Did you copy/paste the code exactly from the web page? On the page the return type for sendPhoto() is void whereas your error message says it’s expecting a return type of boolean. Seeing as the function doesn’t return anything you get the error message (ie. it’s expecting a return of boolean and the function doesn’t have a return statement).
 
If you have modified the code in any way make sure that you return something if you tell the compiler there is a return type.
 
Maybe the PDF is different from the web page?

0 Vote Up Vote Down
Jean Pierre Daviau answered 5 years ago

In the pdf

boolean sendPhoto()

In the github file linked by the pdf
https://raw.githubusercontent.com/RuiSantosdotme/ESP32-CAM-eBook/master/Code/Module_3/Motion_Detector_Photo_Email/Motion_Detector_Photo_Email.ino
 
In the web page void sendPhoto()

void sendPhoto()

And still:
The flash… does not flash.
Not surprisingly, there is no  #include “SD_MMC.h”   and code lines associated goes with it.

0 Vote Up Vote Down
Jean Pierre Daviau answered 5 years ago

Another thing

SPIFFS mounted successfully
IP Address: http://189.143.0.115
Taking a photo...
Picture file name: /photo.jpg
The picture has been saved in /photo.jpg - Size: 0 bytes
Taking a photo...
Picture file name: /photo.jpg
The picture has been saved in /photo.jpg - Size: 0 bytes
Taking a photo...
Picture file name: /photo.jpg
The picture has been saved in /photo.jpg - Size: 0 bytes
Taking a photo...
Picture file name: /photo.jpg
The picture has been saved in /photo.jpg - Size: 123008 bytes
Sending email...

I tried to put a delay in the do-whiles loop unsuccessfully.
Regards
JPD


1 Vote Up Vote Down
Steve Mercer answered 5 years ago

You are right.
 
I believe Rui/Sara should review the code in the three places; test and update so they are all the same and that it works. The code at the link would definitely not work.

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

Hi.
I’m sorry about that issue.
I don’t know how that happened.
The function doesn’t return anything, so it should be void.
The code on the link was updated. Can you try it?
Regards,
Sara

0 Vote Up Vote Down
Jean Pierre Daviau answered 5 years ago

Hi,

I guess you are talking about codeThe void sendPhoto( void ) was a lesser problem.

Connecting to WiFi.....WiFi.RSSI: -45

SPIFFS mounted successfully
IP Address: http://189.143.0.115
Taking a photo...
Picture file name: /photo.jpg
The picture has been saved in /photo.jpg - Size: 0 bytes
Taking a photo...
Picture file name: /photo.jpg
The picture has been saved in /photo.jpg - Size: 0 bytes
Taking a photo...
Picture file name: /photo.jpg
The picture has been saved in /photo.jpg - Size: 0 bytes
Taking a photo...
Picture file name: /photo.jpg
The picture has been saved in /photo.jpg - Size: 135680 bytes
Sending email...
Connecting to SMTP server...
SMTP server connected, wait for response...
Identification...
Authentication...
Sign in...
Sending Email header...
Sending Email body...
Sending attachments...
/photo.jpg
Finalize...
Finished
Email sent successfully
Going to sleep now

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

Hi.
That result means that the camera couldn’t get the photo at the first try. Only at the fourth try. That’s why there’s an if statement checking if the photo was successfully taken and saved.
However, I don’t know how to solve that issue to get things always at the first try..
Regards,
Sara

0 Vote Up Vote Down
Jean Pierre Daviau answered 5 years ago

Maybe the spiff writing is too slow or too fast, or else.

A problem of memory formating between spiff memory, flash, etc?

A part of it could be written in assembly….

…

I dont know either ;o)

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

Hi.
Yes, it is probably a problem while writing the file to spiffs. However, I really don’t know how to solve that.
Unfortunately, I’m not familiar with Assembly :/
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] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

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

Copyright © 2013-2025 · 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.