我的吉尔风声传感器有进展了。
到目前为止,我已经运行了它,并在内部通过uart读取传感器,并在esphome桌面的日志窗口中正确发布变量。它显示为一个集成,但没有显示我的子传感器。
这是我当前的Yaml文件:
esphome:名称:vind平台:ESP32板:esp-wrover-kit包括:- windsonic.h wifi:名称:“阴暗面”密码:“xxxxxx”#启用后备热点(俘虏门户),以防wifi连接失败美联社:名称:“vind后备热点”密码:“xxxxx”captive_portal: #启用日志记录器:baud_rate: 0 #使家庭助理API API:密码:19463331伟德国际"xxxxxx" ota: password: "xxxxxxx" uart: id: wind tx_pin: GPIO1 rx_pin: GPIO3 baud_rate: 19200 sensor: - platform: custom lambda: |- auto my_Windsonic = new Windsonic(id(wind));App.register_component (my_Windsonic);返回{my_Windsonic - > retning_sensor my_Windsonic - > hastighet_sensor};传感器:- name: "Vindretning" unit_of_measurement:°Grader accuracy_decimal: 3
她是我的windaonic.h文件:
#include“esphome.h”类Windsonic:公共组件,公共传感器,公共传感器,公共uartdevice {public:windsonic(uartcomponent *父节目):uartdevice(父){} sensor * hastighet_sensor = new sensor();传感器* Retning_Sensor = New Sensor();浮动恢复;浮动匆匆;void setup()覆盖{//在此处over do do do} void循环()覆盖{//使用Arduino API读取数据,例如字符串行= READSTRINGUNTIL('\ n');string r = line.substring(7,10);string s = line.substring(14,19);Retning = R.Tofloat();hastighet = s.tofloat();Retning_Sensor-> Publish_state(Retning); hastighet_sensor->publish_state(hastighet); retning = 0; hastighet = 0; r = ""; s = ""; } };
我是不是做错了什么让我的变量出现在爱蕾丝里?