Esp8266 12f 刷固件 - 编译固件
删除hassos esphome 面板下面的目录和文件
ESPHome Dashboard里编译固件、然后下载固件到本地
删除hassos esphome 面板下面的目录和文件
ESPHome Dashboard里编译固件、然后下载固件到本地
0
esphome:
name: test1
includes:
- my_custom_component.h
friendly_name: test1
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "+wajSSS60UBPdF+Sn9uDMv+E7ShZr5M44t4p7xYccqU="
ota:
- platform: esphome
password: "0d2bdf9bf0bc188e8154c8d455dcd474"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Test1 Fallback Hotspot"
password: "JvHSBje0vtFq"
captive_portal:
uart:
id: uart_bus
rx_pin: 3
tx_pin: 1
baud_rate: 9600
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
text_sensor:
- platform: custom
lambda: |-
auto my_custom_sensor = new UartReadLineSensor(id(uart_bus));
App.register_component(my_custom_sensor);
return {my_custom_sensor};
text_sensors:
name: "yykz"
id: "uart_readline"
Compiling .pioenvs/test1/src/esphome/core/string_ref.cpp.o
Compiling .pioenvs/test1/src/esphome/core/util.cpp.o
Compiling .pioenvs/test1/src/main.cpp.o
Linking .pioenvs/test1/firmware.elf
RAM: [==== ] 42.4% (used 34696 bytes from 81920 bytes)
Flash: [===== ] 48.9% (used 500553 bytes from 1023984 bytes)
Building .pioenvs/test1/firmware.bin
esp8266_copy_factory_bin([".pioenvs/test1/firmware.bin"], [".pioenvs/test1/firmware.elf"])
esp8266_copy_ota_bin([".pioenvs/test1/firmware.bin"], [".pioenvs/test1/firmware.elf"])
========================= [SUCCESS] Took 27.68 seconds =========================
INFO Successfully compiled program.
#include "esphome.h"
class UartReadLineSensor : public Component, public UARTDevice, public TextSensor {
public:
UartReadLineSensor(UARTComponent *parent) : UARTDevice(parent) {}
void setup() override {
// nothing to do here
}
int readline(int readch, char *buffer, int len)
{
static int pos = 0;
int rpos;
if (readch > 0) {
switch (readch) {
case '\n': // Ignore new-lines
break;
case '\r': // Return on CR
rpos = pos;
pos = 0; // Reset position index ready for next time
return rpos;
default:
if (pos < len-1) {
buffer[pos++] = readch;
buffer[pos] = 0;
}
}
}
// No end of line has been found, so return -1.
return -1;
}
void loop() override {
const int max_line_length = 80;
static char buffer[max_line_length];
while (available()) {
if(readline(read(), buffer, max_line_length) > 0) {
publish_state(buffer);
}
}
}
};
Time level Tag Message
16:00:00 [W] [component:237]
Component api took a long time for an operation (289 ms).
16:00:00 [W] [component:238]
Components should block for at most 30 ms.
16:00:01 [D] [api.connection:1375]
ESPHome Logs 2024.7.2 (192.168.2.120): Connected successfully
16:00:01 [I] [app:100]
ESPHome version 2024.7.2 compiled on Aug 4 2024, 10:23:22
16:00:01 [C] [wifi:599]
WiFi:
16:00:01 [C] [wifi:427]
Local MAC: 9C:9C:1F:44:55:D0
16:00:01 [C] [wifi:432]
SSID: [5m'ChinaNet-S5S7XA'[6m
16:00:01 [C] [wifi:435]