getting error 'Serial' was not declared in this scope
I am adding Dust Sensor to my particle photon project at home,
I got this GitHub project that I want to test before implementing a final code.
I am not an expert in cpp, I wanted to modularise the dust sensor codebase to separate library so I created new dustSensor.cpp file and kept the code linked above.
but I keep getting error:
'Serial' was not declared in this scope
'Serial1' was not declared in this scope
'DEBUG' was not declared in this scope
'DEC' was not declared in this scope dustSensor.cpp:13:57:
I do have Serial.begin(57600) called in setup() function but still get the above error
serial programming softwareserial serial-data cpp
add a comment |
I am adding Dust Sensor to my particle photon project at home,
I got this GitHub project that I want to test before implementing a final code.
I am not an expert in cpp, I wanted to modularise the dust sensor codebase to separate library so I created new dustSensor.cpp file and kept the code linked above.
but I keep getting error:
'Serial' was not declared in this scope
'Serial1' was not declared in this scope
'DEBUG' was not declared in this scope
'DEC' was not declared in this scope dustSensor.cpp:13:57:
I do have Serial.begin(57600) called in setup() function but still get the above error
serial programming softwareserial serial-data cpp
1
add#include <Arduno.h>
to cpp
– Juraj
Nov 15 '18 at 13:48
you can find it with opened your Particle Project in the Desktop IDE and click on theBrowse and Manage Libraries
buttons and find the library you need. that's automatically include your libraries. see this docs.
– abu-ahmed al-khatiri
Nov 15 '18 at 14:02
add a comment |
I am adding Dust Sensor to my particle photon project at home,
I got this GitHub project that I want to test before implementing a final code.
I am not an expert in cpp, I wanted to modularise the dust sensor codebase to separate library so I created new dustSensor.cpp file and kept the code linked above.
but I keep getting error:
'Serial' was not declared in this scope
'Serial1' was not declared in this scope
'DEBUG' was not declared in this scope
'DEC' was not declared in this scope dustSensor.cpp:13:57:
I do have Serial.begin(57600) called in setup() function but still get the above error
serial programming softwareserial serial-data cpp
I am adding Dust Sensor to my particle photon project at home,
I got this GitHub project that I want to test before implementing a final code.
I am not an expert in cpp, I wanted to modularise the dust sensor codebase to separate library so I created new dustSensor.cpp file and kept the code linked above.
but I keep getting error:
'Serial' was not declared in this scope
'Serial1' was not declared in this scope
'DEBUG' was not declared in this scope
'DEC' was not declared in this scope dustSensor.cpp:13:57:
I do have Serial.begin(57600) called in setup() function but still get the above error
serial programming softwareserial serial-data cpp
serial programming softwareserial serial-data cpp
asked Nov 15 '18 at 13:22
Ciasto piekarzCiasto piekarz
2891721
2891721
1
add#include <Arduno.h>
to cpp
– Juraj
Nov 15 '18 at 13:48
you can find it with opened your Particle Project in the Desktop IDE and click on theBrowse and Manage Libraries
buttons and find the library you need. that's automatically include your libraries. see this docs.
– abu-ahmed al-khatiri
Nov 15 '18 at 14:02
add a comment |
1
add#include <Arduno.h>
to cpp
– Juraj
Nov 15 '18 at 13:48
you can find it with opened your Particle Project in the Desktop IDE and click on theBrowse and Manage Libraries
buttons and find the library you need. that's automatically include your libraries. see this docs.
– abu-ahmed al-khatiri
Nov 15 '18 at 14:02
1
1
add
#include <Arduno.h>
to cpp– Juraj
Nov 15 '18 at 13:48
add
#include <Arduno.h>
to cpp– Juraj
Nov 15 '18 at 13:48
you can find it with opened your Particle Project in the Desktop IDE and click on the
Browse and Manage Libraries
buttons and find the library you need. that's automatically include your libraries. see this docs.– abu-ahmed al-khatiri
Nov 15 '18 at 14:02
you can find it with opened your Particle Project in the Desktop IDE and click on the
Browse and Manage Libraries
buttons and find the library you need. that's automatically include your libraries. see this docs.– abu-ahmed al-khatiri
Nov 15 '18 at 14:02
add a comment |
1 Answer
1
active
oldest
votes
I learned that I needed to include Arduino.h
header file
apart from that I learned .ino files and .cpp files is that the .ino files transparently include particle.h for you.
The other difference is that .ino files generate forward declarations for you. This is necessary when you’ve implemented a function later in the file than when you’ve first used it. For example, if you pass the function to something like Particle.subscribe in setup() but you’ve implemented it farther down the file.
2
The technical name for that is a "forward reference". Historical note: the necessity to declare the function before a forward reference originated because early C compilers were written to read your source code only once, rather than once to find function and variable definitions and again to generate code once the components of it were known. Such a compiler was easier to write and ran faster (which was a bigger concern at the time than it is today).
– JRobert
Nov 15 '18 at 15:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("schematics", function () {
StackExchange.schematics.init();
});
}, "cicuitlab");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "540"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f57875%2fgetting-error-serial-was-not-declared-in-this-scope%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I learned that I needed to include Arduino.h
header file
apart from that I learned .ino files and .cpp files is that the .ino files transparently include particle.h for you.
The other difference is that .ino files generate forward declarations for you. This is necessary when you’ve implemented a function later in the file than when you’ve first used it. For example, if you pass the function to something like Particle.subscribe in setup() but you’ve implemented it farther down the file.
2
The technical name for that is a "forward reference". Historical note: the necessity to declare the function before a forward reference originated because early C compilers were written to read your source code only once, rather than once to find function and variable definitions and again to generate code once the components of it were known. Such a compiler was easier to write and ran faster (which was a bigger concern at the time than it is today).
– JRobert
Nov 15 '18 at 15:44
add a comment |
I learned that I needed to include Arduino.h
header file
apart from that I learned .ino files and .cpp files is that the .ino files transparently include particle.h for you.
The other difference is that .ino files generate forward declarations for you. This is necessary when you’ve implemented a function later in the file than when you’ve first used it. For example, if you pass the function to something like Particle.subscribe in setup() but you’ve implemented it farther down the file.
2
The technical name for that is a "forward reference". Historical note: the necessity to declare the function before a forward reference originated because early C compilers were written to read your source code only once, rather than once to find function and variable definitions and again to generate code once the components of it were known. Such a compiler was easier to write and ran faster (which was a bigger concern at the time than it is today).
– JRobert
Nov 15 '18 at 15:44
add a comment |
I learned that I needed to include Arduino.h
header file
apart from that I learned .ino files and .cpp files is that the .ino files transparently include particle.h for you.
The other difference is that .ino files generate forward declarations for you. This is necessary when you’ve implemented a function later in the file than when you’ve first used it. For example, if you pass the function to something like Particle.subscribe in setup() but you’ve implemented it farther down the file.
I learned that I needed to include Arduino.h
header file
apart from that I learned .ino files and .cpp files is that the .ino files transparently include particle.h for you.
The other difference is that .ino files generate forward declarations for you. This is necessary when you’ve implemented a function later in the file than when you’ve first used it. For example, if you pass the function to something like Particle.subscribe in setup() but you’ve implemented it farther down the file.
answered Nov 15 '18 at 14:43
Ciasto piekarzCiasto piekarz
2891721
2891721
2
The technical name for that is a "forward reference". Historical note: the necessity to declare the function before a forward reference originated because early C compilers were written to read your source code only once, rather than once to find function and variable definitions and again to generate code once the components of it were known. Such a compiler was easier to write and ran faster (which was a bigger concern at the time than it is today).
– JRobert
Nov 15 '18 at 15:44
add a comment |
2
The technical name for that is a "forward reference". Historical note: the necessity to declare the function before a forward reference originated because early C compilers were written to read your source code only once, rather than once to find function and variable definitions and again to generate code once the components of it were known. Such a compiler was easier to write and ran faster (which was a bigger concern at the time than it is today).
– JRobert
Nov 15 '18 at 15:44
2
2
The technical name for that is a "forward reference". Historical note: the necessity to declare the function before a forward reference originated because early C compilers were written to read your source code only once, rather than once to find function and variable definitions and again to generate code once the components of it were known. Such a compiler was easier to write and ran faster (which was a bigger concern at the time than it is today).
– JRobert
Nov 15 '18 at 15:44
The technical name for that is a "forward reference". Historical note: the necessity to declare the function before a forward reference originated because early C compilers were written to read your source code only once, rather than once to find function and variable definitions and again to generate code once the components of it were known. Such a compiler was easier to write and ran faster (which was a bigger concern at the time than it is today).
– JRobert
Nov 15 '18 at 15:44
add a comment |
Thanks for contributing an answer to Arduino Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f57875%2fgetting-error-serial-was-not-declared-in-this-scope%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
add
#include <Arduno.h>
to cpp– Juraj
Nov 15 '18 at 13:48
you can find it with opened your Particle Project in the Desktop IDE and click on the
Browse and Manage Libraries
buttons and find the library you need. that's automatically include your libraries. see this docs.– abu-ahmed al-khatiri
Nov 15 '18 at 14:02