#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
//Firebase settings
#define FIREBASE_HOST "..........firebaseio.com/" //cant share
#define FIREBASE_AUTH "..............." //cant share
//Wi-Fi settings
#define WIFI_SSID "kello"
#define WIFI_PASSWORD "8888"
//Define trigger and echo digital pins
const int trigPin = 4;
const int echoPin = 3;
// The amount of time the ultrassonic wave will be travelling for
long duration = 0;
// Define the distance variable
double distance = 0;
void setup()
{
Serial.begin(9600);
// Connect to Wi-Fi
Serial.print("Wi-Fi...");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("Connected to: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
// Ultrasonic sensor, set echo as Input and trigger as Output
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop()
{
getDistance();
// Prints the distance value to the serial monitor
Serial.print("Distance: ");
Serial.println(distance);
delay(500);
}
void getDistance()
{
// Clear trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// trigPin HIGH por 10ms
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
//Reads echoPin, returns the travel time of the sound wave in ms
duration = pulseIn(echoPin, HIGH);
// Calculating the distance, in centimeters, using the formula described in the first section.
distance = duration * 0.034 / 2;
// Sends the distance value to Firebase
Firebase.setFloat("distance", distance);
}
Я выпускник компьютера, поэтому у меня мало знаний о nodemcu. Я видел некоторые документы о nodemcu. Я хочу показать данные, полученные ультразвуковым датчиком расстояния c, в базе данных пожарной базы в реальном времени. Но я не могу понять, почему я не могу получить вывод serial.println (distance) в окне com5, даже если код успешно компилируется. Это то, что я получаю при запуске программы
Executable segment sizes:
IROM : 330560 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 27760 / 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 : 25160 ) - zeroed variables (global, static) in RAM/HEAP
Sketch uses 361772 bytes (34%) of program storage space. Maximum is 1044464 bytes.
Global variables use 28612 bytes (34%) of dynamic memory, leaving 53308 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM5
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: ec:fa:bc:c1:44:d2
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 365920 bytes to 264395...
Writing at 0x00000000... (5 %)
Writing at 0x00004000... (11 %)
Writing at 0x00008000... (17 %)
Writing at 0x0000c000... (23 %)
Writing at 0x00010000... (29 %)
Writing at 0x00014000... (35 %)
Writing at 0x00018000... (41 %)
Writing at 0x0001c000... (47 %)
Writing at 0x00020000... (52 %)
Writing at 0x00024000... (58 %)
Writing at 0x00028000... (64 %)
Writing at 0x0002c000... (70 %)
Writing at 0x00030000... (76 %)
Writing at 0x00034000... (82 %)
Writing at 0x00038000... (88 %)
Writing at 0x0003c000... (94 %)
Writing at 0x00040000... (100 %)
Wrote 365920 bytes (264395 compressed) at 0x00000000 in 23.4 seconds (effective 125.3 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
Пожалуйста, помогите мне и дайте мне знать, если требуется дополнительная информация.