我在将 NodeMCU v3 连接到 Arduino IDE 时遇到问题。我已经使用连接到超声波传感器的 Arduino UNO(没有 firebase 部分)完成了相同的代码,没有问题,但是当尝试将 NodeMCU v3 连接到超声波传感器时,我收到了这个错误。
我要做的是在使用 NodeMCU v3 时从传感器收集数据并将其存储到火力基地......我一直遇到问题。
这是我在 Arduino IDE 中的 NodeMCU 设置:
板:NodeMCU 1.0(ESP-12E 模块) 上传速度:115200 CPU 频率:80 MHz 闪存大小:4m(无 spiffs) 调试端口:禁用 调试级别:无 Iwlp 变体:v2 低内存 VTables:闪存异常:启用 擦除闪存:仅草图端口:Com6
#include <FirebaseArduino.h>
#include <ESP8266WiFi.h> //wifi library
#define WIFI_SSID "wifi001" //replace SSID with your wifi username
#define WIFI_PASSWORD "1234" //replace PWD with your wifi password
#define WIFI_LED D5 //connect a led to any of the gpio pins of the board and replace pin_number with it eg. D4
#define FIREBASE_HOST "some_firebase_host" //link of api
#define FIREBASE_AUTH "secret" //database secret
int trig = 8;
int echo = 7;
long microsecondsToInches(float microseconds)
{
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(float microseconds)
{
return microseconds / 29 / 2;
}
void setup()
{
Serial.begin(9600);
pinMode(WIFI_LED, OUTPUT); //define pinmodes
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
//connect to wifi
while (WiFi.status() != WL_CONNECTED)
{ //wait till connected to WiFi
delay(100);
digitalWrite(WIFI_LED, LOW); //Blink the light till connected to WiFi
delay(100);
digitalWrite(WIFI_LED, HIGH);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
digitalWrite(WIFI_LED, HIGH);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); //connect to Database
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
delay(1000);
}
void loop()
{
String firebaseResult = firebaseGet();
delay(100);
// Transmitting pulse
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
float t = 0, h = 0, hp = 0, inches = 0, cm = 0, offset = 1.8;
if (firebaseResult == "ON")
{
//code to happen if the status is ON
// Waiting for pulse
t = pulseIn(echo, HIGH);
// Calculating distance
h = t;
hp = h;
h = t / offset; //half the bottle (16)
h = h - 7; // water height, 0 - 50 cm - 0-16cm
//
hp = (2 * h); // distance in %, 0-100 %
cm = microsecondsToCentimeters(hp);
Serial.print(cm);
Serial.print("\n");
delay(1000);
}
else
{
//code to happen if the status is OFF
}
}
显示的错误是:
Arduino: 1.8.8 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Enabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Elias\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Elias\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Elias\Documents\Arduino\libraries -fqbn=esp8266:esp8266:nodemcuv2:xtal=80,vt=flash,exception=enabled,eesz=4M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200 -ide-version=10808 -build-path C:\Users\Elias\AppData\Local\Temp\arduino_build_989711 -warnings=none -build-cache C:\Users\Elias\AppData\Local\Temp\arduino_cache_309203 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\esptool\2.5.0-3-20ed2b9 -prefs=runtime.tools.esptool-2.5.0-3-20ed2b9.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\esptool\2.5.0-3-20ed2b9 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9 -prefs=runtime.tools.xtensa-lx106-elf-gcc-2.5.0-3-20ed2b9.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9 -prefs=runtime.tools.mkspiffs.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\2.5.0-3-20ed2b9 -prefs=runtime.tools.mkspiffs-2.5.0-3-20ed2b9.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\2.5.0-3-20ed2b9 -verbose C:\Users\Elias\Desktop\level_meter\mustwork\now\now.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Elias\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Elias\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Elias\Documents\Arduino\libraries -fqbn=esp8266:esp8266:nodemcuv2:xtal=80,vt=flash,exception=enabled,eesz=4M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200 -ide-version=10808 -build-path C:\Users\Elias\AppData\Local\Temp\arduino_build_989711 -warnings=none -build-cache C:\Users\Elias\AppData\Local\Temp\arduino_cache_309203 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\esptool\2.5.0-3-20ed2b9 -prefs=runtime.tools.esptool-2.5.0-3-20ed2b9.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\esptool\2.5.0-3-20ed2b9 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9 -prefs=runtime.tools.xtensa-lx106-elf-gcc-2.5.0-3-20ed2b9.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9 -prefs=runtime.tools.mkspiffs.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\2.5.0-3-20ed2b9 -prefs=runtime.tools.mkspiffs-2.5.0-3-20ed2b9.path=C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\2.5.0-3-20ed2b9 -verbose C:\Users\Elias\Desktop\level_meter\mustwork\now\now.ino
Using board 'nodemcuv2' from platform in folder: C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2
Using core 'esp8266' from platform in folder: C:\Users\Elias\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2
Detecting libraries used...
"C:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-3-20ed2b9/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2/tools/sdk/include" "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2/tools/sdk/lwip2/include" "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\Elias\\AppData\\Local\\Temp\\arduino_build_989711/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=c++11 -ffunction-sections -fdata-sections -fexceptions -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10808 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_NODEMCU\"" -DESP8266 "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2\\cores\\esp8266" "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2\\variants\\nodemcu" "C:\\Users\\Elias\\AppData\\Local\\Temp\\arduino_build_989711\\sketch\\now.ino.cpp" -o nul
"C:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\2.5.0-3-20ed2b9/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2/tools/sdk/include" "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2/tools/sdk/lwip2/include" "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\Elias\\AppData\\Local\\Temp\\arduino_build_989711/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=c++11 -ffunction-sections -fdata-sections -fexceptions -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10808 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_NODEMCU\"" -DESP8266 "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2\\cores\\esp8266" "-IC:\\Users\\Elias\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.5.0-beta2\\variants\\nodemcu" "-IC:\\Users\\Elias\\Documents\\Arduino\\libraries\\firebase-arduino-master\\src" "C:\\Users\\Elias\\AppData\\Local\\Temp\\arduino_build_989711\\sketch\\now.ino.cpp" -o nul
In file included from C:\Users\Elias\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22:0,
from C:\Users\Elias\Desktop\level_meter\mustwork\now\now.ino:1:
C:\Users\Elias\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:26:25: fatal error: ArduinoJson.h: No such file or directory
#include <ArduinoJson.h>
^
compilation terminated.
Using library firebase-arduino-master at version 0.1 in folder: C:\Users\Elias\Documents\Arduino\libraries\firebase-arduino-master
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
Invalid library found in C:\Users\Elias\Documents\Arduino\libraries\teckel12-arduino-new-ping-2ebf391d9be2: no headers files (.h) found in C:\Users\Elias\Documents\Arduino\libraries\teckel12-arduino-new-ping-2ebf391d9be2
Invalid library found in C:\Users\Elias\Documents\Arduino\libraries\teckel12-arduino-new-ping-2ebf391d9be2: no headers files (.h) found in C:\Users\Elias\Documents\Arduino\libraries\teckel12-arduino-new-ping-2ebf391d9be2