D1 Mini (ESP8266) + JSN-SR04 Not Working

Hoping to pick everyone’s brains. Spent about 10 hours on trying to get this to work.

Wired straight out of D1 Mini into the JSN-SR04 send board and not getting any reliable measurement, returning nan. This was puzzling so I created an arduino sketch in platformio with NewPing and it worked correctly. Then installed Tasmota and it works correctly, so I’m presuming there is a problem with ESPHome and some peculiarity with this module.

Changed D1 Mini module with same result. Changed ultrasounic modules with same result.

Works as expected with HC-SR04 non waterproof sensor.

esphome:
  name: rain-sono-sleep
  friendly_name: rain_sono_sleep
esp8266:  
  board: d1_mini

web_server:
  port: 80

logger:

ota:
  password: ""
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "rain_sono_sleep Fallback Hotspot"
    password: ""
  manual_ip:
        # Set this to the IP of the ESP
    static_ip: 10.10.10.181
        # Set this to the IP address of the router. Often ends with .1
    gateway: 10.10.10.1
        # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0

captive_portal:

switch:
  - platform: restart
    name: "rain sono sleep reboot"

sensor:
  - platform: uptime
    name: rainsonosleep_uptime
    filters:
      - lambda: return x / 3600;
    unit_of_measurement: "h"

  - platform: ultrasonic
    name: rainsonosleep_distance
    id: rainsonosleep_distance
    # internal: true
    trigger_pin: D1
    echo_pin: D2
    update_interval: 1s
    timeout: 2m
    filters: 
    - lambda: if (isnan(x)) {  return 0.0; } return x;  
   
api:

# deep_sleep:
#   run_duration: 30s
#   sleep_duration: 10s

esphome node returns

16:37:57][D][ultrasonic.sensor:036]: 'rainsonosleep_distance' - Distance measurement timed out!
[16:37:57][D][sensor:093]: 'rainsonosleep_distance': Sending state 0.00000 m with 2 decimals of accuracy
[16:37:59][D][ultrasonic.sensor:036]: 'rainsonosleep_distance' - Distance measurement timed out!
[16:37:59][D][sensor:093]: 'rainsonosleep_distance': Sending state 0.00000 m with 2 decimals of accuracy
[16:38:01][D][ultrasonic.sensor:036]: 'rainsonosleep_distance' - Distance measurement timed out!
[16:38:01][D][sensor:093]: 'rainsonosleep_distance': Sending state 0.00000 m with 2 decimals of accuracy

Log Download

