'Arduino.h' file not found

I try to make a code and after this write my console'Arduino.h' file not found

I use the Arduino uno on Mac this vs studio (PlatformIO)
How can fix it ?

1 Like

Can you show us your code and your platformio.ini file?

And where does the error message appear? Except for the Debug Console nothing is called Console in Visual Studio Code. And it’s unlikely to appear there?

Does the project build?

1 Like

@manuelbl
Yes I can show platformio.ini

I hope u can help me
Thx :slight_smile:

1 Like

Please show your code (main.cpp) as well. And for code we prefer text over images. Just put it between two lines with three backquotes (```) to have formatted properly.

1 Like

@manuelbl
okay I looking alone and now I disabled
mitaki28.vscode-clang (Look pic)
and the problems don’t come
I hope its right

thx

2 Likes

From the information so far, it looks as if only Intellisense is affected, i.e. you get red squiggly lines in the code editor, related entries in the Problems view but you can still build and upload the project.

The first approach to fix it is to disable all C/C++ related extensions except C/C++ from Microsoft and PlatformIO IDE from PlatformIO.

So by disabling the C/C++ Clang Command Adapter you did the right thing.

3 Likes

But where are the problem by C/C++? Can u help me ?

I’m afraid I don’t understand your question. Can you describe it in more detail?

@manuelbl

1.Is the problem now fixed or only temporarily fixed? 2. how is it that c / c ++ does not cause problems for me in the editor and not with others

Disabling the C/C++ Clang Command Adapter should have fixed the problem - permanently.

But I still don’t understand part 2 of your question.You are writing the C/C++ does not cause problem, i.e. works correctly. That’s a good thing, isn’t it?

2 Likes

I think there could be some confusion here:

There are IntelliSense errors, and there are C/C++/compiler errors.

IntelliSense errors are code errors detected by the IntelliSense engine, which analyses your code while you are writing it, and tries to detect potential errors. However, it sometimes doesn’t work properly, and gives ‘false positives’ / says there are errors that don’t really exist. This misbehaviour could be the result of a configuration issue, a conflict with another extension, a bug in the IntelliSense, antivirus software misbehaving or any number of odd conflicts or reasons. Either way, IntelliSense errors are shown in the Problems tab.

There are C/C++/compiler errors, which are detected by the compiler during the build/compile process. These are real errors, as they are preventing the compiler from building your project. They need to be fixed before your project will successfully build. These errors are shown in the Terminal tab.

1 Like

U help me very thx. It’s my first time on this Platform and I never think to become so much help !

1 Like

Ahhhh, now I know what u mean , I disable the
compiler the error are gone but it’s not really good ? I fiddled and didn’t fix it properly?

I am new to programming and try to learn everything. I’m actually a trained electrician

So sorry for maybe stupid questions…

No, not quite… you fiddled… which broke intellisense in the first place (which isn’t hard to do, trust me), and then removed the addon that broke it (mitaki28.vscode-clang), and it came good again :wink:

IntelliSense is nice when it works (as you don’t have to compile the code to find mistakes), but when it doesn’t work, it doesn’t. At that point, you either ignore the ‘Problems’ tab, or you spend lots of time trying to make it work. I do the latter, even when it does work… I just press build/compile when I think I’ve finished something, and wait for the compiler to tell me I did something wrong.

1 Like

ahhh u save my day :slight_smile:
Thank u really!

1 Like

Platform IO is supposed to be platform independent

but on first use, proves completely useless because it is completely empty
Question as … where is Arduimo.h Library not found … is crypticaly answered explaining you should use TH library manager …

there is no respect for the beginner… it claims the include paths and library paths are NOT setup correctly.
upon asking you getting the fourth degree.

      Everyone can create MISTORIES THIS IS GETTING VERY ANNOYING

IF ONE CAN USE THE LIBRARY MANAGER WHERE ARE THE FILES in ARDUINO (to copy) and to be placed in PLATFORMIO…

		What are  the KEYWORDS   to LOAD
		
		
		
		 a) THE core  arduino  library    ( ARDUINO.h, Serial .....)  there is enough doc how to find json , wifi ....
		    THE CORE  arduino  8266  libary ( ARDUINO.h, Serial .....)  there is enough doc how to find json , wifi ....
		    THE  CORE  ESP32    library   ( ARDUINO.h, Serial .....)  there is enough doc how to find json , wifi ....
		    THE CORE   RTOS  library   ( ARDUINO.h, Serial .....)  there is enough doc how to find json , wifi ....
		    ...
		      all frameworks ....
		      
		  B)
		  		Can they be   inserted  with the  LIBRARY MANAGER  [ YES/ NO ]
		  		
		  		Can I Reuse   the arduino IDE  include/library  (same updates .... it takes MONTHS ... to get an answer from platform IO
		  		
		  		Can I add my OWN INCLUDES/LIBRARIES
		  		
		  C)    Arduino IDE is an all containing packet 
		  		PLEASE  DOCUMENT  WHERE TO FIND  THESE CORE  LIBRARIES   !!!!!!
		  		
		  				
		  		
		 WILL THIS SOLVE  THE  ARDUINI.H  proroble m and simular   FOR EVER .....  [ YES /NO ]
		 
		 
	PLease  do NOT refer me to   standards    Using   any off  the  utility libraries 
	
	
	
				FOR  ARDUINO IDE   the y can be INTERNAL ( included in the packet !!!!)
				FOR  PLATFORM IO    THIS MUST BE EXPLICITELY DOCUMENTED  NOT INTERNAL IN THE PACKET
				
				
				
         Sorry  for the capitals  MONTHS frustration  ......
1 Like

I agree, the documentation isn’t clear for beginners, but I couldn’t tell if you were trying to help or just state your frustration.

Do you know how to add the Arduino.h path to PlatformIO or not? I’m still looking, and if you know, it’ll be of great help :slight_smile:

Omar

1 Like

Hi @OmarAlamoudi,

If you create a program using the option framework = arduino (in the platformio.ini file) then, when you compile it for the first time, PlatformIO will download all required tools, files and so on. The next time it does that will be if something has changed or been updated.

Where is the Arduino.h file? Well, on my Linux system, I can see it in /home/norman/.platformio/packages/framework-arduino-avr/cores/arduino - but you don’t need to know where it lives, the compiler will (should!) find it.

Here’s an example on my setup:

mkdir PIO_dummy
cd PIO_dummy
pio init --board uno

That creates a pile of stuff (technical term) ready for me to add some code. Have a look at the meat of the platformio.ini file:

cat platformio.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino

So far so good, the framework is arduino, so I can simply create a sketch, add the line #include <Arduino.h> to it and compile:

vi src/main.ino    ### I use vi for this example.

Add these lines, then save the file and exit the editor.

#include <Arduino.h>

void setup() {
}

void loop() {
}

The file is ready to be compiled:

The command pio run will compile the code and produces a lot of output:

Processing uno (platform: atmelavr; board: uno; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR 2.2.0 > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES: 
 - framework-arduino-avr 5.0.0 
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
Converting main.ino
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/uno/src/main.ino.cpp.o
Archiving .pio/build/uno/libFrameworkArduinoVariant.a
Indexing .pio/build/uno/libFrameworkArduinoVariant.a
Compiling .pio/build/uno/FrameworkArduino/CDC.cpp.o
...
Lots of compilation of Arduino files here ...
...
Archiving .pio/build/uno/libFrameworkArduino.a
Indexing .pio/build/uno/libFrameworkArduino.a
Linking .pio/build/uno/firmware.elf
Checking size .pio/build/uno/firmware.elf
Building .pio/build/uno/firmware.hex
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   1.4% (used 444 bytes from 32256 bytes)
========================= [SUCCESS] Took 2.39 seconds =========================

The command pio run --target upload will upload it to my Uno, however, there’s no point as the sketch doesn’t do anything.

You can see, from the compilation listing above, that there are no errors, the Arduino.h file has been found on my system somewhere and included in my sketch. I didn’t need to find it or tell the compiler where to find it.

What happens on your system when you follow the instructions above? Do yo get a cleancompilation or do you get an errro?

HTH

Cheers,
Norm.

2 Likes

Thank you very much @normandunbar!

I think I do understand your wonderful answer. My primary concern, which I didn’t make clear, was how to take advantage of IntelliSense and remove the squiggly red lines in Visual Studio Code by simply adding the path of the Arduino.h file. But due to my beginner nature using PlatformIO, I didn’t realize PIO is as dynamic as you describe it.

I actually have no problems uploading sketches to my Arduino. I notices that your sketch has a .ino extension, I’m using main.cpp and it is working just fine as of right now.

Is there a way to dynamically point to the directory where PIO stores the Arduino source code?

Thanks

Hi @OmarAlamoudi,

This thread might help andwer your question. Replies 6 and 7 - currently at the bottom - should suffice.

Cheers,
Norm.