Why is this binary sensor causing the ESP to not connect?

I have the following:

  tx_pin: GPIO2
  rx_pin: GPIO4
  baud_rate: 9600

# Declare DFPlayer mini module
      logger.log: 'Somebody press play!'

  sda: GPIO1
  scl: GPIO3
  scan: true
  id: bus_a

  - platform: gpio
    pin: GPIO5
    id: sw
    name: "sw"
    internal: true
  - platform: gpio
    pin: GPIO13
    name: "TV on off"
  - platform: mpu6050
    address: 0x68
    update_interval: 2s
      name: "MPU6050 Accel X"
      id: "x"
      - above: 6
          - switch.turn_on: sw
      - below: 6
          - switch.turn_off: sw
      name: "MPU6050 Accel Y"
      id: "y"
      name: "MPU6050 Accel z"
      id: "z"
      name: "MPU6050 Gyro X"
      name: "MPU6050 Gyro Y"
      name: "MPU6050 Gyro z"
      name: "MPU6050 Temperature"
  - platform: ultrasonic
    trigger_pin: GPIO12
    echo_pin: GPIO14
    update_interval: 1s
    name: "Ultrasonic Sensor"
      - below: 1
          - if:
                switch.is_on: sw
                - dfplayer.play_next:

The binary sensor makes the ESP not connect to the network.
I have tried several GPIOs but it just refuses to work with the binary sensor.
If I remove or comment the binary sensor then it all works fine.
What is wrong with the binary sensor?

This is a node MCU 8266.

Maybe the id is missing?

Instead of naming the pin
pin: GPIO13

what about trying pin: D7

Only pin and name is required, but I could try it.

I think it didn’t like that before.
I believe that was what I tried first with this board, but then had to look at the pin out to get the GPIO names.
But I can try it.

This is what I get:


  name: rtttltest
  platform: ESP8266
  board: nodemcuv2

Have you definitly set the board as nodemcu?

Yes. It makes no difference.

Ok, I can use D7, but it still won’t connect with binary sensor in the code

I think it might be a spacing issue

  - platform: gpio
      number: GPIO13
    name: "TV on off"

edit, nah. I see both methods and spacings in the page you linked to. Inconsistent in the docs. Maybe it doesnt matter at all. Sorry.

When you boot the device with binary sensor what do you see on the logs. I think you are connecting by serial rather than by plugging usb cabel in. I take it that the device goes into boot mode rather than flash mode.

I flash it with the new flash tool using https and the “stay on this page to prevent slow down” thing.

But even if I do this as the first flash (without binary_sensor) then do a OTA it will still fail to boot.

Because it doesn’t connect to wifi then I can’t see the logs, only the “trying to reconnect in x seconds”.

Maybe I can try ESP-flasher later, but I don’t think it’s the flash that is the issue.
The flash seems fine.

This is really weird. the screenshot from above with the messages about D7 for the esp01_1m board. The ESP01 is totally different, it doesnt have pins above gpio3. Anything you have tried with that board in the code would fail.
But just below, you mention to Spiro the board as nodemcuv2 and that you have tried that. This one should be programmed in if your using node mcu 8266.

Did you make any progress yet?

No progress yet.
The coding has worked fine up to the binary sensor which ironically is the last thing I need to add to the device.
Everything else works great with esp01_1m or nodemcuv2, both work, except the binary sensor.

I was thinking that that perhaps the reason it wasn’t connecting to network was because it wasn’t even going into bootmode. I have seen this happen when something gets connected to GPIO0 and pulls it low at startup and it goes into flashmode. You would probably get some info from the logs if you were to connect by cable to nodemcu and use the esp-flasher in log mode.

Currently the device is completely unconnected.
Only the USB cable is connected.

ESP01 (1M version)


slight difference.

But what was your first flash? with esp01? or esp01_1m or nodemcu nodemcuv2 ?
If you did so with the first, just esp01, you could experience memory issues. It thinks there is 512kb of it. I needed to flash directly to fix this. But if this is so, it will probably not flash OTA in the first place. That will be visible in the logger.
Have you enabled logger?
Have you set your wifi stuff and fixed ip in the config?
static_ip: 192.168.4.xx

I see…

The new way of creating devices doesn’t give you the option to set the device.

So downloading as a binary and flashing with esp tool, could that work?
The messages say it deletes the flash so it should be a clean flash?

I’ll see what I can do.
I know there is a difference, in the old days you had the drop-down to select the board, now that is gone and I thought it didn’t matter.


Thats exactly how it should work :slight_smile:

If that is how it should work then why is there a online tool that is newly developed?

I might have missed that until. hahah… ill investigate

When you setup a new board it does give option to set the specific board type in esphome.