INFO ESPHome 2024.5.0
INFO Reading configuration /config/rain-sono-sleep.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing rain-sono-sleep (board: d1_mini; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Platform Manager: Installing platformio/espressif8266 @ 4.2.1
INFO Installing platformio/espressif8266 @ 4.2.1
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Platform Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Tool Manager: Installing platformio/framework-arduinoespressif8266 @ ~3.30102.0
INFO Installing platformio/framework-arduinoespressif8266 @ ~3.30102.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%          
Tool Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40700.0
INFO Installing platformio/tool-scons @ ~4.40700.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Tool Manager: Removing tool-scons @ 4.40502.0
INFO Removing tool-scons @ 4.40502.0
Tool Manager: [email protected] has been removed!
INFO [email protected] has been removed!
Removing unused dependencies...
Library Manager: Removing ESPAsyncWebServer-esphome @ 3.1.0
INFO Removing ESPAsyncWebServer-esphome @ 3.1.0
Library Manager: Removing dependencies...
INFO Removing dependencies...
Library Manager: Removing ESPAsyncTCP-esphome @ 1.2.3
INFO Removing ESPAsyncTCP-esphome @ 1.2.3
Library Manager: [email protected] has been removed!
INFO [email protected] has been removed!
Library Manager: [email protected] has been removed!
INFO [email protected] has been removed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.2.0
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.2.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/list_entities.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/captive_portal/captive_portal.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/esp8266/core.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/esp8266/gpio.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/esp8266/preferences.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/json/json_util.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/logger/logger.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/logger/logger_esp32.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/logger/logger_esp8266.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/logger/logger_host.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/logger/logger_libretiny.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/logger/logger_rp2040.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/md5/md5.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/mdns/mdns_component.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/mdns/mdns_esp32.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/mdns/mdns_host.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/mdns/mdns_libretiny.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/mdns/mdns_rp2040.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/network/util.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/ota/ota_backend_arduino_libretiny.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/ota/ota_backend_arduino_rp2040.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/ota/ota_component.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/restart/switch/restart_switch.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/sensor/automation.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/sensor/filter.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/sensor/sensor.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/socket/lwip_sockets_impl.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/socket/socket.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/switch/automation.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/switch/switch.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/ultrasonic/ultrasonic_sensor.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/uptime/uptime_sensor.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/web_server/list_entities.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/web_server/web_server.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/web_server_base/web_server_base.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/wifi/wifi_component.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/wifi/wifi_component_esp32_arduino.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/wifi/wifi_component_esp8266.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/wifi/wifi_component_esp_idf.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/wifi/wifi_component_libretiny.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/components/wifi/wifi_component_pico_w.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/application.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/color.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/component.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/component_iterator.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/controller.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/entity_base.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/helpers.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/log.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/ring_buffer.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/scheduler.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/string_ref.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/time.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/esphome/core/util.cpp.o
Compiling .pioenvs/rain-sono-sleep/src/main.cpp.o
Generating LD script .pioenvs/rain-sono-sleep/ld/local.eagle.app.v6.common.ld
Compiling .pioenvs/rain-sono-sleep/libd58/ESPAsyncTCP-esphome/AsyncPrinter.cpp.o
Compiling .pioenvs/rain-sono-sleep/libd58/ESPAsyncTCP-esphome/ESPAsyncTCP.cpp.o
Compiling .pioenvs/rain-sono-sleep/libd58/ESPAsyncTCP-esphome/ESPAsyncTCPbuffer.cpp.o
Compiling .pioenvs/rain-sono-sleep/libd58/ESPAsyncTCP-esphome/SyncClient.cpp.o
Compiling .pioenvs/rain-sono-sleep/libd58/ESPAsyncTCP-esphome/tcp_axtls.c.o
Compiling .pioenvs/rain-sono-sleep/lib181/Hash/Hash.cpp.o
Archiving .pioenvs/rain-sono-sleep/libd58/libESPAsyncTCP-esphome.a
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/BearSSLHelpers.cpp.o
Archiving .pioenvs/rain-sono-sleep/lib181/libHash.a
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/CertStoreBearSSL.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/ESP8266WiFi.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/ESP8266WiFiAP.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/ESP8266WiFiGeneric.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/ESP8266WiFiGratuitous.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/ESP8266WiFiMulti.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/ESP8266WiFiSTA-WPS.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/ESP8266WiFiSTA.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/ESP8266WiFiScan.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/WiFiClient.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/WiFiClientSecureBearSSL.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/WiFiServer.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/WiFiServerSecureBearSSL.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/WiFiUdp.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb1/ESP8266WiFi/enable_wifi_at_boot_time.cpp.o
Compiling .pioenvs/rain-sono-sleep/lib9aa/ESPAsyncWebServer-esphome/AsyncEventSource.cpp.o
Archiving .pioenvs/rain-sono-sleep/libfb1/libESP8266WiFi.a
Compiling .pioenvs/rain-sono-sleep/lib9aa/ESPAsyncWebServer-esphome/AsyncWebSocket.cpp.o
Compiling .pioenvs/rain-sono-sleep/lib9aa/ESPAsyncWebServer-esphome/WebAuthentication.cpp.o
Compiling .pioenvs/rain-sono-sleep/lib9aa/ESPAsyncWebServer-esphome/WebHandlers.cpp.o
Compiling .pioenvs/rain-sono-sleep/lib9aa/ESPAsyncWebServer-esphome/WebRequest.cpp.o
Compiling .pioenvs/rain-sono-sleep/lib9aa/ESPAsyncWebServer-esphome/WebResponses.cpp.o
Compiling .pioenvs/rain-sono-sleep/lib9aa/ESPAsyncWebServer-esphome/WebServer.cpp.o
Compiling .pioenvs/rain-sono-sleep/lib070/DNSServer/DNSServer.cpp.o
Archiving .pioenvs/rain-sono-sleep/lib9aa/libESPAsyncWebServer-esphome.a
Compiling .pioenvs/rain-sono-sleep/libfb2/ESP8266mDNS/ESP8266mDNS.cpp.o
Archiving .pioenvs/rain-sono-sleep/lib070/libDNSServer.a
Compiling .pioenvs/rain-sono-sleep/libfb2/ESP8266mDNS/LEAmDNS.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb2/ESP8266mDNS/LEAmDNS_Control.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb2/ESP8266mDNS/LEAmDNS_Helpers.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb2/ESP8266mDNS/LEAmDNS_Structs.cpp.o
Compiling .pioenvs/rain-sono-sleep/libfb2/ESP8266mDNS/LEAmDNS_Transfer.cpp.o
Archiving .pioenvs/rain-sono-sleep/libFrameworkArduinoVariant.a
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Crypto.cpp.o
Archiving .pioenvs/rain-sono-sleep/libfb2/libESP8266mDNS.a
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Esp-frag.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Esp-version.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Esp.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/FS.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/FSnoop.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/FunctionalInterrupt.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/IPAddress.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/LwipDhcpServer-NonOS.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/LwipDhcpServer.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/LwipIntf.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/LwipIntfCB.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/MD5Builder.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Print.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Schedule.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/StackThunk.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Stream.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/StreamSend.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Tone.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/TypeConversion.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/Updater.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/WMath.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/WString.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/abi.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/aes_unwrap.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/base64.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/cbuf.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/cont.S.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/cont_util.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_app_entry_noextra4k.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_eboot_command.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_features.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_flash_quirks.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_flash_utils.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_i2s.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_main.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_non32xfer.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_noniso.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_phy.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_postmortem.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_si2c.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_sigma_delta.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_spi_utils.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_timer.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_vm.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_waveform_phase.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_waveform_pwm.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_wiring.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_wiring_analog.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_wiring_digital.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_wiring_pulse.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_wiring_pwm.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/core_esp8266_wiring_shift.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/crc32.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/debug.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/exc-c-wrapper-handler.S.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/exc-sethandler.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/flash_hal.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/gdb_hooks.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/heap.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/hwdt_app_entry.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/libb64/cdecode.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/libb64/cencode.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/libc_replacements.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/mmu_iram.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/reboot_uart_dwnld.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/spiffs/spiffs_cache.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/spiffs/spiffs_check.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/spiffs/spiffs_gc.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/spiffs/spiffs_hydrogen.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/spiffs/spiffs_nucleus.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/spiffs_api.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/sqrt32.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/stdlib_noniso.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/time.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/uart.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/umm_malloc/umm_info.c.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/umm_malloc/umm_integrity.c.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/umm_malloc/umm_local.c.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/umm_malloc/umm_malloc.cpp.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/umm_malloc/umm_poison.c.o
Compiling .pioenvs/rain-sono-sleep/FrameworkArduino/wpa2_eap_patch.cpp.o
Archiving .pioenvs/rain-sono-sleep/libFrameworkArduino.a
Linking .pioenvs/rain-sono-sleep/firmware.elf
RAM:   [====      ]  42.7% (used 34992 bytes from 81920 bytes)
Flash: [====      ]  42.1% (used 439921 bytes from 1044464 bytes)
Building .pioenvs/rain-sono-sleep/firmware.bin
esp8266_copy_factory_bin([".pioenvs/rain-sono-sleep/firmware.bin"], [".pioenvs/rain-sono-sleep/firmware.elf"])
========================= [SUCCESS] Took 80.01 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 10.10.10.181
INFO Uploading /config/.esphome/build/rain-sono-sleep/.pioenvs/rain-sono-sleep/firmware.bin (444080 bytes)
INFO Compressed to 308252 bytes
Uploading: [============================================================] 100% Done...

INFO Upload took 3.38 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 10.10.10.181 using esphome API
INFO Successfully connected to rain-sono-sleep @ 10.10.10.181 in 15.418s
INFO Successful handshake with rain-sono-sleep @ 10.10.10.181 in 0.063s
[16:50:59][I][app:100]: ESPHome version 2024.5.0 compiled on May 18 2024, 16:50:04
[16:50:59][C][wifi:580]: WiFi:
[16:50:59][C][wifi:408]:   Local MAC: 48:3F:DA:50:4F:82
[16:50:59][C][wifi:413]:   SSID: 'shmoo3'[redacted]
[16:50:59][C][wifi:416]:   IP Address: 10.10.10.181
[16:50:59][C][wifi:419]:   BSSID: AC:9E:17:A1:21:B9[redacted]
[16:50:59][C][wifi:421]:   Hostname: 'rain-sono-sleep'
[16:50:59][C][wifi:423]:   Signal strength: -55 dB ▂▄▆█
[16:50:59][C][wifi:427]:   Channel: 5
[16:50:59][C][wifi:428]:   Subnet: 255.255.255.0
[16:50:59][C][wifi:429]:   Gateway: 10.10.10.1
[16:50:59][C][wifi:430]:   DNS1: 0.0.0.0
[16:50:59][C][wifi:431]:   DNS2: 0.0.0.0
[16:50:59][C][logger:185]: Logger:
[16:50:59][C][logger:186]:   Level: DEBUG
[16:50:59][C][logger:188]:   Log Baud Rate: 115200
[16:50:59][C][logger:189]:   Hardware UART: UART0
[16:50:59][C][uptime.sensor:031]: Uptime Sensor 'rainsonosleep_uptime'
[16:50:59][C][uptime.sensor:031]:   Device Class: 'duration'
[16:50:59][C][uptime.sensor:031]:   State Class: 'total_increasing'
[16:51:00][C][uptime.sensor:031]:   Unit of Measurement: 'h'
[16:51:00][C][uptime.sensor:031]:   Accuracy Decimals: 0
[16:51:00][C][uptime.sensor:031]:   Icon: 'mdi:timer-outline'
[16:51:00][C][restart:068]: Restart Switch 'rain sono sleep reboot'
[16:51:00][C][restart:070]:   Icon: 'mdi:restart'
[16:51:00][C][restart:090]:   Restore Mode: always OFF
[16:51:00][C][ultrasonic.sensor:045]: Ultrasonic Sensor 'rainsonosleep_distance'
[16:51:00][C][ultrasonic.sensor:045]:   State Class: 'measurement'
[16:51:00][C][ultrasonic.sensor:045]:   Unit of Measurement: 'm'
[16:51:00][C][ultrasonic.sensor:045]:   Accuracy Decimals: 2
[16:51:00][C][ultrasonic.sensor:045]:   Icon: 'mdi:arrow-expand-vertical'
[16:51:00][C][ultrasonic.sensor:046]:   Echo Pin: GPIO4
[16:51:00][C][ultrasonic.sensor:047]:   Trigger Pin: GPIO5
[16:51:00][C][ultrasonic.sensor:048]:   Pulse time: 10 µs
[16:51:00][C][ultrasonic.sensor:049]:   Timeout: 11661 µs
[16:51:00][C][ultrasonic.sensor:050]:   Update Interval: 2.0s
[16:51:00][C][captive_portal:088]: Captive Portal:
[16:51:00][C][web_server:173]: Web Server:
[16:51:00][C][web_server:174]:   Address: 10.10.10.181:80
[16:51:00][C][mdns:115]: mDNS:
[16:51:00][C][mdns:116]:   Hostname: rain-sono-sleep
[16:51:00][C][ota:096]: Over-The-Air Updates:
[16:51:00][C][ota:097]:   Address: 10.10.10.181:8266
[16:51:00][C][ota:103]:   OTA version: 2.
[16:51:00][C][api:139]: API Server:
[16:51:00][C][api:140]:   Address: 10.10.10.181:6053
[16:51:00][C][api:144]:   Using noise encryption: NO
[16:51:01][D][ultrasonic.sensor:036]: 'rainsonosleep_distance' - Distance measurement timed out!
[16:51:01][D][sensor:093]: 'rainsonosleep_distance': Sending state 0.00000 m with 2 decimals of accuracy
[16:51:03][D][ultrasonic.sensor:036]: 'rainsonosleep_distance' - Distance measurement timed out!
[16:51:03][D][sensor:093]: 'rainsonosleep_distance': Sending state 0.00000 m with 2 decimals of accuracy
[16:51:05][D][ultrasonic.sensor:036]: 'rainsonosleep_distance' - Distance measurement timed out!
[16:51:05][D][sensor:093]: 'rainsonosleep_distance': Sending state 0.00000 m with 2 decimals of accuracy

No logs, no issue.

There are some issues with esphome 2024.5 (and d1 mini)
See:

I would not use aliases, just gpio.
You could also try to raise update_interval and remove timeout line

1 Like

Thank you for the suggestions.

  • I get the same result with using GPIO #s.
  • No change with timeout removed
  • ESPHome rolled back to docker image Package esphome · GitHub with same result.

Looking at the codebase, it looks like it just pings once. Theoretically, it should work regardless, but perhaps this module doesn’t register a single ping.

You did well trying with arduino sketch. At least you can be sure that your wiring and boards are ok. If you are skilled, maybe you could skip ultrasonic component and use that arduino code instead.

Can try to switch module to UART mode and use following component:

Recently have tried another clone of this module: AJ-SR04M.
It also return nothing in trigger/echo mode, but works fine in UART mode.

For my curiosity, what kind of accuracy you find with that?

That was where I was going next with a big old lambda. I am using AliExpress knock off boards AJ-SR04M and am not sure I can put them in uart mode as they don’t have jumpers.

I’ll try uart method. I didn’t think it is the esphome version. When I walked the version back, the component wouldn’t compile.

I’ll report back. Tasmota is rock solid so I’m not likely to spend a ton of time futzing with Esphome YAMLambda hell.

This does look promising for mode selection and the power consumption if true is really appealing

I got it working using the link to this site .

It needs a longer pulse time than usual sensors. I did this in Ping-Echo low power mode with 300 ohm resistor across 19.

  - platform: ultrasonic
    name: rainsonosleep_distance
    id: rainsonosleep_distance
    # internal: true
    trigger_pin: D1
    echo_pin: D2
    update_interval: .5s
    pulse_time: 10ms
    timeout: 2m
    filters: 
    - lambda: if (isnan(x)) {  return 0.0; } return x;