0

How do I include a local file? This is my project structure (with multiple sketches):

(project root)
    - some_config.json
    - SketchOne/
        - SketchOne.ino
    - SketchTwo/
        - SketchTwo.ino
    - lib/
        - lib_1/
            - some.h

From SketchOne/SketchOne.ino, I want to include lib/lib_1/some.h. I've tried the following(s):

#include "lib/lib_1/some.h"
#include <lib/lib_1/some.h>
#include "lib_1/some.h"
#include <lib_1/some.h>

Note: I use the CLI (arduino-cli)

  • maybe it would be a better idea to use a SD Module. So later you can change data by replacing the SD-Card and reboot. https://www.mischianti.org/2020/01/26/manage-json-file-with-arduino-and-esp8266/ Using a local JSON-File is not useful. You also could convert the JSON to an inline array within the program code. You can use https://quicktype.io/ to convert the JSON ... – Danny Sep 06 '22 at 09:25

1 Answers1

0

In Arduino projects are called "sketches". The name of the main ino file of the sketch must match the name of the sketch folder. CLI builds one sketch at time.

Sketches are in file system organized into a folder called "sketchbook". The sketchbook folder should containing a special folder named "libraries". Folders in the libraries folder are treated as libraries. There are two forms of library folder in the file system: old and new.

See the sketch build process too.

Juraj
  • 3,490
  • 4
  • 18
  • 25
  • In that case, how can I include a file outside my "sketch" or is it not possible with `arduino-cli`. I feel like it can work but I need to play with `--library` and `--libraries` flag(s) – Farish Irfan Sep 05 '22 at 05:55
  • can't you put the library into the libraries folder? your folders structure listed in the question is similar to a sketchbook folder. why not make a sketchbook folder? – Juraj Sep 05 '22 at 08:25