0

I'm at the stage where I can #include headerFiles.h into my arduino sketches.

I'm just beginning to wonder whether it's possible to append strings that are concatenated from integers which are analogRead from sensors to a .h file?

It'd make the arduino a lot more portable and would negate having to buy an SD card module.

How would the data be extracted? EEPROM is too small for datalogging past what you'd rack up in text over a reading every minute for a few hours.

Any clever clogs got ideas for this?

migrated from electronics.stackexchange.com Jul 1 '16 at 16:40

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • open the .h file with an editor and write stuff into it, easy as that. – PlasmaHH Jul 1 '16 at 13:02
  • 5
    Header files only exist on your development machine, not on the Arduino, so can only be modified with the involvement of the former, and the changes only take effect when you rebuild and reflash the sketch. – Chris Stratton Jul 1 '16 at 13:04
  • There are external serial EEPROM/flash memory chips which may be easier to deal with than an SD card (from the Arduino side); search for "spi flash". And then there's also OpenLog. – JimmyB Jul 1 '16 at 15:36
  • How much memory do you need? Kilobytes? Megabytes? Gigabytes? – JimmyB Jul 1 '16 at 15:38
3

Header files are part of your source code. The result of a build is a set of ones and zeros which are sent to your arduino and written in its Flash memory (the program space). The way you put these zeroes and ones together is completely up to you. You could write C and/or C++ code (where you have header files), you could write assembly code or you could write the zeroes and one directly on the disk, if you are crazy enough. Header and Source files live only in the world of the developer and its toolchain, Arduino doesn't know they exist at all.

That being said, if you want to store log data you could use a SD card like you said, or send it over the network, or you could use a serial connection. But I'm sure there are plenty of other options.

1

Header files are used to "encapsulate" functionality of your code. When you #include a header file, what you are actually doing is, as perhaps an oversimplification, "pasting" the code from that header file into your sketch above where the main code you've written in that file resides. You can then call on functions defined in the header file. Usually, at this level, you are using header files to include useful code that other programmers have contributed to a "library" that has some functionality that makes your life easier -- UART or Wire for communication, or perhaps being able to write to one of Adafruit's LCD displays with a single function call.

Programmers will also write their own header files to improve readability of their code -- for example, by encapsulating all code related to a particular functionality, perhaps troubleshooting, in one file. Another header file in the same program might, a bit ironically, be dedicated to input/output functions (but in the sense that it handles the reading and writing of data on some storage medium, such as an SD card). Header files can also #include other header files (if you're careful about how you do so).

However, header files are not usable "input/output." The compiler will read it all as one program and flash it to the Arduino just like any other code you have written.

http://www.learncpp.com/cpp-tutorial/19-header-files/

0

I'm just beginning to wonder whether it's possible to append strings that are concatenated from integers which are analogRead from sensors to a .h file?

No, you have the wrong end of the stick here. You can't write to a .h file, certainly not on the Arduino, because it is running independently of the development environment.

It'd make the arduino a lot more portable and would negate having to buy an SD card module.

An SD module, like the one below, only costs about $US 15, and then you can write gigabytes of data to it, and then easily move the SD card to your PC to process it.

SD card module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.