arduino_secrets.h: No such file or directory [SOLVED]!

Is the arduino_secrets: No such file or directory error giving you heck?

arduino_secrets: No such file or directory error screen shot

By the end of this video, you’ll understand:

  1. What a header file is, how to make one, and how to put your arduino secrets in it
  2. Where to put your arduino_secrets.h header file
  3. Wether to use “…” or <…> around your header files
  4. How to never write out your WiFi SSID or password again

I know you have secrets.

I mean – we all do.  

Like that time I buried that guy alive in my neighbors backyard.

But I’m not talking about those kind of Secrets

I’m talking about Arduino Secrets. 

They are often found in a header file named arduino_secrets, and include things like WiFi passwords and WiFi networks names. Some of my favorite WiFi names are, It Burns WhenIP, Pretty Fly For a WiFi, The LAN Before Time.

If you have no idea what a header file is, no sweat, let’s talk about it.

Header files are used by the programming languages like C and C++ to help organize code.  You see them most often when using Arduino libraries, they contain things like variables, function signatures, macros, and stuff like that.

If none of that makes sense – don’t worry about it.  You don’t really need to understand it in depth to use them.

You just need to understand that when some programmers share their program, they will keep secret data in a header file named something like arduino_secrets.

What you’ll learn in this video is how to solve the “arduino_secrets.h: No such file or directory error”, plus I’ll show you an awesome trick (let’s call it a secret) <lady winking> so you never have to write out your Arduino Secrets again.

Let’s me start by explaining to you something that confuses the crud out folks who are new to arduino, but once you realize how simple it is, you’re going to want to smack your head against a wall <video head smack>

It has to do with #include statements, and whether or not to use “” or alligators mouths. 

<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>

To explain it, you need to understand how the Arduino folder hierarchy is setup. So let’s start there.

When you install the Arduino IDE, the program creates a folder named Arduino and places it in your My Document folder.  This Arduino folder is called the Arduino Sketchbook folder.

Inside the Arduino folder (again, named your sketchbook folder), it creates another folder called libraries.

This is your libraries folder.

Anytime you install a 3rd party library with Arduino IDE, that library will get saved into the libraries folder.  So if you have a bunch of libraries installed, this libraries folder will be packed!

Now when you write and save a program in Arduino, called a sketch, the Arduino IDE creates a folder with the same name as the program you wrote.  Inside that folder is where your sketch file is saved, and it has the file

 extension .ino. 

If you add a tab in the arduino ide, and then write some code, this tab will be saved in the same sketch folder and by default it will have the file extension .ino as well.

Now this is where header files come in.

Let say you are writing a program and you plan on sharing it publicly.

If the program includes things like your WiFi password, you really don;t want to share that publicly.

So what you might do is create a header file, and put your secret value in there, then, when you share the program, you only share the .ino file with the expectation that end users will either make their own secrets header file, or just write their secrets directly into the program. 

Or, and this is really common, you’ll include the arduino_secrets header file, but you’ll just leave the values blank for the end user to write in themselves.

So how do you add a header file?

Well it’s really easy.  You just add a new tab, but instead of just writing the name, you append a .h to the end of the name.

Now you have a header file.

This header file is going to be saved into the same folder as the sketchbook folder.

This is where you can add your secrets.

#ifndef ARDUINO_SECRETS_H
#define ARDUINO_SECRETS_H

#define SECRET_SSID "Secret Undergound Layer"
#define SECRET_PASSWORD "Mwahahahaha!$%1"

#define SECRET_OPEN_AI_API "tacocatgoatcheesepizza4567892"
#define SECRET_NUMBER 47

#endif

Here you make some #define’s for your secrets.  

First you give them names, and the convention I recommend following is this.

#define SECRET_TYPE_OF_SECRET

A #define is what is called a macro, and a macro is a little programming tool that the compiler uses when it assembles your program.

What a #define will do is replace all instances of the first word written, with whatever follows it.

So using the example above, if in my .ino code I have to reference SECRET_NUMBER, then when the program gets compiled, that macro will replace SECRET_NUMBER with 47.

