Can't get JSN-SR04T distance sensor to work

Hi,

I don’t seem to get a JSN-SR04T distance sensor to work. I have tried with both a ESP8266 board and a atom lite esp32 and none of them work. I have also bought an extra JSN-SR04T sensor if the first one was faulty but I get the same result.

> [01:06:35][D][ultrasonic.sensor:036]: 'garden_watertank_distance' - Distance measurement timed out!
> [01:06:35][D][sensor:093]: 'garden_watertank_distance': Sending state nan m with 2 decimals of accuracy

If I connect a HC-SR04 sensor it works perfectly

> [00:57:40][D][ultrasonic.sensor:040]: 'garden_watertank_distance' - Got distance: 0.057 m
> [00:57:40][D][sensor:093]: 'garden_watertank_distance': Sending state 0.05677 m with 2 decimals of accuracy

My config file for the esp8266 board is

> > esphome:
> >   name: esphome-web-cfa09a
> >   friendly_name: Vattenniva
> > 
> > esp8266:
> >   board: esp01_1m
> > 
> > # Enable logging
> > logger:
> > 
> > # Enable Home Assistant API
> > api:
> >   encryption:
> >     key: "8pzfT6DRfSi5c/BE/dIQIZD9UFd78PnMOL+g1u9t33A="
> > 
> > ota:
> > 
> > 
> > wifi:
> >   ssid: !secret wifi_ssid
> >   password: !secret wifi_password
> > 
> >   # Enable fallback hotspot (captive portal) in case wifi connection fails
> >   ap:
> >     ssid: "Esphome-Web-Cfa09A"
> >     password: "RSToQSbvHwRY"
> > 
> > captive_portal:
> > 
> > sensor:
> > 
> >  # The actual distance sensor
> >  - platform: ultrasonic
> >    trigger_pin: 3
> >    echo_pin: 1
> >    name: garden_watertank_distance
> >    update_interval: 5s
> >    pulse_time: 20us

Any suggestions on a resolution will be appreciated. I have also tried a pulse time of 50us.

They should be functionally equivalent. Are you sure you’re wiring it correctly?

99,9% sure. I can also here a small click sound from the speaker if I listen carefully.

Two things might be worth checking:

  1. When I ordered my JSN-SR04T sensors from Amazon, I received a very similar looking AJ-SR04M, it said JSN-SR04T on the box but in the box was an AJ-SR04M. Couldn’t get it to work, asked Amazon for a replacement and received the same incorrectly labled boxes again - had to order from a different vendor.

  2. I couldn’t get the code to work just using the pin numbers, it worked fine on my old sensor (forgot what it’s called) but I had to change it to this

sensor:
 - platform: ultrasonic
   trigger_pin: GPIO13
   echo_pin: GPIO12

I struggled also with this sensor. I discovered that I also purchased a AJ-SR04M sensor and that this device ISN’T the same as the JSN-SR04T which is documented in ESPHOME.

When reading the documentation, the modes for the AJ are slightly different. You can read all about this @ probots tutorials : How to Communicate Waterproof Ultrasonic Sensor AJ-SR04M/JSN-SR04T with Arduino/ESP32 – Probots Blog.

In the ESPHOME documentation they give 2 modes as an option. I succeeded in making mode 1 work with my Home Assistant. But instead using a 47K resistor (ESPHOME documentation), I used 120k resistor at R19 as documented by probots for the automatic mode.

I think the mode 2 option isn’t possible with the AJ-SR04M as the trigger signal will be sent as a 0x05 (ESPHOME documentation) while the sensor would expect a 0x01 signal before returning the distance.
This is a real bummer because this mode would allow reducing power consumption.
Therefore, support for this slightly different sensor would be great! :slight_smile:

I really wish documentation on ESPhome and thru retailers were better for this device.

I also bought this device thinking it was a JSN-SR04T. Is there any way to use it in “mode 1”?

Hi,

do you have the possibility to send me the exact yaml you are using for the sensor. I have soldered on a 120k resistor to put it into mode 1 but still can’t get it to work.

Thank you in advance!