gromeck / BLE-Scanner

ESP32-based Bluetooth Low Energy (BLE) scanner to report presence of bluetooth devices into an MQTT service.
GNU General Public License v3.0
90 stars 21 forks source link

Can't find EEPROM.h in Arduino IDE #24

Open EdwardDeaver opened 6 months ago

EdwardDeaver commented 6 months ago

I opened the project in the latest Arduino IDE and I'm getting these errors:

/Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp: In function 'void EepromInit(int)': /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp:36:3: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 36 | EEPROM.begin(_eeprom_size); | ^~ | EPERM /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp: In function 'void EepromClear()': /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp:65:5: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 65 | EEPROM.write(n, 0xff); | ^~ | EPERM /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp:66:3: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 66 | EEPROM.commit(); | ^~ | EPERM /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp: In function 'int EepromRead(int, int, void)': /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp:80:9: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 80 | if (EEPROM.read(addr + n) != 0xff) | ^~ | EPERM /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp:87:28: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 87 | ((byte ) buffer)[n] = EEPROM.read(addr + n); | ^~ | EPERM /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp: In function 'void EepromWrite(int, int, const void)': /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp:102:5: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 102 | EEPROM.write(addr + n, ((byte ) buffer)[n]); | ^~ | EPERM /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/eeprom.cpp:107:3: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 107 | EEPROM.commit(); | ^~ | EPERM /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/ntp.cpp: In function 'void NtpSetup()': /Users/$USERNAME/Downloads/BLE-Scanner-main/BLE-Scanner/ntp.cpp:178:7: error: 'WiFi' was not declared in this scope 178 | if (WiFi.hostByName(_config_ntp.server, _ntp_ip)) { | ^~~~

exit status 1

Compilation error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'?

gromeck commented 5 months ago

Hi @EdwardDeaver, which version of Arduino IDE are you using? Did you install the esp32 package? EEPROM should be part of it.

wprinz commented 4 months ago

Hi @gromeck , I'm having similar problems, both with WIFI and EEPROM. I'm getting the following compile errors:

C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\ntp.cpp:181:7: error: 'WiFi' was not declared in this scope
  181 |   if (WiFi.hostByName(_config_ntp.server, _ntp_ip)) {
      |       ^~~~

C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\eeprom.cpp: In function 'void EepromInit(int)':
C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\eeprom.cpp:36:3: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'?
   36 |   EEPROM.begin(_eeprom_size);
      |   ^~~~~~
      |   EPERM

... and many other EEPROM was not declared in this scope errors

All libs are installed. I assume something goes wrong with the include sequence, as the compiler does not complain about a missing lib, but a missing declaration in this scope. Any hint is appreciated. I'm using Arduino IDE 2.3.2 on win10.

gromeck commented 4 months ago

C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\ntp.cpp:181:7: error: 'WiFi' was not declared in this scope 181 | if (WiFi.hostByName(_config_ntp.server, _ntp_ip)) { | ^~~~

Try adding

#include "wifi.h"

to the file ntp.cpp directly after #include "config.h"

But I can't explain why I don't get this error :-/

gromeck commented 4 months ago

All libs are installed.

Are you sure that you've installed the esp32 lib by Espressif Systems -- not Arduino ESP32 Boards lib by Arduino? See the https://github.com/gromeck/BLE-Scanner/blob/main/README.md, section , first two bullet points.

wprinz commented 4 months ago

First I installed only the esp32, later I also installed the Arduino ESP32 Boards, to test if this could solve the problem. Thus I now have both installed, but only a ESP32 board is selected.

wprinz commented 4 months ago

unfortunately the error remains: :\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\eeprom.cpp: In function 'void EepromInit(int)': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\eeprom.cpp:36:3: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 36 | EEPROM.begin(_eeprom_size); | ^~~~~~ | EPERM C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\eeprom.cpp: In function 'void EepromClear()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\eeprom.cpp:65:5: error: 'EEPROM' was not declared in this scope; did you mean 'EPERM'? 65 | EEPROM.write(n, 0xff); | ^~~~~~ | EPERM

then later:

C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\ntp.cpp: In function 'void NtpSetup()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\ntp.cpp:182:7: error: 'WiFi' was not declared in this scope 182 | if (WiFi.hostByName(_config_ntp.server, _ntp_ip)) { | ^~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp: In function 'bool WifiSetup()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:52:5: error: 'WiFi' was not declared in this scope 52 | WiFi.macAddress(mac); | ^~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:56:15: error: 'WIFI_AP' was not declared in this scope 56 | WiFi.mode(WIFI_AP); | ^~~~~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:81:5: error: 'WiFi' was not declared in this scope 81 | WiFi.mode(WIFI_STA); | ^~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:81:15: error: 'WIFI_STA' was not declared in this scope 81 | WiFi.mode(WIFI_STA); | ^~~~~~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp: In function 'bool WifiUpdate()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:107:9: error: 'WiFi' was not declared in this scope 107 | if (WiFi.status() != WL_CONNECTED) { | ^~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:107:26: error: 'WL_CONNECTED' was not declared in this scope 107 | if (WiFi.status() != WL_CONNECTED) { | ^~~~~~~~~~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp: In function 'String WifiGetSSID()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:146:53: error: 'WiFi' was not declared in this scope 146 | return StateCheck(STATE_CONFIGURING) ? _AP_SSID : WiFi.SSID(); | ^~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp: In function 'int WifiGetChannel()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:158:10: error: 'WiFi' was not declared in this scope 158 | return WiFi.channel(); | ^~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp: In function 'int WifiGetRSSI()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:170:10: error: 'WiFi' was not declared in this scope 170 | return WiFi.RSSI(); | ^~~~ In file included from C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:30: C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp: In function 'String WifiGetIpAddr()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:183:60: error: 'WiFi' was not declared in this scope 183 | return IPAddressToString(StateCheck(STATE_CONFIGURING) ? WiFi.softAPIP() : WiFi.localIP()); | ^~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\util.h:63:37: note: in definition of macro 'IPAddressToString' 63 | #define IPAddressToString(addr) ((addr).toString()) | ^~~~ C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp: In function 'String WifiGetMacAddr()': C:\Users\prinz\Documents\Projekte\Arduino\BLE-Scanner\wifi.cpp:197:3: error: 'WiFi' was not declared in this scope 197 | WiFi.macAddress(mac); | ^~~~

which looks really strange that WiFi is not declared in wifi.cpp - I assume something really strange is going on here.

gromeck commented 4 months ago

First I installed only the esp32, later I also installed the Arduino ESP32 Boards, to test if this could solve the problem. Thus I now have both installed, but only a ESP32 board is selected.

Please, deinstall the Arduino ESP32 Boards lib.

Additionally, open File -> Preferences ... -> Settings and ensure that Show verbose output during has compile checked. Then recompile and send the complete compile log (as attachment) here.

wprinz commented 4 months ago

Thanks for your time!

Arduino ESP32 Boards are removed.

Here is the full compiler log: (too long to include in comment) compile_log.txt

gromeck commented 4 months ago

This compile log lacks a lot of information.

My log starts with the target specification of the the compile:

FQBN: esp32:esp32:d1_mini32:PartitionScheme=min_spiffs
Using board 'd1_mini32' from platform in folder: /home/gromeck/.arduino15/packages/esp32/hardware/esp32/3.0.3
Using core 'esp32' from platform in folder: /home/gromeck/.arduino15/packages/esp32/hardware/esp32/3.0.3

For each library a section with the selected one is output:

Detecting libraries used...
/home/gromeck/.arduino15/packages/esp32/tools/esp-x32/2302/bin/xtensa-esp32-elf-g++ -c ... /tmp/arduino/sketches/7970E08F2BBB3C33259147BC24A1229F/sketch/BLE-Scanner.ino.cpp -o /dev/null
Alternatives for WiFi.h: [WiFi@1.2.7 WiFi@3.0.3]
ResolveLibrary(WiFi.h)
  -> candidates: [WiFi@1.2.7 WiFi@3.0.3]

I was not aware that compiling under Windows and Linux is that different. I am running IDE 2.3.2 under Linux. I have no idea (and no windows). But you might try under Linux.

Did you try the examples which are offered in the IDE? Try to compile File -> Examples -> EEPROM -> eeprom_class and File -> Examples -> WiFi -> WiFiClient with your desired ESP32 board.

wprinz commented 4 months ago

Hi @gromeck, your comment about Linux guided me to the solution. The problem is caused by using the file names wifi.h and eeprom.h as well as the corresponding compiler flags in your files. Windows confuses these files with the libraries WiFiand EEPROM. This results in these very strange problems, most probably caused by using the same compiler flags in your .h files as in the library .h files. After modifying both, i.e. the files names to my_wifi.h/.cpp and my_eeprom.h/.cpp as well as the flags to __MY_EPROM_H__and __MY_WIFI_H__ the code compiled successfully. You may wish to make these changes also to you repro.

In parallel I tried to compile the code also using visual studio and platformio, but not yet successful as I'm getting similar very strange error messages. I'll keep trying :-) to understand what the problem with platformio is.

gromeck commented 4 months ago

Hmm, ok, that's wierd. There should be no dependencies between the file names in my own sketch and the ones from the libraries.

This could be an issue of the Arduino IDE 2. Do you know about filename rules there?

as well as the flags to MY_EPROM_H and MY_WIFI_H

Could you please check, if this is necessary? The libs use other flag name/rules and should not collide (this would otherwise be also the case under Linux).

wprinz commented 4 months ago

You are right! I changed MY_EEPROM_H and MY_WIFI_H back to EEPROM_H and WIFI_H and it compiles without any problems.

I assume the file name problem is caused by the fact that windows files names are case insensitiv. : https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity This probably leads to the wierd error messages.

gromeck commented 4 months ago

You are right! I changed MY_EEPROM_H and MY_WIFI_H back to EEPROM_H and WIFI_H and it compiles without any problems.

Ok, thanks for this check.

I assume the file name problem is caused by the fact that windows files names are case insensitiv. : https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity This probably leads to the wierd error messages.

Yes, and this causes some problems even within the IDE 2 (see https://github.com/arduino/arduino-ide/issues?q=is%3Aissue+is%3Aopen++case+sensitive). As I don't have a windows environment, you could open an issue against die IDE with some simple code that shows the problem (or by using BLE-Scanner as a reference).

wprinz commented 4 months ago

I'm not sure if this is an Arduino issue. In the meantime I succeeded to compile your code in Visual Studio Code and PlatformIO. There, the same problems occur and after modifying the filenames as well as the watchdog code everything compiled OK. I've left some comments about this in the corresponding issue on PlatformIO.