User Serial.print in another file of the project

Hi,

I have photon hardware and I am doing development using Web IDE. The compiler is giving me error when I am using Serial.print() function in another file of the project. Let me explain this using example:

The ‘main.ino’ is a main project file. I am adding another files to the project ‘extra.cpp’ and ‘extra.h’. Now I am beginning the serial port in the setup() function in the main.ino file by calling ‘Serial.begin(115200)’. And I can use Serial.print() function anywhere in main.ino file to print messages on serial console.

But when I am using Serial.print() function in extra.cpp to print message compiler is giving me error:

‘Serial’ was not declared in this scope.

Please help me to overcome this error.

Thanks,
Dhaval

@dhaval, did you include a #include "application.h" at the top of your extra.h file? :smile:

1 Like

@peekay123,

Thanks… That works.

1 Like