splitbrain.org

electronic brain surgery since 2001

Liberating the Sonoff Power Elite

My DIY Wall Box has worked great for the last couple of years until recently. For some reason the charging stopped despite the car's battery being far from full. Turning off the power and turning it back on fixed the problem for a bit until charging stopped again.

At first I suspected the KIA charger to be faulty. But when connecting it directly to the extension cord it worked just fine. And since there's nothing else in between, somehow the eMylo WiFi power meter must be at fault, even though I don't know how and why.

Anyway I decided to replace it. I wasn't really happy with it anyway. It's a Tuya device and integrating it into home assistant was a bit painful. With the official integration, you don't get access to the current power draw, despite the info being available in the App. LocalTuya worked okayish but was a pain to set up.

So for the new power meter I wanted something that would be more open. I came across the Sonoff Power Elite POW316D. It's powered by a ESP32 so flashing an open firmware should be easy, right?

I came across this article by BangerTech. They recommended a FT232RL FTDI USB-to-Serial Adapter for flashing. So I ordered it and the POWR316D and got started.

Opening the device is easy. It's just 4 little screws. For connecting the USB-to-Serial adapter I soldered four header pins to the board - when doing it a bit unconventional you can manage that without even removing the board from the housing.

However from there on nothing really worked. esptool just never got any serial connection. Only after several days, I found an important sentence in the Tasmota documentation:

Note that TX from your adapter goes to RX on the ESP device and RX from adapter goes to TX on the device!

Makes total sense, but just hadn't really occurred to me. Once connected correctly, the FT232 worked. Sometimes. I had interruptions and connection problems again and again. Reading the Tasmota docs, this seems to be a problem with a too low Amperage on the 3.3V delivered by the adapter. So better get one of their recommended devices.

Anyway. With the connection issues somewhat solved, I began trying to flash Tasmota. Since I had started with esptool to test the connection and backup the original firmware, and the linked esphome-flasher being archived, I also wanted to flash the firmware using esptool. This seemed to work at first, at least I got no errors. But the device never booted.

Note: in theory the device should boot and run off the 3.3v provided by the serial adapter. But with the low amps this does not work. So to test, disconnect the Adapter, close the device, then connect mains voltage. Never have mains connected when tinkering with the serial port!

It is a bit hard to know if it booted, because when the firmware is flashed nothing will show on the screen and no LEDs will work. Instead you should be on the lookout for a Tasmota WiFi access point becoming available.

So despite having flashed Tasmota (according to esptool output) it didn't work. I then somewhere read that ESP32s are weird and need some special treatment and that the easiest and safest way to flash them is the web installer.

And really, low and behold. Simply going to https://tasmota.github.io/install/, picking their defaults (Tasmota (english), All, Allow erase device) worked perfectly.

A note on flashing: to get the device into flash mode do this:

  • connect the USB to Serial Adapter
  • press and hold the button
  • start the flashing
  • release the button when the connection has been made

This might not be the exact needed procedure but it worked for me.

So with the web flasher I got Tasmota installed. Then I connected to the access point (which opens a captive portal), configured my network, waited for the reboot, got the IP from my router and connected to that again.

Next you can simply pick the POWR316D from the list of preconfigured devices under Auto Configuration. Once done, the display comes alive again and you can use the device with Tasmota.

I could have stopped here and use MQTT to integrate it into Home Assistant. But what I really wanted was to use ESPHome instead of Tasmota.

Why did I even mess with Tasmota in the first place? Mostly because it seemed to be better documented and I had converted Tasmota installs to ESPHome before, so I thought that to be the easiest way.

I set up the ESPHome configuration using the official example configuration1) and build the firmware (manual, modern).

However using that firmware in the Tasmota Firmware Upgrade dialog resulted in a “Invalid file signature”. Then I read, that for modern Tasmota you're supposed to gzip the firmware file. Easy done. Unfortunately that only resulted in a “not enough space on device” error. The recommendation to remedy that is to flash Tasmota-minima via OTA Upgrade. That didn't make any difference for me.

In the end, I reconnected the USB-to-Serial adapter and flashed ESPHome using their Web Installer. I should have done that in the first place without messing with Tasmota at all.

ESPHome on POWR316D

I finally had the power meter running and delivering data to Home Assistant. That's when I noticed that this device has no concept of a “Total Energy Ever” meter. Whenever mains is lost, the counter resets to zero! Gah…

As a remedy I created a “Utility Meter” helper in Home Assistant. I also added the Daily Energy sensor to the Energy Dashboard. This should be good enough to track the monthly energy going into the car.

HA Utility Meter Helper

I was finally able to install the thing into my wall box. Even though the POWR316D is addvertised as DIN-Rail mountable it is clearly not designed for (German) standard fuse boxes. The DIN rail clip is flimsy the device does not fit into the standard fuse box slots, the button is not reachable behind the cover… This is a mess. But at least it works for now.

Ugly Duckling on a DIN Rail

This took all way to long, but at least I learned a few things about flashing Tasmota and ESPHome…

Would I buy the POW316D again? Probably not. I would look into power meters without any WiFi but some kind of export mechanism like S0-Bus instead. Then connect my own ESP to read the values over that bus.

Tags:
esphome, tasmota, sonoff, electronics, home-assistant
Similar posts:
1)
You may want to fix this one display bug