thank you , it works fine .
does it change a lot if first value in input is “SR”
second problem : how in lambda check if first input is “AA” or “SR”
thank you , it works fine .
does it change a lot if first value in input is “SR”
second problem : how in lambda check if first input is “AA” or “SR”
%s
will read in a string. If you only have the two options “AA” or “SR” you could do two sscanf() statements with “AA;%f;%f” and “SR;%f;%f”
I’m trying to send and receive data from an ESP32 to an Arduino Mega via UART.
Sending goes from the ESP to the Mega in the direction of Mega.
I can see that in the Mega log and in the ESP log.
When data is sent from the Mega, I can still see it in the serial monitor in the Mega but nothing arrives in the ESP, at least that’s what it looks like.
Can someone please help me?
her is the Arduino-Mega Serial-Output.
first lines is from ESP-restart.
12:34:08.518 -> Empfangen vom ESP : [878781][D][Updater.cpp:133] begin(): OTA Partition: app0
12:34:20.850 -> Empfangen vom ESP : [891108][V][WiFiGeneric.cpp:360] _arduino_event_cb(): STA Disconnected: SSID: ASUS, BSSID: 40:b0:76:9a:4d:70, Reason: 8
12:34:20.881 -> Empfangen vom ESP : [891108][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino EvenCONNECTED
12:34:20.881 -> Empfangen vom ESP : [891115][W][WiFiGeneric.cpp:950] _eventCallback(): Reason: 8 - 3][V][WiFiGeneric.cpp:341] _arduino_event_cb(): STA Stopped
12:34:21.213 -> Empfangen vom ESP : [891128][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Even[ 753][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
12:34:21.213 -> Empfangen vom ESP : [ 786][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started
12:34:21.248 -> Empfangen vom ESP : [ 787][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START
12:34:27.149 -> Empfangen vom ESP : [ 6710][V][WiFiGeneric.cpp:381] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 9
12:34:27.149 -> Empfangen vom ESP : [ 6710][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 1 - SCAN_DONE
12:34:28.017 -> Empfangen vom ESP : [ 7558][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: ASUS, BSSID: 40:b0:76:9a:4d:70, Channel: 10, Auth: WPA2_PSK
12:34:28.017 -> Empfangen vom ESP : [ 7559][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Even][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got New IP:192.168.2.119
12:34:28.061 -> Empfangen vom ESP : [ 7574][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino EvenFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.2.119, MASK: 255.255.255.0, GW: 192.168.2.1
12:36:47.411 -> Empfangen vom ESP :
12:38:17.789 -> Empfangen vom ESP : DataToSend from button esp
12:38:44.242 -> Nachricht Serial.print von Mega To Esp: dd
The last lines 12:38:17.789 , was i pressed the button on the ESP
The last line shows a manual input from me on the Arduino Mega’s serial monitor
The Logfile from ESP32 (ESP32-S2-DevKit-M-1)
[12:34:30][I][app:100]: ESPHome version 2024.10.3 compiled on Nov 19 2024, 12:32:50
[12:34:30][C][wifi:600]: WiFi:
[12:34:30][C][wifi:428]: Local MAC: 70:04:1D:FB:D9:DA
[12:34:30][C][wifi:433]: SSID: [redacted]
[12:34:30][C][wifi:436]: IP Address: 192.168.2.119
[12:34:30][C][wifi:440]: BSSID: [redacted]
[12:34:30][C][wifi:441]: Hostname: 'watercontroltest'
[12:34:30][C][wifi:443]: Signal strength: -46 dB ▂▄▆█
[12:34:30][V][wifi:445]: Priority: 0.0
[12:34:30][C][wifi:447]: Channel: 10
[12:34:30][C][wifi:448]: Subnet: 255.255.255.0
[12:34:30][C][wifi:449]: Gateway: 192.168.2.1
[12:34:30][C][wifi:450]: DNS1: 192.168.2.1
[12:34:30][C][wifi:451]: DNS2: 0.0.0.0
[12:34:30][C][logger:185]: Logger:
[12:34:30][C][logger:186]: Level: VERBOSE
[12:34:30][C][logger:188]: Log Baud Rate: 115200
[12:34:30][C][logger:189]: Hardware UART: USB_CDC
[12:34:30][C][uart.arduino_esp32:151]: UART Bus 0:
[12:34:30][C][uart.arduino_esp32:152]: TX Pin: GPIO44
[12:34:30][C][uart.arduino_esp32:153]: RX Pin: GPIO45
[12:34:30][C][uart.arduino_esp32:155]: RX Buffer Size: 256
[12:34:30][C][uart.arduino_esp32:157]: Baud Rate: 115200 baud
[12:34:30][C][uart.arduino_esp32:158]: Data Bits: 8
[12:34:30][C][uart.arduino_esp32:159]: Parity: NONE
[12:34:30][C][uart.arduino_esp32:160]: Stop bits: 1
[12:34:30][C][uart.button:014]: UART Button 'UART String Output'
[12:34:30][C][captive_portal:089]: Captive Portal:
[12:34:30][C][web_server:153]: Web Server:
[12:34:30][C][web_server:154]: Address: 192.168.2.119:80
[12:34:30][C][mdns:116]: mDNS:
[12:34:30][C][mdns:117]: Hostname: watercontroltest
[12:34:30][V][mdns:118]: Services:
[12:34:30][V][mdns:120]: - _esphomelib, _tcp, 6053
[12:34:30][V][mdns:122]: TXT: friendly_name = WaterControler_test
[12:34:30][V][mdns:122]: TXT: version = 2024.10.3
[12:34:30][V][mdns:122]: TXT: mac = 70041dfbd9da
[12:34:30][V][mdns:122]: TXT: platform = ESP32
[12:34:30][V][mdns:122]: TXT: board = esp32-s2-saola-1
[12:34:30][V][mdns:122]: TXT: network = wifi
[12:34:30][V][mdns:122]: TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[12:34:30][V][mdns:120]: - _http, _tcp, 80
[12:34:30][C][esphome.ota:073]: Over-The-Air updates:
[12:34:30][C][esphome.ota:074]: Address: 192.168.2.119:3232
[12:34:30][C][esphome.ota:075]: Version: 2
[12:34:30][C][esphome.ota:078]: Password configured
[12:34:30][C][safe_mode:018]: Safe Mode:
[12:34:30][C][safe_mode:020]: Boot considered successful after 60 seconds
[12:34:30][C][safe_mode:021]: Invoke after 10 boot attempts
[12:34:30][C][safe_mode:023]: Remain in safe mode for 300 seconds
[12:34:30][C][api:140]: API Server:
[12:34:30][C][api:141]: Address: 192.168.2.119:6053
The ESPhome-Code
uart:
tx_pin: GPIO44
rx_pin: GPIO45
id: uart_bus
baud_rate: 115200
debug:
direction: BOTH
dummy_receiver: true
#after:
# delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
button:
- platform: uart
name: "UART String Output"
data: 'DataToSend from button esp'
#custom_component:
#- lambda: |-
# auto my_custom = new MyCustomComponent(id(uart_bus));
# return {my_custom};
captive_portal:
sorry all, now works fine… i used the wrong RX/TX Pins…
I have an evacuated tube HWS with a controller for the pump etc, The controller has a serial connection which I have connected an ESP32 and am reading the binary data coming from it.
I have talked with the manufacturer and they state that it must be read in binary.
the MSB of each byte is part of the version number
The next three bits contain the sequence number of the byte “0-7”
The remaining four bits contain data.
The first six bytes (last four bits of each or nibble) are the upper and lower temperature readings.
The last two bytes are status bits eg: pump on/off etc
I’ve managed to get the binary data in the logs with some trial and error.
I would like to be able to turn the data into sensors, three temperature readings and three statuses but I’m at a loss now and can’t find any examples reading binary data.
Here’s my yaml.
I’ve tried setting after bytes to 8 but it seems to cause timeout issues and disconnections. I randomly picked 80 and it seems to work without error but repeats which is not ideal.
Is there a way to get it to sucessfully read just eight bytes or is that irrelevant?
esphome:
name: apricus-hws
friendly_name: Apricus HWS
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "dXybdS3IqHoFyjf8j7CxUGN342/xFlZhNT9ea43JB3c="
ota:
- platform: esphome
password: "0f5953e7a20348dd1b540fe0e8f9e743"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: HIGH
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Apricus-Hws Fallback Hotspot"
password: ""
captive_portal:
uart:
baud_rate: 4800
rx_pin: 20
debug:
direction: RX
dummy_receiver: true
after:
bytes: 80
sequence:
- lambda: UARTDebug::log_binary(direction, bytes, ';');
Heres a copy of some of the logs. You can’t write to it only receive and it just continuously sends data.
INFO ESPHome 2024.11.2
INFO Reading configuration /config/esphome/apricus-hws.yaml...
INFO Starting log output from 192.168.0.28 using esphome API
INFO Successfully connected to apricus-hws @ 192.168.0.28 in 0.113s
INFO Successful handshake with apricus-hws @ 192.168.0.28 in 0.075s
[20:25:57][I][app:100]: ESPHome version 2024.11.2 compiled on Dec 1 2024, 14:53:50
[20:25:57][C][wifi:600]: WiFi:
[20:25:57][C][wifi:428]: Local MAC: 24:58:7C:36:52:4C
[20:25:57][C][wifi:433]: SSID: 'TelstraC18C1E'[redacted]
[20:25:57][C][wifi:436]: IP Address: 192.168.0.28
[20:25:57][C][wifi:440]: BSSID: A2:B5:3C:C1:8C:26[redacted]
[20:25:57][C][wifi:441]: Hostname: 'apricus-hws'
[20:25:57][C][wifi:443]: Signal strength: -49 dB ▂▄▆█
[20:25:57][C][wifi:447]: Channel: 6
[20:25:57][C][wifi:448]: Subnet: 255.255.255.0
[20:25:57][C][wifi:449]: Gateway: 192.168.0.1
[20:25:57][C][wifi:450]: DNS1: 8.8.8.8
[20:25:57][C][wifi:451]: DNS2: 8.8.4.4
[20:25:57][C][logger:185]: Logger:
[20:25:57][C][logger:186]: Level: DEBUG
[20:25:57][C][logger:188]: Log Baud Rate: 115200
[20:25:57][C][logger:189]: Hardware UART: USB_CDC
[20:25:57][C][uart.arduino_esp32:151]: UART Bus 0:
[20:25:57][C][uart.arduino_esp32:153]: RX Pin: GPIO20
[20:25:57][C][uart.arduino_esp32:155]: RX Buffer Size: 256
[20:25:57][C][uart.arduino_esp32:157]: Baud Rate: 4800 baud
[20:25:57][C][uart.arduino_esp32:158]: Data Bits: 8
[20:25:57][C][uart.arduino_esp32:159]: Parity: NONE
[20:25:57][C][uart.arduino_esp32:160]: Stop bits: 1
[20:25:57][C][captive_portal:089]: Captive Portal:
[20:25:57][D][uart_debug:196]: <<< 0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000
[20:25:57][C][mdns:116]: mDNS:
[20:25:57][C][mdns:117]: Hostname: apricus-hws
[20:25:57][C][esphome.ota:073]: Over-The-Air updates:
[20:25:57][C][esphome.ota:074]: Address: apricus-hws.local:3232
[20:25:57][C][esphome.ota:075]: Version: 2
[20:25:57][C][esphome.ota:078]: Password configured
[20:25:57][C][safe_mode:018]: Safe Mode:
[20:25:57][C][safe_mode:020]: Boot considered successful after 60 seconds
[20:25:57][C][safe_mode:021]: Invoke after 10 boot attempts
[20:25:57][C][safe_mode:023]: Remain in safe mode for 300 seconds
[20:25:57][C][api:140]: API Server:
[20:25:57][C][api:141]: Address: apricus-hws.local:6053
[20:25:57][C][api:143]: Using noise encryption: YES
[20:25:57][D][uart_debug:196]: <<< 0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000
[20:25:57][D][uart_debug:196]: <<< 0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000 (0xF0);0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000
This is the 0-7 bytes
0b00000000 (0x00);0b00010101 (0x15);0b00100001 (0x21);0b00110111 (0x37);0b01001101 (0x4D);0b01010110 (0x56);0b01100000 (0x60);0b11110000
for example bytes 0 and 1 give the binary number of 01010000 (add the last four bits of data together, second byte first) converted to decimal gives 80 minus 50 gives a temperature of 30degC. Through trial and error i found I had to minus 50 from the readings to get the temperature, I’m guessing it’s something to do with ADC.
I know it’s a lot but any help would be appreciated.
If I should start a new thread that’s fine.
I don’t know if this will help, but this setup shows some bitwise manipulation (although with ble data)
This thread has some more examples on parsing uart into sensors. But not necessarily binary processing.
I did this once but I’ll be buggered if I can remember how it works;) Maybe there is something around here that is of use. But maybe not.
Thanks guys that’s more information than I could find.
It looks to be very uncommon to be working with binary data.
This is all very new to me and I have extremely limited experience with the code, definitely have a lot to learn to figure this out.
Up until now I have found similar examples to what I need and have tweaked them to suit. Or in HA used the visual editor and worked things out.
Hi, had a problem I cant solve. In my car I had a arduino nano with mcp2515 canbus adapter, it both reading/writing data to canbus and give me a lot of fun extra functions. Remote start of the diesel heater from the key is one of them. I also add add a wemos d1 to connect it to HA, it let me even start the diesel heater from HA.
The problem is I want to import data from the diesel heater to HA, coolant temperature for a example. The heater send data in hex value like (“id: 500, data: 0x00, 0x00, 0x00, 0x50, 0x00”), 0x50 is the coolant temperature and 50 degree in celcius. Want this value as a sensor in HA.
Becuse im a beginner I begin small by write a test code to my arduino nano. Every second it send “1” to serial bus, my goal is to see the “1” in HA as a decimal sensor but the value not come longer than I can see it in esphome;s log terminal if I use debug mode. Had tested many example hints but it will not show upp as sensor in HA. Had read many threads but it will not work when I try, someone who can help me in the right direction?
So post what you get on your log…
Yes. As a test my arduino nano send “123” to serial every second, HA see it when my yaml code is in debug mode. The idea is to make a sensor of the value “123” but not understund right. Before I tried to make custom uart text sensor but the sensor never change state for unknown.
Log:
[20:52:18][C][logger:185]: Logger:
[20:52:18][C][logger:186]: Level: DEBUG
[20:52:18][C][logger:188]: Log Baud Rate: 115200
[20:52:18][C][logger:189]: Hardware UART: UART0
[20:52:18][C][uart.arduino_esp8266:118]: UART Bus:
[20:52:18][C][uart.arduino_esp8266:119]: TX Pin: GPIO1
[20:52:18][C][uart.arduino_esp8266:120]: RX Pin: GPIO3
[20:52:18][C][uart.arduino_esp8266:122]: RX Buffer Size: 256
[20:52:18][C][uart.arduino_esp8266:124]: Baud Rate: 115200 baud
[20:52:18][C][uart.arduino_esp8266:125]: Data Bits: 8
[20:52:18][C][uart.arduino_esp8266:126]: Parity: NONE
[20:52:18][C][uart.arduino_esp8266:127]: Stop bits: 1
[20:52:18][C][uart.arduino_esp8266:129]: Using hardware serial interface.
[20:52:18][W][uart.arduino_esp8266:143]: You're using the same serial port for logging and the UART component. Please disable logging over the serial port by setting logger->baud_rate to 0.
[20:52:18][C][template.switch:068]: Template Switch 'Dieselvärmare'
[20:52:18][C][template.switch:090]: Restore Mode: always OFF
[20:52:18][C][template.switch:057]: Optimistic: YES
[20:52:18][D][uart_debug:158]: <<< "123"
[20:52:18][C][uart.button:014]: UART Button 'Dieselvärmare På'
[20:52:18][C][uart.button:014]: UART Button 'Dieselvärmare Av'
[20:52:18][C][captive_portal:089]: Captive Portal:
[20:52:18][C][web_server:153]: Web Server:
[20:52:18][C][web_server:154]: Address: esid.local:80
[20:52:18][C][mdns:116]: mDNS:
[20:52:18][C][mdns:117]: Hostname: esid
[20:52:18][C][esphome.ota:073]: Over-The-Air updates:
[20:52:18][C][esphome.ota:074]: Address: esid.local:8266
[20:52:18][C][esphome.ota:075]: Version: 2
[20:52:18][C][safe_mode:018]: Safe Mode:xxx
[20:52:18][C][safe_mode:019]: Boot considered successful after 60 seconds
[20:52:18][C][safe_mode:021]: Invoke after 10 boot attempts
[20:52:18][C][safe_mode:022]: Remain in safe mode for 300 seconds
[20:52:18][C][api:140]: API Server:
[20:52:18][C][api:141]: Address: esid.local:6053
[20:52:18][C][api:145]: Using noise encryption: NO
[20:52:18][D][api:103]: Accepted
[20:52:18][C][improv_serial:032]: Improv Serial:
[20:52:18][D][api.connection:1446]: Home Assistant 2022.10.5 (xxx): Connected successfully
[20:52:19][D][uart_debug:158]: <<< "123"
[20:52:20][D][uart_debug:158]: <<< "123"
[20:52:21][D][uart_debug:158]: <<< "123"
[20:52:22][D][uart_debug:158]: <<< "123"
[20:52:23][D][uart_debug:158]: <<< "123"
[20:52:24][D][uart_debug:158]: <<< "123"
[20:52:26][D][uart_debug:158]: <<< "123"
[20:52:27][D][uart_debug:158]: <<< "123"
[20:52:28][D][uart_debug:158]: <<< "123"
[20:52:29][D][uart_debug:158]: <<< "123"
[20:52:30][D][uart_debug:158]: <<< "123"
[20:52:31][D][uart_debug:158]: <<< "123"
[20:52:32][D][uart_debug:158]: <<< "123"
[20:52:33][D][uart_debug:158]: <<< "123"
Yaml:
substitutions:
name: esid
friendly_name: esid_dosa
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
includes:
# - uart_read_line_sensor.h
esp8266:
board: esp01_1m
# Enable logging
logger:
# baud_rate: 0
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
# Set up a wifi access point
ap: {}
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp8266.yaml@main
import_full_config: true
# To have a "next url" for improv serial
web_server:
uart:
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 115200
debug:
direction: BOTH
dummy_receiver: true
after:
delimiter: "\r\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
switch:
- platform: template
name: "Dieselvärmare"
optimistic: true
turn_on_action:
- uart.write: "heater_on\r\n"
turn_off_action:
- uart.write: "heater_off\r\n"
button:
- platform: uart
name: "Dieselvärmare På"
data: "heater_on\r\n"
- platform: uart
name: "Dieselvärmare Av"
data: "heater_off\r\n"
Make a template sensor:
sensor:
- platform: template
name: "T1"
id: "testsensor"
and update it in uart debug:
sequence:
- lambda: |-
UARTDebug::log_string(direction, bytes);
id(testsensor).publish_state( bytes[0] );
Thanks. I tested it but it not work properly, it make no differnce what number I send HA see it the sensor show as 49. Tested a new custom text sensor and now it work, but not properly. It receive “123” and after nothing, some seconds after it receive “123123123123123123123123123123…”. The text sensor I tested was:
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: "dogshit"
And log:
:28:23][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:24][D][uart_debug:158]: <<< "123"
[22:28:24][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:25][D][uart_debug:158]: <<< "123"
[22:28:25][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:26][D][uart_debug:158]: <<< "123"
[22:28:26][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:27][D][uart_debug:158]: <<< "123"
[22:28:27][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:28][D][text_sensor:064]: 'dogshit': Sending state '3123123123123123123123123123123123123123123123123123123123123123123123123123123'
[22:28:28][D][uart_debug:158]: <<< "123"
[22:28:28][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:29][D][uart_debug:158]: <<< "123"
[22:28:29][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:30][D][uart_debug:158]: <<< "123"
[22:28:30][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:31][D][uart_debug:158]: <<< "123"
[22:28:31][D][sensor:093]: 'T1': Sending state 49.00000 with 1 decimals of accuracy
[22:28:32][D][uart_debug:158]: <<< "123"
only if it starts with 1 I expect… Try 234234 and you get 50?
You send ascii symbols to esp, symbol “1” is 49.
It’s not clear to me what you want to accomplish and why you have Nano there in the first place.
Not sure but will remember i got same with other numbers. Send ”hej” and your test sensor receive it as 103. I check it again when home.
The nano with a mcp2515 module is reading and writing on the canbus line in my car, from beginning HA was not included to the project. After some time I add a wemos d1 to connect it to HA. The idea is I want my read canbus and send interesting data to HA like battery voltage, diesel heater sensors… Already successfull write buttons to send data from HA, now i want receive data to HA. If it is in decimal or text dosent matter, much data that I want to receive will be in hex.
Should be 104, symbol “h”.
I guess you are using Serial.print() on your arduino code, which is converting data to ascii. You could use Serial.write if you want to send hex. Then read it byte by byte on your Esphome. The example I posted reads the first byte.
Otherwise you have to convert the serial data to string and use text sensor instead.
Thansk again, yes using serial.print(). Will test your hints and come back after test
Consider also skipping the Nano and use just esphome with mcp2515 component.
I see. Your example work but as you say everything it receive shows as ascii, maybe it can be harder to translate in HA. Did you maybe had a example of a text sensor just to have someting to begin with. I test a textsensor before but it not shows as a value, it shows everything as a endless value. Im not so good coding but want to learn, small examples had helped me before to write bigger codes both to HA and arduino ide.
You might be better off just testing in hex like Karosm mentioned.
There’s more examples for recieving and publishing here.
There’s some examples of setting up hex globals here which might be useful for testing.
It all depends what you want to accomplish. If you send hex values and want to use these values to automation or you send some text to be visualized in HA…