opened 05:42AM - 02 Jun 24 UTC
# Problem
Attempting to compile in the Arduino IDE results in the following err…or:
```
/home/user/air_gradient_open_air_firmware/examples/OneOpenAir/OneOpenAir.ino:40:10: fatal error: AirGradient.h: No such file or directory
40 | #include "AirGradient.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: AirGradient.h: No such file or directory
```
The tactical problem issue here is that some included files are in examples/OneOpenAir, while others are in src, and Arduino IDE is not looking in all these places.
However, the core problem is I can not find instructions on how to configure the Arduino IDE to compile. Since I expect others can compile the code, I expect this is just a setup problem and not a broken codebase.
# Steps to reproduce
1. Set up Arduino IDE to compile for the ESP32 board using the [instructions on the blog](https://www.airgradient.com/blog/install-arduino-c3-mini/)
2. Install the "serial" library for Python (e.g. `sudo apt install python3-serial`)
3. Checkout this repo and open `./examples/OneOpenAir/OneOpenAir.ino` in the Arduino IDE
4. Click the verify button (check mark button in the upper left of the Arduino IDE) and see the posted error above
# Attempts at resolving this
I tried a number of things to resolve this.
- Make a symlink pointing to `./examples/OneOpenAir/OneOpenAir.ino`, put it in `./src/`, and open and compile that (so the file is next to the .h file we want to include)
- Copy `./examples/OneOpenAir/OneOpenAir.ino` into `./src/`, and open and compile that (so the file is next to the .h file we want to include)
- Make a symlink to `./src/Libraries` named `./examples/OneOpenAir/libraries` so the sketch directory has a libraries folder, as described in the [arduino documentation](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries/)
- File -> Preference -> Change Sketchbook location to the root git repo, `./src`, or `./examples/OneOpenAir` to get it to find the libraries directory
- copy OneOpenAir.ino into the `./src` directory, rename `./src` to `OneOpenAir`, open OneOpenAir.ino in the Arduino IDE and attempt to compile it (this was tried because Arduino insists on having the name of the directory match the name of the .ino file)
All of the above gave same error message except the last one, which give the error message below:
```
/home/user/air_gradient_open_air_firmware/OneOpenAir/OneOpenAir.ino:41:10: fatal error: OtaHandler.h: No such file or directory
41 | #include "OtaHandler.h"
| ^~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: OtaHandler.h: No such file or directory
```
Symlinking to ../examples/OneOpenAir/OtaHandler.h, ../examples/OneOpenAir/LocalServer.h and ../examples/OneOpenAir/OpenMetrics.h works around the "No such file" errors, but then exposes the more serious compilation errors below:
```
home/user/air_gradient_open_air_firmware/OneOpenAir/AgConfigure.cpp: In member function 'bool Configuration::parse(String, bool)':
/home/user/air_gradient_open_air_firmware/OneOpenAir/AgConfigure.cpp:277:45: error: ambiguous overload for 'operator==' (operand types are 'JSONVar' and 'String')
277 | if (jconfig[jprop_configurationControl] ==
In file included from /home/user/.arduino15/packages/esp32/hardware/esp32/3.0.0/cores/esp32/Arduino.h:192,
from /home/user/air_gradient_open_air_firmware/OneOpenAir/Main/PrintLog.h:4,
from /home/user/air_gradient_open_air_firmware/OneOpenAir/AgConfigure.h:5,
from /home/user/air_gradient_open_air_firmware/OneOpenAir/AgConfigure.cpp:1:
/home/user/.arduino15/packages/esp32/hardware/esp32/3.0.0/cores/esp32/WString.h:211:8: note: candidate: 'bool String::operator==(const String&) const' (reversed)
211 | bool operator==(const String &rhs) const {
| ^~~~~~~~
/home/user/.arduino15/packages/esp32/hardware/esp32/3.0.0/cores/esp32/WString.h:214:8: note: candidate: 'bool String::operator==(const char*) const' (reversed)
214 | bool operator==(const char *cstr) const {
| ^~~~~~~~
In file included from /home/user/air_gradient_open_air_firmware/OneOpenAir/Libraries/Arduino_JSON/src/JSON.h:25,
from /home/user/air_gradient_open_air_firmware/OneOpenAir/Libraries/Arduino_JSON/src/Arduino_JSON.h:23,
from /home/user/air_gradient_open_air_firmware/OneOpenAir/AgConfigure.cpp:2:
/home/user/air_gradient_open_air_firmware/OneOpenAir/Libraries/Arduino_JSON/src/JSONVar.h:85:8: note: candidate: 'bool JSONVar::operator==(const JSONVar&) const'
85 | bool operator==(const JSONVar& v) const;
| ^~~~~~~~
/home/user/air_gradient_open_air_firmware/OneOpenAir/AgConfigure.cpp:286:45: error: ambiguous overload for 'operator==' (operand types are 'JSONVar' and 'String')
286 | if (jconfig[jprop_configurationControl] ==
/home/user/.arduino15/packages/esp32/hardware/esp32/3.0.0/cores/esp32/WString.h:211:8: note: candidate: 'bool String::operator==(const String&) const' (reversed)
211 | bool operator==(const String &rhs) const {
| ^~~~~~~~
/home/user/.arduino15/packages/esp32/hardware/esp32/3.0.0/cores/esp32/WString.h:214:8: note: candidate: 'bool String::operator==(const char*) const' (reversed)
214 | bool operator==(const char *cstr) const {
| ^~~~~~~~
/home/user/air_gradient_open_air_firmware/OneOpenAir/Libraries/Arduino_JSON/src/JSONVar.h:85:8: note: candidate: 'bool JSONVar::operator==(const JSONVar&) const'
85 | bool operator==(const JSONVar& v) const;
| ^~~~~~~~
/home/user/air_gradient_open_air_firmware/OneOpenAir/AgApiClient.cpp: In member function 'bool AgApiClient::postToServer(String)':
/home/user/air_gradient_open_air_firmware/OneOpenAir/AgApiClient.cpp:108:7: error: 'WiFi' was not declared in this scope
108 | if (WiFi.isConnected() == false) {
| ^~~~
/home/user/air_gradient_open_air_firmware/OneOpenAir/AgApiClient.cpp:118:3: error: 'WiFiClient' was not declared in this scope
118 | WiFiClient wifiClient;
| ^~~~~~~~~~
/home/user/air_gradient_open_air_firmware/OneOpenAir/AgApiClient.cpp:120:20: error: 'wifiClient' was not declared in this scope
120 | if (client.begin(wifiClient, uri.c_str()) == false) {
| ^~~~~~~~~~
exit status 1
Compilation error: ambiguous overload for 'operator==' (operand types are 'JSONVar' and 'String')
```