• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

?? Compiler error: avr/pgmspace.h: No such file or directory

Q&A Forum › Category: ESP32 › ?? Compiler error: avr/pgmspace.h: No such file or directory
0 Vote Up Vote Down
Erik de Ruiter asked 8 months ago

(I looked first if others had this problem but could not find it here.)
So I’ve got a Compiler error:

/home/erik/SynologyDrive/Arduino/libraries/Adafruit_Sensor/Adafruit_Sensor.cpp:2:10: fatal error: avr/pgmspace.h: No such file or directory
2 | #include <avr/pgmspace.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
exit status 1

Ebook: Learn LVGL: Build GUIs for ESP32 Projects, PAGE: 162

I found a solution after some searching:

REMOVE the #include <avr/pgmspace.h> line from Adafruit_Sensor.cpp
OR change the line to: #include <pgmspace.h>

Adafruit_Sensor.cpp content: /home/erik/SynologyDrive/Arduino/libraries/Adafruit_Sensor
——————————————————————

#include “Adafruit_Sensor.h”
#include <avr/pgmspace.h>
void Adafruit_Sensor::constructor() {
}

So AFTER the mentioned changes compiling is OK and everything seems to be working.
But this is not as it should be??
What could be the matter?
Thanks, Erik

MY (Linux Mint) SETUP:

ARDUINO IDE:
——————
Version: 2.3.2
Date: 2024-02-20T09:54:08.669Z
CLI Version: 0.35.3
Copyright © 2024 Arduino SA
Arduino IDE: Additional Boards Manager URLs:
———————————————————————-
http://arduino.esp8266.com/stable/package_esp8266com_index.json
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Adafruit BME280 Library: v. 2.2.4 including dependancies
——————————————————————–
/home/erik/SynologyDrive/Arduino/libraries/Adafruit_BME280_Library
/home/erik/SynologyDrive/Arduino/libraries/Adafruit_Sensor
/home/erik/SynologyDrive/Arduino/libraries/Adafruit_Unified_Sensor

Compiler ERROR MESSAGE:
———————————————————————–
avr/pgmspace.h: No such file or directory
2 | #include <avr/pgmspace.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: exit status 1

Question Tags: compiler error
3 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 8 months ago

Hello Erik,
You shouldn’t need to modify any files from those libraries and they should compile by default. Go to “Library Manager” and search for these libraries to check if you have these versions that you have installed

  • Adafruit BME280 Library 2.2.4
  • Adafruit Unified Sensor 1.1.14
  • Adafruit BusIO 1.16.1

If you’ve made changes to those libraries, I recommend removing them and re-installing them again.

0 Vote Up Vote Down
Erik de Ruiter answered 8 months ago

Yes I have the latest versions.  Before asking this question, to be sure, I removed the BME280 2.2.4 lib via the library manager and reinstalled version 2.2.4 which also installed the other libs.  The versions are OK, as you pointed out.

No problem, I know now where to look if I use the BME280 and normally I code in VSCode/PlatformIO without this problem so let this not take anymore of your time. I only use the Arduino IDE to follow the Ebook

I just wanted to know if I had overlooked something.

Thank you very much for your help!

0 Vote Up Vote Down
Rui Santos Staff answered 8 months ago

To be honest I’m not really sure why you’re getting that issue in Arduino IDE.
It looks like it’s  some conflict with the libraries or something failed during an update. Glad you were able to make it work with VS Code.
Regards,
Rui
 

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.