为什么我在连接 Firebase 时会在 Arduino 中遇到这个问题?

Why am I facing this Problem in Arduino when connecting Firebase?

Arduino: 1.8.13 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp: In member function 'bool FirebaseObject::isNullString(const String&) const':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp:71:57: warning: 'const char* ArduinoJson::Internals::JsonVariantCasts<TImpl>::asString() const [with TImpl = ArduinoJson::JsonVariant]' is deprecated: use as<char*>() instead [-Wdeprecated-declarations]

   71 |   return variant.is<const char *>() && variant.asString() == NULL;

      |                                                         ^

In file included from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariantBase.hpp:7,

                 from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariant.hpp:13,

                 from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\jsonbuffer.hpp:12,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Deserialization/JsonParser.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/JsonBufferBase.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/DynamicJsonBuffer.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:9,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,

                 from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.h:24,

                 from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp:17:

c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariantCasts.hpp:28:28: note: declared here

   28 |   FORCE_INLINE const char *asString() const {

      |                            ^~~~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp: In member function 'ArduinoJson::JsonVariant FirebaseObject::getJsonVariant(const String&) const':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp:91:26: warning: 'ArduinoJson::JsonObject& ArduinoJson::Internals::JsonVariantCasts<TImpl>::asObject() const [with TImpl = ArduinoJson::JsonVariant]' is deprecated: use as<JsonObject>() instead [-Wdeprecated-declarations]

   91 |     json = json.asObject().get<JsonVariant>(start);

      |                          ^

In file included from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariantBase.hpp:7,

                 from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariant.hpp:13,

                 from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\jsonbuffer.hpp:12,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Deserialization/JsonParser.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/JsonBufferBase.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/DynamicJsonBuffer.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:9,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,

                 from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.h:24,

                 from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp:17:

c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariantCasts.hpp:23:28: note: declared here

   23 |   FORCE_INLINE JsonObject &asObject() const {

      |                            ^~~~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp: In member function 'int FirebaseRequest::sendRequest(const string&, const string&, char*, const string&, const string&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp:78:1: warning: no return statement in function returning non-void [-Wreturn-type]

   78 | }

      | ^

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp: In member function 'void FirebaseStream::startStreaming(const string&, const string&, const string&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp:91:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   91 |   analyzeError("STREAM", status, path_with_auth);

      |                ^~~~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'String FirebaseArduino::push(const String&, const ArduinoJson::JsonVariant&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:65:54: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   65 |   int status = req_.get()->sendRequest(host_, auth_, "POST", path.c_str(), buf);

      |                                                      ^~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'void FirebaseArduino::set(const String&, const ArduinoJson::JsonVariant&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:94:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   94 |   req_.get()->sendRequest(host_, auth_, "PUT", path.c_str(), buf);

      |                                         ^~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'void FirebaseArduino::getRequest(const String&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:101:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

  101 |   req_.get()->sendRequest(host_, auth_, "GET", path.c_str());

      |                                         ^~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'virtual void FirebaseArduino::remove(const String&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:147:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

  147 |   req_.get()->sendRequest(host_, auth_, "DELETE", path.c_str());

      |                                         ^~~~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'virtual const String& FirebaseArduino::error()':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:201:32: warning: returning reference to temporary [-Wreturn-local-addr]

  201 |   return error_.message().c_str();

      |          ~~~~~~~~~~~~~~~~~~~~~~^~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp: In member function 'virtual void FirebaseHttpClientEsp8266::begin(const string&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:47:50: error: no matching function for call to 'begin(const char*, const char [60])'

   47 |     http_.begin(url.c_str(), kFirebaseFingerprint);

      |                                                  ^

In file included from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:9:

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:166:10: note: candidate: 'bool HTTPClient::begin(String, uint16_t, String)' (near match)

  166 |     bool begin(String host, uint16_t port, String uri = "/")  __attribute__ ((error("obsolete API, use ::begin(WiFiClient, host, port, uri)")));

      |          ^~~~~

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:166:10: note:   conversion of argument 2 would be ill-formed:

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:47:30: error: invalid conversion from 'const char*' to 'uint16_t' {aka 'short unsigned int'} [-fpermissive]

   47 |     http_.begin(url.c_str(), kFirebaseFingerprint);

      |                              ^~~~~~~~~~~~~~~~~~~~

      |                              |

      |                              const char*

In file included from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:9:

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:167:10: note: candidate: 'bool HTTPClient::begin(String, const uint8_t*)' (near match)

  167 |     bool begin(String url, const uint8_t httpsFingerprint[20])  __attribute__ ((error("obsolete API, use ::begin(WiFiClientSecure, ...)")));

      |          ^~~~~

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:167:10: note:   conversion of argument 2 would be ill-formed:

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:47:30: error: invalid conversion from 'const char*' to 'const uint8_t*' {aka 'const unsigned char*'} [-fpermissive]

   47 |     http_.begin(url.c_str(), kFirebaseFingerprint);

      |                              ^~~~~~~~~~~~~~~~~~~~

      |                              |

      |                              const char*

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp: In member function 'virtual void FirebaseHttpClientEsp8266::begin(const string&, const string&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:51:60: error: invalid conversion from 'const char*' to 'const uint8_t*' {aka 'const unsigned char*'} [-fpermissive]

   51 |     http_.begin(host.c_str(), kFirebasePort, path.c_str(), kFirebaseFingerprint);

      |                                                            ^~~~~~~~~~~~~~~~~~~~

      |                                                            |

      |                                                            const char*

In file included from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:9:

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:168:70: note:   initializing argument 4 of 'bool HTTPClient::begin(String, uint16_t, String, const uint8_t*)'

  168 |     bool begin(String host, uint16_t port, String uri, const uint8_t httpsFingerprint[20])  __attribute__ ((error("obsolete API, use ::begin(WiFiClientSecure, ...)")));

      |                                                        ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~

exit status 1

Error compiling for board NodeMCU 1.0 (ESP-12E Module).



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

当我遇到同样的问题时,我在 board manager 上回滚到 2.7.4,这导致它编译没有问题。我想板软件在 FireBase 库更新之前更新了。我在 this page.

上找到了这个解决方案

我在将代码从旧笔记本电脑转移到新笔记本电脑时发现了错误。

你猜怎么着?我最近在我的新笔记本电脑中下载的 Arduino 库版本与旧笔记本电脑中的版本不匹配! 这就是错误消息弹出的原因。

使用 platformio,更改 platformio.ini(为我工作),最新 2.x 版本:

platform = espressif8266@^2

Solution from this page

回滚到 2.7.X 版本enter image description here