Shelly PLUS 1 + ESPHome (+ bletracker)


i recently ordered 2 Shelly PLUS 1 to try and get them to run a bletracker. So far i’ve succesfully flashed them with ESPHome and integrated them in HA. I’ve used this configuration, supplemented with a static IP (so not including the bletracker just yet). I wasn’t able to flash the device directly from HA, so i had to use ESPHome for windows, which worked very well!

After i got this working i tried adding the “esp32_ble_tracker:” syntax. The code compiled succesfully and the flashing OTA was succesfull as wel. However after rebooting the Shelly is no longer found by HA and seems to be crashing. However, i can still see the shelly in my Modem (even after refreshing it). Also OTA updates are no longer working, I have to flash the Shelly over a COM port with a confugation without the bletracker for it to fully work again.

I do have quite some experience with ESP’s and arduino, but am new to HA and ESPHome. So i do not immediately know where to look for a solution to this.
One thing i was suspecting is that the Shelly doesn’t get enough power. I’ve still got the Shelly powered by the ttl converter using a 1A power supply; that should be enough, right?
I’m hesitant to connect the Shelly to mains power, because it was a real pain to connect the VCC, GND, TX, RX wires to the connector on the Shelly, which is extremely small! I don’t want to do that again, if i can help it :slight_smile:

So to summarize: i got everything working fine, however adding the “esp32_ble_tracker:” seems to crash the Shelly. I would be very gratefull for anyone who could point me in the right direction for a solution. Or is what i’m trying to do here just not possible? I don’t see a reason why it wouldn’t be, but i’m happy to learn :wink:

Thank in advance.

This is extremely unlikely

The esp32_ble_tracker integration is well known to make troubles:

For the moment you could try this:

met67 commented on Oct 27
“Seems like the new esp-idf framework solves this issue… I managed do have BLE, Display and Wi-Fi at the same time (still too young to use in production, IMHO, but on the right path)
ESPHome 2021.10.0 - 20th October 2021 — ESPHome

Thank you very much for your reply. However, for now, i believe this is getting a little bit too complicated for my current skill-level.
I think i will put this on hold for now and mayby look into it at a later time. It’s probably better to tackle some more “beginner friendy” projects first.

I had a similar amount of pain getting esp32_ble_tracker working on a Shelly 1 Plus. Including the bonus idiot move of popping it in the wall then realising you had to UART flash when adding ble for the first time.

At the moment though, it’s working fine and picks up nearby BLE. The config that seems most stable for me is:

  board: esp32dev
    type: esp-idf
    version: latest
    active: false

Hello David,

thank you so much, that config works for me!
I still have to add any BLE devices to test it out, but at least the Shelly is no longer crashing and is showing up in HA again! I was also able to use OTA and get the serial connection OTA.

This is the kind of stuff, that i hard for a beginner to figure out, so i’m very gratefull for you sharing your experience.

Don’t feel bad, I’ve been using ESPHome for years and never would have guessed that solution.

Using the esp-idf framework instead of the (still) default arduino was also the “quick fix” mentioned in the github.

Anyway esphome will probably fully migrate to esp-idf in the future once the last dependency’s are migrated and then the esp32_ble_tracker will be much more stable/useable for all by default :rocket:

Could you please provide full config with switch and sensors?
I still getting boot loop.

Sure. I think I just used the config from

  - platform: gpio
      number: GPIO04
    name: Switch1
      - delayed_on_off: 50ms
  - platform: gpio
    id: shelly_relay_1
    name: Relay1
    pin: GPIO26
    icon: "mdi:electric-switch"
    restore_mode: RESTORE_DEFAULT_ON

  - platform: atc_mithermometer
    mac_address: "A4:C1:38:03:CA:0D"
      name: "Bedroom Temperature"

This is the config that ended up working for me (thanks to David for his help).
I still havn’t gotten around to actually adding any Xiaomi devices and didn’t run the Shelly on mains power yet, so that’s still something i will have to try.
Keep in mind that running from USB ports didn’t work for me either. The power just isn’t enough. Try a phone charger of at least 1A, 2A would be better.

  device_name: "Shelly 1 Plus 01"
  # Higher value gives lower watt readout
  current_res: "0.001"
  # Lower value gives lower voltage readout
  voltage_div: "1925"

  name: shelly_1_plus_01
    board_build.f_cpu: 160000000L

  board: esp32dev
    type: esp-idf
    version: latest

    active: false

  ssid: "xxxxxx"
  password: "xxxxx"
    static_ip: xxx
    gateway: xxx
    subnet: xxx



  password: "xxxx"

  - platform: gpio
    id: "relay_output"
    pin: GPIO26

  - platform: output
    id: "relay"
    name: "${device_name} Relay"
    output: "relay_output"

  - platform: gpio
    name: "${device_name} Switch"
    pin: GPIO4
        - switch.toggle: "relay"
      - delayed_on_off: 50ms
  - platform: gpio
    name: "${device_name} Button"
      number: GPIO25
      inverted: yes
        input: true
        pullup: true
        - switch.toggle: "relay"
      - delayed_on_off: 5ms

  - platform: ntc
    sensor: temp_resistance_reading
    name: "${device_name} Temperature"
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    icon: "mdi:thermometer"
      b_constant: 3350
      reference_resistance: 10kOhm
      reference_temperature: 298.15K
      - above: "80.0"
          - switch.turn_off: "relay"
  - platform: resistance
    id: temp_resistance_reading
    sensor: temp_analog_reading
    configuration: DOWNSTREAM
    resistor: 6kOhm
  - platform: adc
    id: temp_analog_reading
    pin: GPIO32
    attenuation: 11db

  - platform: adc
    name: "${device_name} Relay Supply Voltage"
    pin: GPIO33
    attenuation: 11db
      - multiply: 8

    number: GPIO0
    inverted: true

Thank you! Are you using 12VDC or 110-220VAC?
I’m trying to use 12VDC and it’s not booting

How much Ampere (or Power) can your 12VDC PSU deliver? Is it up for the task? Did you try another power source?

It is 1A 12VDC. I used it before with Shelly, no problems.
I connected now to 220VAC and it’s working.

Do you get same hight ping? Usually it’s 1-2ms for wifi devices(other shellies or esp32).

Hy @assembly

does OTA work for you?

I have a Shelly Plus 1 in which I copied your exact same configuration (only changes are my SSID and IP) and everything work as expected except for OTA, which does not work.

Every time I try to OTA any firmware, the Shelly reboots without installing the update.

Thank you!


yes OTA works for me. It worked with my old config from post #1 and also with my current config.

Could you please tell me what temperature is reported by your shelly with this config?
Mine is way way off (like 75 without any load).

I believe the beta constant is not correct, or the downstream resistor is not correct but there’s little chance to figure out the right values…

Are you sure it’s off? Maybe it’s on!

Did you calibrate the NTC?

I know it’s off because the thing plugged on it is off :slight_smile:
I didn’t calibrate the NTC, how would you do that accurately?
The beta value (b_constant) is supposed to define the curve the resistance of the NTC follows (which from my POV is wrong in the config proposed, I believe it’s somewhere between 3950 or 4000 instead of 3350)

How does it report temperature when it’s off? :stuck_out_tongue_winking_eye:

First thing I would do is to measure with another sensor to see how far the temperature is from reality. Maybe a IR Thermometer :gun: could be useful for this.

I also remember that some shellys tend to run (really) hot even without load :fire: