Shelly Plus Plug S - ESPHOME

Actually, using these I’ve got accurate readings now:

  - platform: hlw8012
    model: BL0937
    sel_pin:
      number: GPIO19
      inverted: true
    cf_pin: GPIO10
    cf1_pin: GPIO22
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    change_mode_every: 1
    update_interval: 5s
    current:
      id: current
      unit_of_measurement: A
      accuracy_decimals: 3
      internal: true
    voltage:
      id: voltage
      unit_of_measurement: V
      accuracy_decimals: 1
      internal: true
    power:
      name: "${channel_1} power"
      unit_of_measurement: W
      id: power
      icon: mdi:flash-outline
      on_value_range:
        - above: ${max_power}
          then:
            - switch.turn_off: relay
            - homeassistant.service:
                service: persistent_notification.create
                data:
                  title: Message from ${device_name}
                data_template:
                  message: Switch turned off because power exceeded ${max_power} W
substitutions:
  device_name: shelly-plus-plug-s-1
  friendly_name: shelly-plus-plug-s-1
  channel_1: Relay
  max_power: "1500" # 2000
  max_temp: "65.0" # 70.0
  # Higher value gives lower watt readout
  current_res: "0.001"
  # Lower value gives lower voltage readout
  voltage_div: "1830"

Now how would we go about and figure out how to control the LED ring? GPIO3 seems to react to a monochromatic light, but only fully on or off, and only at a certain percentage :confused:

1 Like

Im remove PCB from case without damage…
It for sure use ESP32-U4WDH and BL0937.
There is 4 LED’s. Im not sure if they are RGB or each have own color… Maybe they are driven by PWM …

Looks like U0TXD and U0RXD from chip is not exposed to any pins so reflashing my device looks like will not be possible…

Got it working here

 light:
      - platform: neopixelbus
        variant: 800KBPS
        method:
          type: esp32_rmt
          channel: 0
        pin: GPIO25
        num_leds: 2
        id: rgb_light1
  
      - platform: neopixelbus
        variant: 800KBPS
        method:
          type: esp32_rmt
          channel: 1
        pin: GPIO26
        num_leds: 2

But plug reboot from time to time. Don’t know why. Memory leak probably

1 Like

I’ve noticed that addressing the RGB leds too soon in the boot cycles causes the device to reboot or become unresponsive. It might be the same as your issue @mebrotus. Fortunately, flashing the device was still possible in those cases. I’ve added a safeguard around this and created a PR in the esphome devices repo. I’ve got two devices running this config as stable as can be.
Config for Shelly Plus Plug S by bobkersten · Pull Request #370 · esphome-devices/esphome-devices · GitHub

1 Like

hi all,
I would like to make my shelly plus plug s work additionally as a ble gateway (for esphome(dot)io/cookbook/ble_itag.html).
my first try failed while flashing with esp32_ble_tracker and ble_client modules - firmware was too big for one of two partitions left from shelly (2x almost 2MB), but was ok to flash something smaller.
then I found a way to re-partition flash to make one big app partition Safeboot Partition Layout - Tasmota and used esphome temporary “proof of concept” firmware with one Itag and … it became permanent. it worked, itag works, relay works, but thats it, I cant flash it any more wirelessly. it says “conneciton reset by peer”. even with the minimum firmware (ota and wifi module).

so I think as follows: if safeboot partition with tasmota-safeboot (tasmota32-safeboot.bin) still exists in flash, it would be enough to boot from it and flash whatever we need - like in api tasmota (HTTP API to switch to and from factory partition by s-hadinger · Pull Request #15506 · arendst/Tasmota · GitHub) - but I didn’t find anything similar over the internet for esphome.
what do you think, is that way possible at all?

or serial is my only way? shelly support didn’t provide me pinout (obviously) and I couldn’t find it as well by myself. from 18 pins would not be so easy to find rx tx etc
thank you

1 Like

For everyone who is interested on the PinOut Points. I successfully flashed ESPHome over TTL Serial.


@homeass1

5 Likes

I made a quick fix using pins to hit the points.

3 Likes

Thanks for this informations.
I will try reflash it using this pins :slight_smile:

having 2 of these just fine in the Shelly integration, I wonder why would you want to flash them in the first place?

1 Like

Because if I need to do some “advanced” functions Im more familiar with esphome coding(yaml) than Shelly scripts… Also If with Shelly FW I want in plug get some data from other HA sensor I need to use MQTT or some API calls to HA which is more complex than simple calling sensor from esphome code…
For simple on/off switching and reading power usage I think normal fw is ok… Also this is my view and maybe all thing can also be done with Shelly scripts…

Cool. Still new to Esphome myself, I try to learn from all of you, and understand the deeper options.

1 Like

@fanningert did you solder contacts on ESP board or are only pushed on them? Did you use hard wire to make contact or I see sewing needles? :slight_smile:

@fanningert thanks for pinout diagram. Today Im sucesfully reflash my Shelly Plus Plug S.

@DejanBukovec yes i used sewing needles and they are only pushed on the contacts. :slight_smile: It was a quick and dirty construction. I am currently creating a pcb for easy flashing. But this need some time.

1 Like

I opened a pull request to change the platform to esp-idf.
since we do have the “ESP32 RMT LED Strip” platform with esphome 2023.5, it is possible to address the LEDs when using the esp-idf framework.
With this it is possible to use the plug as a bluetooth proxy too, because of the much smaller footprint.

If you want to get inspiration until the pr is merged, you can take a look at my proposed changes:

Hi,
many thankes for the PinOut Points.
My Shells Plus Plug S ist defekt after 10 Days. There is nothing of reaktion at the device.
No reset ist possible, also is no power betwen GND and 3,3Volt.
Is there any to find out, ore some poit to check?

How did you open the plug?
Mine has no screws like the older models…

My have them inside contact holes…

It is one screw, and it is placed in the hole for “ground”. You’ll need a narrow and long screwdriver for it.

I’ll be trying the pinout flash soon, cause my new ESPHome firmware gets uploaded but the plug is not booting with the new firmware version 🥲

Hmm… this solution did not work for me.
First I tried to migrate via the software way. Migrated from Shelly Software to tasmota is easy. But I was not able to migrate from tasmota to ESPHome. Tried it the hole day along.
So I decided to open this thing and but the needles on it. I flashed with esptools on a raspberry. (tig's Blog)

The software said that the bin file is copied correct. But the plug is dead. I tried a second one. Also dead.

**daniel@raspberrypi**:**~ $** esptool.py --port /dev/ttyS0 write_flash 0x0000 ~/shelly-plus-plug-s-3.bin
esptool.py v4.6.2
Serial port /dev/ttyS0
Connecting...
Failed to get PID of a device on /dev/ttyS0, using standard reset sequence.
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Failed to get PID of a device on /dev/ttyS0, using standard reset sequence.
Detecting chip type... ESP32
Chip is ESP32-U4WDH (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: b0:b2:1c:0f:9a:80
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x000d9fff...
Compressed 892336 bytes to 589471...
Wrote 892336 bytes (589471 compressed) at 0x00000000 in 53.5 seconds (effective 133.5 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
**daniel@raspberrypi**:**~ $**

No reaction if I put 3,3 Volt and Ground directly on the pins. No reaction if I put in the wall outlet.
Oh no, I killed my two plugs. :frowning:

Any ideas? Maybe it is better to buy the ATHOM plugs with pre flashed ESPHome?