Beginner: Create a Sensor in ESPhome

Hi all,

I’m not very good with this, so I need basic help :frowning: I am very happy I was able to upload a firmware to my ESP32 and feel like a hero already :wink:

I want to test this ultrasonic sensor that people are talking about here:

This is mainly a PoC and I don’t need anything reliable at the moment.

But the first question is how I can get this working at all. I have it all wired up, flashed the firmware on the ESP etc., but I don’t get any sensory input.

My config looks like this:

esphome:
  name: ultraschall
  friendly_name: ultraschall

esp32:
  board: esp32dev
  framework:
    type: arduino

sensor:
  - platform: ultrasonic
    trigger_pin: GPIO2 
    echo_pin: GPIO4
    name: "Ultrasonic Sensor"

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "el1a4m1ePshETDxxxxxxxA7NKo/wAXECnZZwJQ="

ota:
  - platform: esphome
    password: "1be87d0e2cxxxxxxx2b5e0b669b2"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Ultraschall Fallback Hotspot"
    password: "aoeiaoeiaoeiaoeiaoeiaoei"

captive_portal:

And the flashing worked, but then looked like this:

I tried drawing a Fritzing, but there is no esp32 board with my very ordinary pin out? I tried taking some photos:

Tried to get a better picture of the breadboard:

It does show in HA, but no status of the sensor:

Any idea what I might have done wrong? :frowning:

HI
I take it you have tried pointing the sensor at something within 2m rather than just having it pointing up at the ceiling.

Advanced options:

  • timeout (Optional, float): The number of meters for the timeout. Most sensors can only sense up to 2 meters. Defaults to 2 meters.

Your log says it’s a distance timeout.

1 Like

Your answer made my heart jump a bit as I thought that would have been a very stupid mistake, but I held my hand in front of it for two minutes and also put an object in front of it with no change:

Good. Now double check your wiring. Breadboards are prone to bad connections.

I moved every cable by one or two “boxes”.

Do you think I should wire it directly? I’m a bit nervous … I burnt the last ESP a week ago when I had a short circuit(?) :smiley:

It looks to me that you don’t actually have a connection going on the breadboard?

And yeah, try using female->female Dupont wires and make direct connection instead.


Yes those 4 wires aren’t connected to anything on the breadboard

I do have connections from the ESP to the breadboard, I highlighted them a bit:

oh no, it is not connected from left to right?!

haha, ok:

They need to be in the same row. Try putting the ones in row 4 up to row 2.

1 Like

Nice! Glad you got it working. Btw. You shouldn’t be scared of making a direct connection, just check it carefully before powering up.

1 Like

According to the pictures, you do not have connected wires on the non-soldering field

 trigger_pin: GPIO2
 echo_pin: GPIO4

with board esp

1 Like

I think that was already established several posts ago and the issue has been solved :wink:

1 Like