错误是:
Arduino: 1.8.12 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Executable segment sizes:
IROM : 329240 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 27992 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1408 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 2044 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 25168 ) - zeroed variables (global, static) in RAM/HEAP
Sketch uses 360684 bytes (34%) of program storage space. Maximum is 1044464 bytes.
Global variables use 28620 bytes (34%) of dynamic memory, leaving 53300 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM4
Connecting........_____....._____....._____....._____....._____....._____....._____
Traceback (most recent call last):
File "C:\Users\nEW u\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.2/tools/upload.py", line 65, in <module>
esptool.main(cmdline)
File "C:/Users/nEW u/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.2/tools/esptool\esptool.py", line 2890, in main
esp.connect(args.before)
File "C:/Users/nEW u/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.2/tools/esptool\esptool.py", line 483, in connect
raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Invalid head of packet (0xF0)
esptool.FatalError: Failed to connect to ESP8266: Invalid head of packet (0xF0)
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
这是我使用 arduino 的超声波传感器的引脚配置
1. VCC pin to +5v on the Arduino board.
2. Trigger to digital pin 7 on your Arduino board.
3. Echo to digital pin 6 on your Arduino board.
4. GND with GND on Arduino.
这是我正在执行的代码
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
// Set these to run example.
#define FIREBASE_HOST "......" //cannot share for privacy purpose
#define FIREBASE_AUTH "......" //cannot share for privacy purpose
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "PASSWORD"
const int pingPin = 7;
const int echoPin = 6;
String myString;
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);
}
void loop() {
long duration, inches, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
cm = microsecondsToCentimeters(duration);
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
myString= String(duration);
Firebase.setString("Ultrasonic/DistanceInCm",myString);
delay(1000);
}
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}
该代码是关于从我的超声波距离传感器获取信息,然后使用 esp8266 wifi 模块将其显示在 firebase 实时数据库中请指导我做错了什么,我需要更多信息让我知道
尝试提供您使用的确切硬件。
错误消息显示闪烁到 NodeMCU(NodeMCU 0.9(ESP-12 模块))的问题,您的原理图显示带有 ESP 模块的 Arduino UNO。
检查以下内容:
是否为闪烁选择了正确的硬件
是否为您使用的 USB 端口安装了正确的驱动程序
是否选择了正确的 USB 端口
总而言之 - 您的程序甚至没有传输到使用的硬件。仔细阅读错误消息,它指出“FatalError('Failed to connect to” -> 它无法识别连接的硬件
我怎么知道我的硬件是什么?
首先查看您购买的发票/订单。检查 PCB 上印刷的名称/商标。查看芯片以识别电路板。拍照并将其作为问题发布到 stack-exchange