Expected constructor, destructor or type conversion before '(' token

Hello Everyone , Im encountering this problem It says Expected constructor, destructor or type conversion before '(' token . Attaching .ino file and the Error Snapshot .Thank you

sketch_mar18a.ino (11.1 KB)

sketch_mar18a.ino (11.1 KB)

Please copy the complete error message (there is a button on the screen to do it) and post it here

Arduino: 1.8.5 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled, ck, 26 MHz, 40MHz, DOUT (compatible), 512K (no SPIFFS), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

sketch_mar28a:136: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER2_COMPA_vect) //triggered when Timer2 counts to 124

^

C:\Users\LENOVO\Documents\Arduino\sketch_mar28a\sketch_mar28a.ino: In function 'void interruptSetup()':

sketch_mar28a:86: error: 'TCCR2A' was not declared in this scope

TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE

^

sketch_mar28a:87: error: 'TCCR2B' was not declared in this scope

TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER

^

sketch_mar28a:88: error: 'OCR2A' was not declared in this scope

OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE

^

sketch_mar28a:89: error: 'TIMSK2' was not declared in this scope

TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A

^

C:\Users\LENOVO\Documents\Arduino\sketch_mar28a\sketch_mar28a.ino: At global scope:

sketch_mar28a:136: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER2_COMPA_vect) //triggered when Timer2 counts to 124

^

Multiple libraries were found for "OneWire.h"
Used: C:\Users\LENOVO\Documents\Arduino\libraries\OneWire
Not used: C:\Users\LENOVO\Documents\Arduino\libraries\OneWire-master
exit status 1
expected constructor, destructor, or type conversion before '(' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

ESP8266 ModuleThere's your answer

try:

void ISR(TIMER2_COMPA_vect)

I believe you are trying to make a function here...

wolframore:
try:

void ISR(TIMER2_COMPA_vect)

I believe you are trying to make a function here...

Better answer: "Try compiling for the correct processor"

Actually I'll be using a Esp8266 to send data on cloud so that the reason why I chose Generic Esp8266 . and If Dont Choose Esp8266 Board it wont recognize my Header file .

anandraut:
Actually I'll be using a Esp8266

So why are you trying to compile code written for an AVR?

(I can't see your code because I'm posting from my phone)

Does the ESP8266 have a Timer2?

it has 2 just not "2"... well I was addressing the construct error...

Im using Using Mega to Process data and Esp8266 to send data on cloud .

If I include the Header file of ESP8266 which is include<ESP8266WFi.h> I get this Error if I choose esp8266 board
Arduino: 1.8.5 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled, ck, 26 MHz, 40MHz, DOUT (compatible), 512K (no SPIFFS), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Build options changed, rebuilding all
sketch_mar28a:193: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER2_COMPA_vect) //triggered when Timer2 counts to 124

^

C:\Users\LENOVO\Documents\Arduino\sketch_mar28a\sketch_mar28a.ino: In function 'void interruptSetup()':

sketch_mar28a:143: error: 'TCCR2A' was not declared in this scope

TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE

^

sketch_mar28a:144: error: 'TCCR2B' was not declared in this scope

TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER

^

sketch_mar28a:145: error: 'OCR2A' was not declared in this scope

OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE

^

sketch_mar28a:146: error: 'TIMSK2' was not declared in this scope

TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A

^

C:\Users\LENOVO\Documents\Arduino\sketch_mar28a\sketch_mar28a.ino: At global scope:

sketch_mar28a:193: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER2_COMPA_vect) //triggered when Timer2 counts to 124

^

Multiple libraries were found for "OneWire.h"
Used: C:\Users\LENOVO\Documents\Arduino\libraries\OneWire
Not used: C:\Users\LENOVO\Documents\Arduino\libraries\OneWire-master
exit status 1
expected constructor, destructor, or type conversion before '(' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

If I choose Mega Board then I get this error
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build options changed, rebuilding all
C:\Users\LENOVO\Documents\Arduino\sketch_mar28a\sketch_mar28a.ino:5:25: fatal error: ESP8266WiFi.h: No such file or directory

#include <ESP8266WiFi.h>

^

compilation terminated.

Multiple libraries were found for "OneWire.h"
Used: C:\Users\LENOVO\Documents\Arduino\libraries\OneWire
Not used: C:\Users\LENOVO\Documents\Arduino\libraries\OneWire-master
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The code in your attachment to the first post contains nothing pertaining to an ESP8266 and indeed compiles for a Mega when a stray '.' is removed.

Please explain what you are trying to do with what hardware in what configuration?

attaching code which uses esp8266 to send data to thinkspeak cloud . I delete that code back then. Sorry and Should I make new string regarding my problem no this forum

sketch_mar18a.ino (11.1 KB)

Why have you started a new thread on the same topic?

Threads merged.

I think you are trying to implement an impossible architecture with one program for the two boards with two board specific IDE's and you will need to change your approach.

  1. Use only the esp8266 programmed with the Arduino IDE and wifi libraries, and migrate the heart rate detection code to the esp8266.

  2. Use only the Mega with the IDE, and use AT commands to control the esp8266. You will have to forgo the wifi library.

  3. Independently program the MEGA and the ESP8266 with each boards version of the IDE and have the mega send the data to the esp over a serial link for transmission to Thingspeak.

If you go with cattledog's option 2, you might find this library useful:

It provides a standard Arduino Client/Server class interface for using a standard Arduino board like your Mega connected to an ESP8266 running the AT firmware.