Hi,
currently I have ESPHome with an esp32dev configured to read uart RX with the follow data getting captured.
[08:12:08][D][text_sensor:064]: ‘uart_readline’: Sending state '| Volts = 231.30 | Amps = 0.00 | Watts = 0.00
I was looking to create 3 entities from the data above. One for volts, one for Amps and another one for watts.
Can someone give me an idea on the best way to achieve this?
What config have you got?
There’s a few ways to tackle it depending on how that data is coming in.
uart:
id: uart_bus
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 9600
stop_bits: 1
debug:
direction: RX
dummy_receiver: true
after:
delimiter: “\n”
sequence:
- lambda: |-
UARTDebug::log_string(direction, bytes);
if(bytes.size() > 49)
id(volts1).publish_state( (float) bytes[0] );
else
ESP_LOGD(“main”, “Response data only had %d bytes!!”, bytes.size() );
sensor:
platform: template
id: “volts1”
unit_of_measurement: “V”
name: “volts1”
accuracy_decimals: 0
Id go ask in the Discord server for this.
I’m having a hard time linking your OP data to your config (especially as your code isn’t formatted, (please figure out how to do that for the future ).
Personally I’d probably be looking at the mulcmu approach for this unless you are already competent in cpp.
The UART Bus component provides a write action but no read actions. Typically the UART read is implemented in a custom component that also does the processing. The UART debug sequence can be exploited to act like a call back function whenever there is received data to process. So basically instead of creating a small custom component a large lambda call can be used in the UART debug yaml. This is shared to hopefully help make implementing UART devices a bit easier for average users.
It seems t…