That’s kind of a quick and dirty description of the define macro. But it’s all you need to know right now.

OK, now that we have a header file with our secrets, how can we use it?

We need to include it into the .ino sketch.  To do that we use another macro called #include followed by the name of the header file in quotes.

#include "arduino_secrets.h"

Now when we compile our program, the .ino file has access to all the stuff in the header file.

But this is where everyone and their uncle gets a little bit confused.

Because, you notice I used quotes around the header file name.  Why did I use quotes and not kissing alligators?

Well here’s the deal.  The Arduino IDE needs to know where to look for your header file, it’s not some fortune telling cat, it needs a little help.

When you put quotes around the header files, it tells the Arduino IDE to first look in the program sketch folder for the .h file of that same name.  If it doesn’t find it there, then it will look in the libraries folder for a folder that matches that header name, and get the header file from inside that folder.

If the compiler looks in these place, and can’t find the header file of the same name, then you get that error.

Now if  you use the alligators, a very similar things happens.

The <> around the header files tells the Arduino IDE to go straight to the libraries folder to look for the header file.  It won’t even look in the sketch book folder.

That is literally the only difference between the “” and <>.

How are you supposed to remember which does what?

Here’s how I remember – in ‘merica we use inches to denote length.  

And the symbol to denote an inch is called a double prime.  Well, those quotes sure like double primes.  So I think, ok, if something is only an inch away, it’s pretty close. So i’ll look pretty close for the header file – i’ll look right in the same sketch book folder first – then, if I don;t find it there, I’ll go to the library folder.

For the kissing alligators, I think they kind of look like book ends – like alligator book ends.  And so, they go straight to the library…

Your mileage may vary on that memory tool 😀

But, you might be saying, Mike, I have an arduino secrets header file, but i’m still getting the error – what gives?! 

The issue might be a spelling or capitalization error.  Thai happens so often it’s laughable, but the Arduino DIE needs and EXACT MATCH to find the header file.

If you #include “Arduino_secrets.h”

But your header file is arduino_serects.h, you will NOT get a match, because of the capital “A” in your include.

So the include must absolutely match the name of the header file.

OK – so hopefully by this point you can get rid of your “no such file or directory” error – but let’s not stop here!

Let me show you something so you don’t ever have to make another Arduino Secrets header file ever again.

Here is what we’ll do.

First, in your libraries folder make a sub folder called arduino_secrets.  Then, open up a text editor program, like notepad or something super lightweight – not MS word.

Type out your header file, with all your secrets and save it in the arduino_secrets folder you just made as arduino_secrets.h.

Now, whenever you need those secrets, just #include <arduino_secrets.h>, and you’ll have all your secrets at your finger tips! 

In addition to secrets, you also want what is called an include guard.  

So let’s do a quick recap. 

Your Arduino Sketchbook will be the place where all your arduino sketches are saved.  And each sketch has its own enclosing folder.

Inside the Arduino folder there is a special folder called libraries.  The libraries folder will house all the libraries you install with the Arduino IDE.

Because they’re Arduino secrets – and maybe they keep 

And maybe you’re getting an error about “No such File Directory” but your your scratching your head wondering, where are my secrets?

The 2 most common secrets are home WIFIs  SSID and Password. 

SSID stands for “service set identifier” – but it’s just the name you gave you WiFi Network 6 years ago – like Bob’s House, or Terry Shack of Horrors

But you might also have frequently used API keys, or whatever. 

In this video I’ll show you how to tame these secrets.

So you can get rid of any “No such file or directory” errors, but better yet I’ll show you how to build a secrets.h file that can be used by all your Arduino programs.

Let’s do this!

AppLab Bricks open in background with actual brick

Arduino AppLab Bricks → Marketing Garbage or New Powerful Interface?

Arduino Ventuno single board computer - top side

New Ventuno Q Dual Brain Single Board Computer

AppLab Pip Install

How to Add Python Packages in Arduino AppLab (No pip install needed)

Arduino Power Section Schematic

Kit-on-a-Shield Schematic Review

Just how random is the ESP32 random number generator?

Just how random is the ESP32 random number generator?

Leave a Comment