How to "include" String and Time classes


I am re-writing my firmware and making it more manageable and easier to maintain. This involves breaking it out into separate classes and files. Currently there are three files: main .ino file, one .h file and one .cpp file. I am doing this in Particle Dev studio (Atom editor).

The question is: how do I refer to built-in String and Time classes in these other files? What should I include?


Try this: include "application.h"

Cool, that did part of the trick! String is now under control. Time class is still missing. It says: “‘Time’ is not a class, namespace, or enumeration”. Any ideas?

@kaksa, can you show your code where you refer to Time?

Sure! For instance:

int Schedule::getTimeAsOfToday (int hour, int min) {
    struct tm t;
    t.tm_year  = Time.year() - 1900;
    t.tm_mon   = Time.month() - 1;  // Month, 0 - jan
    t.tm_mday  =;   // Day of the month
    t.tm_hour  = hour;
    t.tm_min   = min;
    t.tm_sec   = 0;
    t.tm_isdst = 0;             // Is DST on? 1 = yes, 0 = no, -1 = unknown
    //t.tm_gmtoff = 0;
    time_t t_of_day;
    t_of_day = mktime(&t);
    return (int)t_of_day;

Oops… my bad. I had Time::now() in the code as well (I tested my functionality in another environement and accidentally left that, as I used time.h in that environment). So Time class works too. Thanks a lot for your help!

@kaksa, are you sure you have #include "application.h" pulled in?

The next one: how about including “OneWire/OneWire.h” in Dev? I get an error, “No such file/dir”

@peekay123 Yeah, it works. It was my bad. Do you know about the including OneWire in Dev studio?

@kaksa, all the files need to be in a single directory so that include refers to a subdirectory. It should be #include OneWire.h only.

Still getting the same issue: no such file.

Do I need to “activate” using the OneWire library somehow, like in web builder where you search and include a library?

Have you got OneWire.h and OneWire.cpp in you project folder?
And don’t forget the double quotes for #include "OneWire.h"

Oh man… I guess I did something fully again. I guess I am getting tired. OneWire is ok too. Thank you so much for your help!

Oh, I’d need to add those. OK. And where do I download them?

So, from Git of course…

@kaksa, are you using a OneWire device or an I2C device?

It’s a OneWire device (temp sensor). I got the OneWire code from Git, added it to the project folder and now it compiles.