使用Arduino IDE将Arduino Node-MCU与Google Firebase连接

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Arduino IDE将Arduino Node-MCU与Google Firebase连接相关的知识,希望对你有一定的参考价值。

这是我的代码:

//
// Copyright 2015 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

// FirebaseDemo_ESP8266 is a sample that demo the different functions
// of the FirebaseArduino API.

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>



// Set these to run example.
#define FIREBASE_HOST "EXAMPLE-12345.firebaseio.com"
#define FIREBASE_AUTH "secret"
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "PWD"

void setup() {
  Serial.begin(9600);

  // connect to wifi.
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}

int n = 0;

void loop() {
  // set value
  Firebase.setFloat("number", 42.0);
  // handle error
  if (Firebase.failed()) {
    Serial.print("setting /number failed:");
    Serial.println(Firebase.error());
    return;
  }
  delay(1000);

  // update value
  Firebase.setFloat("number", 43.0);
  // handle error
  if (Firebase.failed()) {
    Serial.print("setting /number failed:");
    Serial.println(Firebase.error());
    return;
  }
  delay(1000);

  // get value
  Serial.print("number: ");
  Serial.println(Firebase.getFloat("number"));
  delay(1000);

  // remove value
  Firebase.remove("number");
  delay(1000);

  // set string value
  Firebase.setString("message", "hello world");
  // handle error
  if (Firebase.failed()) {
    Serial.print("setting /message failed:");
    Serial.println(Firebase.error());
    return;
  }
  delay(1000);

  // set bool value
  Firebase.setBool("truth", false);
  // handle error
  if (Firebase.failed()) {
    Serial.print("setting /truth failed:");
    Serial.println(Firebase.error());
    return;
  }
  delay(1000);

  // append a new value to /logs
  String name = Firebase.pushInt("logs", n++);
  // handle error
  if (Firebase.failed()) {
    Serial.print("pushing /logs failed:");
    Serial.println(Firebase.error());
    return;
  }
  Serial.print("pushed: /logs/");
  Serial.println(name);
  delay(1000);
}

这是我的错误:

** Arduino:1.8.5(Windows 10),主板:“NodeMCU 1.0(ESP-12E模块),80 MHz,115200,4M(3M SPIFFS)”

构建选项已更改,重建所有内容

在C: Users ASUS Documents Arduino libraries FirebaseArduino src / Firebase.h:30:0中包含的文件,来自C: Users ASUS Documents Arduino libraries FirebaseArduino src / FirebaseArduino.h :22,来自C: Users ASUS Documents Arduino libraries firebase-arduino-master examples FirebaseDemo_ESP8266 FirebaseDemo_ESP8266.ino:21:C: Users ASUS Documents Arduino libraries FirebaseArduino src / FirebaseObject.h:109:11:错误:StaticJsonBuffer是来自ArduinoJson 5的类。请参阅arduinojson.org/upgrade以了解如何将程序升级到ArduinoJson版本6 std :: shared_ptr> buffer_; ^

在C: Users ASUS Documents Arduino libraries FirebaseArduino src / FirebaseArduino.h:22:0中包含的文件中,来自C: Users ASUS Documents Arduino libraries firebase-arduino-master examples FirebaseDemo_ESP8266 FirebaseDemo_ESP8266.ino:21:C: Users ASUS Documents Arduino libraries FirebaseArduino src / Firebase.h:86:11:错误:StaticJsonBuffer是来自ArduinoJson的一个类5.请参阅arduinojson.org/升级以了解如何将程序升级到ArduinoJson版本6 std :: shared_ptr> buffer_; ^

退出状态1编译板块NodeMCU 1.0(ESP-12E模块)时出错。**

请帮我!谢谢!

答案

我有同样的问题。你必须降级你的ArduinoJson。

为了这; 1)草图 - >包含库 - >管理库2)在此窗口中,将“json”写入搜索框。你应该看到“Benoit Blanchon的ArduinoJson”。将其版本降级至5.13.2 3)关闭Arduino,再次打开。 4)将代码发送到您的NodeMCU 5)享受。

以上是关于使用Arduino IDE将Arduino Node-MCU与Google Firebase连接的主要内容,如果未能解决你的问题,请参考以下文章

Ros使用Arduino 1安装Arduino IDE

迄今为止最好的arduino开发平台:vscode+platformio,秒杀arduino ide。及vscode+pio对比arduino ide对比Stduino

Arduino官方软件IDE入门

Arduino软件IDE简介

智能小车-Arduino IDE使用说明

Arduino案例实操 -- 智能巡防小车Arduino IDE巡线小车编程