I am using the Arduino Nano 33 IOT with Web Editor (although I have also tried with Arduino IDE 2.2.1). My goal is to use SinricPro to enable Google Home voice commands and to use ArduinoOTA for program updates. My C++ knowledge is weak.
I have successfully implemented both features in separate sketches but I am unable to combine them. The code below compiles fine:
It seems that Sinric will only compile with WiFiNINA_Generic.h while ArduinoOTA will only compile with WiFiNINA.h. Removing all comments (including both WiFiNINA_Generic.h and WiFiNINA.h). causes many redeclaration errors. If I do not include WiFiNINA.h, I get a "ArduinoOTA was not declared in this scope error".
Unfortunately, I still can't get this to complile.
I placed the #define WiFiNINA_h
line, in every location I could think of but could not get rid of the errors.
If I include #include <WiFiNINA.h>
then I get multiple redeclaration errors, the first being 'redeclaration of 'WL_NO_SHIELD"'.
If I do not include #include <WiFiNINA.h>
then I get the error: redefinition of 'class WiFiUDP' class WiFiUDP : public UDP {
Maybe I created these problems by not understanding what you meant in your troubleshooting section. I was getting the error "'ArduinoOTA' was not declared in this scope" and saw the advice below:
'ArduinoOTA' was not declared in this scope - make sure a networking library is included before the ArduinoOTA.h include
I did not know what that meant so I included the WiFiNINA.h file and the error went away. Was this the wrong file?
I am not sure what you mean. I am guessing that Sinric uses WiFiNINA_Generic and ArduinoOTA uses WiFiNINA and I cannot have both libraries in the same sketch. I am also guessing that the #define WiFiNINA_h statement somehow allows ArduinoOTA to use WiFiNINA_Generic but I was unable to figure out how it does that.
Thank you very much Juraj, your solution works. And I can now compile the code. Running it is still giving me grief but I will investigate that further before reporting.
Any deeper insight into this compiler problem would be greatly appreciated as I am now encountering the same problem when I include the EMailSender library. I have poked around in EMailSender.h to see if a similar fix might be available but I cannot figure it out.
Is it correct that my problems basically stemmed from including both WiFiNINA and WiFiNINA_Generic and that the fix you provided allowed ArduinoOTA to use WiFiNINA_Generic? Is it likely that I can convince EMailSender to do the same thing?
WiFiNINA_Generic has wrong file names. All WiFi libraries have WiFiClient.h and WiFiUdp.h, but WiFiNINA_Generic has only WiFiClient_Generic.h and WiFiUdp_Generic.h