Main.cpp:1:10: fatal error: Arduino.h: No such file or directory

Every time I run the code I get this error main.cpp:1:10: fatal error: Arduino.h: No such file or directory . I am newbie, your help is very much appreciated.

What’s the content of the platformio.ini?
Please use pre-formatted text, not image!

My platformio.ini content(I use a Arduino board):

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

Where does this text come from??

Did you use the build button in the bottom bar?

That text is the directory of the main.cpp file stored in my computer.
When I click build button I get this:

Executing task: C:\Users\iniya\.platformio\penv\Scripts\platformio.exe run --environment uno 

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 (5.1.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.2.0 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\uno\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   2.9% (used 936 bytes from 32256 bytes)
================================================ [SUCCESS] Took 1.49 seconds ================================================
 *  Terminal will be reused by tasks, press any key to close it. 

So, everything worked correctly. There is no error at all.

In the step of pasting the path for the binary file, below:

[wokwi]
version = 1
firmware = 'path-to-your-firmware.hex'
elf = '.pio\build\uno\firmware.elf'

I couldn’t find the path for binary file alone.

 *  Executing task: C:\Users\iniya\.platformio\penv\Scripts\platformio.exe run --environment uno 

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 (5.1.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.2.0 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\uno\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   2.9% (used 936 bytes from 32256 bytes)
================================================ [SUCCESS] Took 1.50 seconds ================================================
 *  Terminal will be reused by tasks, press any key to close it. 

Even this is a totally different topic, the file is in the exact same directory (after build):

[wokwi]
version = 1
firmware = '.pio\build\uno\firmware.hex'
elf = '.pio\build\uno\firmware.elf'

I tried with the path you mentioned for hex, it says:

Wokwi: firmware binary .pio\build\uno\firmware.hex not found in workspace

I checked the path, both the binary and .elf files are present but I still get this error

Where is your wokwi.toml file located?
The paths to the firmware and elf file are relative to the location of the wokwi.toml file.

Example:

Filestructure:

.
β”œβ”€β”€ .pio
β”‚   └── build
β”‚       └── uno
β”‚           β”œβ”€β”€ firmware.elf
β”‚           └── firmware.hex
β”œβ”€β”€ .wokwi
β”‚   β”œβ”€β”€ diagram.json
β”‚   └── wokwi.toml
β”œβ”€β”€ src
β”‚   └── main.cpp
└── platformio.ini

wokwi.toml

[wokwi]
version = 1
firmware = '../.pio/build/uno/firmware.hex'
elf = '../.pio/build/uno/firmware.elf'

1 Like

Thanks this worked. <3