Hello,
I’ve set up a JSN-SR04T water level sensor in Mode 2 (querying using a 0x55 command), but it’s not working quite as I expected it to. It seems to query once, then wait the update_interval
and then query again (thus the actual interval for new data is 2*update_interval
) and actually get the data back. It’s difficult to describe but from the logs its apparent.
[12:41:41][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[12:41:44][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:41:44][V][jsn_sr04t.sensor:022]: Read byte from sensor: ff
[12:41:44][V][jsn_sr04t.sensor:022]: Read byte from sensor: 1
[12:41:44][V][jsn_sr04t.sensor:022]: Read byte from sensor: 86
[12:41:44][V][jsn_sr04t.sensor:022]: Read byte from sensor: 86
[12:41:44][V][jsn_sr04t.sensor:048]: Distance from sensor: 390mm, 0.390m
[12:41:44][V][sensor:043]: 'Distance': Received new state 0.390000
[12:41:44][D][sensor:094]: 'Distance': Sending state 0.39000 m with 3 decimals of accuracy
[12:41:49][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:41:54][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:41:54][V][jsn_sr04t.sensor:022]: Read byte from sensor: ff
[12:41:54][V][jsn_sr04t.sensor:022]: Read byte from sensor: 1
[12:41:54][V][jsn_sr04t.sensor:022]: Read byte from sensor: 4e
[12:41:54][V][jsn_sr04t.sensor:022]: Read byte from sensor: 4e
[12:41:54][V][jsn_sr04t.sensor:048]: Distance from sensor: 334mm, 0.334m
[12:41:54][V][sensor:043]: 'Distance': Received new state 0.334000
[12:41:54][D][sensor:094]: 'Distance': Sending state 0.33400 m with 3 decimals of accuracy
[12:41:59][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:42:04][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:42:04][V][jsn_sr04t.sensor:022]: Read byte from sensor: ff
[12:42:04][V][jsn_sr04t.sensor:022]: Read byte from sensor: 1
[12:42:04][V][jsn_sr04t.sensor:022]: Read byte from sensor: 4d
[12:42:04][V][jsn_sr04t.sensor:022]: Read byte from sensor: 4d
[12:42:04][V][jsn_sr04t.sensor:048]: Distance from sensor: 333mm, 0.333m
[12:42:04][V][sensor:043]: 'Distance': Received new state 0.333000
[12:42:04][D][sensor:094]: 'Distance': Sending state 0.33300 m with 3 decimals of accuracy
[12:42:09][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:42:14][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:42:14][V][jsn_sr04t.sensor:022]: Read byte from sensor: ff
[12:42:14][V][jsn_sr04t.sensor:022]: Read byte from sensor: 1
[12:42:14][V][jsn_sr04t.sensor:022]: Read byte from sensor: 44
[12:42:14][V][jsn_sr04t.sensor:022]: Read byte from sensor: 44
[12:42:14][V][jsn_sr04t.sensor:048]: Distance from sensor: 324mm, 0.324m
[12:42:14][V][sensor:043]: 'Distance': Received new state 0.324000
[12:42:14][D][sensor:094]: 'Distance': Sending state 0.32400 m with 3 decimals of accuracy
[12:42:19][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:42:24][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:42:24][V][jsn_sr04t.sensor:022]: Read byte from sensor: ff
[12:42:24][V][jsn_sr04t.sensor:022]: Read byte from sensor: 1
[12:42:24][V][jsn_sr04t.sensor:022]: Read byte from sensor: 50
[12:42:24][V][jsn_sr04t.sensor:022]: Read byte from sensor: 50
[12:42:24][V][jsn_sr04t.sensor:048]: Distance from sensor: 336mm, 0.336m
[12:42:24][V][sensor:043]: 'Distance': Received new state 0.336000
[12:42:24][D][sensor:094]: 'Distance': Sending state 0.33600 m with 3 decimals of accuracy
[12:42:29][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:42:34][V][jsn_sr04t.sensor:014]: Request read out from sensor
[12:42:34][V][jsn_sr04t.sensor:022]: Read byte from sensor: ff
[12:42:34][V][jsn_sr04t.sensor:022]: Read byte from sensor: 1
[12:42:34][V][jsn_sr04t.sensor:022]: Read byte from sensor: 49
[12:42:34][V][jsn_sr04t.sensor:022]: Read byte from sensor: 49
[12:42:34][V][jsn_sr04t.sensor:048]: Distance from sensor: 329mm, 0.329m
[12:42:34][V][sensor:043]: 'Distance': Received new state 0.329000
[12:42:34][D][sensor:094]: 'Distance': Sending state 0.32900 m with 3 decimals of accuracy
My configuration
---
substitutions:
device_name: "rainwater-buffer-tank"
friendly_name: Rainwater Buffer Tank
<<: !include .base.yaml
logger:
level: VERBOSE
esp32:
board: esp32dev
framework:
type: arduino
uart:
- baud_rate: 9600
tx_pin: 17
rx_pin: 18
binary_sensor:
- platform: gpio
id: switch_state
pin:
number: 4
inverted: True
mode:
input: True
pullup: True
on_state:
then:
- switch.toggle: relay
sensor:
- platform: "jsn_sr04t"
name: "Distance"
update_interval: 5s
switch:
- platform: gpio
pin: 16
id: relay
name: Relay
restore_mode: ALWAYS_OFF
Thank you in advance for any replies.