I’ve flashed a Shelly EM Gen3 with ESPHome and added BTHome as per user @badrpc. That works great.
I’ve also created switches for the dry contact relay and the status LED as per the pinout described here. However, you will see that the IRQ pin is not known.
Everything is working great except the ADE7953, which is what is needed in order to get energy readings from the device (the most important part!). I have tried every pin as the IRQ to no avail. I have also tried changing the I2C bus to GPIO18/19 and assigning the IRQ to GPIO6 and then 7, to no avail.
I tried assigning SPI to GPIO18/19/20 and then using pins 4/5, and then 6/7, to try the SPI version of ADE7953 as described in the ESPHome docs. Both attempts gave me readings for the first time, but they were just maxed out static numbers (like 191,000 volts or something like that) so that didn’t work either.
Does anyone have any ideas as to how I can get this energy meter to work with ESPHome? Here’s my config.
esphome:
name: shelly-em-gen3
friendly_name: Shelly EM Gen3
esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
- platform: esphome
password: "not_important"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Shelly-Em-Gen3 Fallback Hotspot"
password: "not_important"
captive_portal:
#GPIO 0 is Built-In Relay
#GPIO 1 is Built-In Button
#GPIO 2 does not work as IRQ
#GPIO 3 is ADC for NTC temperature
#GPIO 4 does not work as IRQ
#GPIO 5 does not work as IRQ
#GPIO 6 is I2C SDA; does not work as IRQ
#GPIO 7 is I2C SCL; does not work as IRQ
#GPIO 8 is a strapping pin; does not work as IRQ
#GPIO 9 is Status LED
#GPIO 10 does not work as IRQ
#GPIO 11 does not work as IRQ
#GPIO 12 is reserved for SPI (SPIHD) when I tried flashing
#GPIO 13 is reserved for SPI (SPIWP) when I tried flashing
#GPIO 14 is reserved for SPI (SPICS0) when I tried flashing
#GPIO 15 is reserved for SPI (CLK) when I tried flashing
#GPIO 16 is reserved for SPI (SPID) when I tried flashing
#GPIO 17 is reserved for SPI (SPIQ) when I tried flashing
#GPIO 18 does not work as IRQ
#GPIO 19 does not work as IRQ
#GPIO 20 does not work as IRQ
#GPIO 21 does not work as IRQ
external_components:
- source:
type: git
url: https://github.com/badrpc/esphome
ref: v0
components: [ bthome ]
esp32_ble_tracker:
bthome:
- id: blu_door_window
mac_address: XX:XX:XX:XX:XX:XX # MAC-address of BLU sensor
encryption_key: "not_important" # 128-bit key
i2c:
sda: GPIO6
scl: GPIO7
binary_sensor:
- platform: bthome
id: blu_door_window
window:
id: test_blu_window
name: "Test blu window"
- platform: status
name: "Shelly EM Gen3 Status"
sensor:
- platform: bthome
id: blu_door_window
angle:
id: test_blu_angle
name: "Test blu angle"
battery_level:
id: test_blu_battery_level
name: "Test blu battery level"
entity_category: "diagnostic"
illuminance:
id: test_blu_illuminance
name: "Test blu illuminance"
- platform: ade7953_i2c
irq_pin: GPIO1
voltage:
name: ADE7953 Voltage
frequency:
name: ADE7953 Frequency
current_a:
name: ADE7953 Current A
current_b:
name: ADE7953 Current B
power_factor_a:
name: "ADE7953 Power Factor A"
power_factor_b:
name: "ADE7953 Power Factor B"
apparent_power_a:
name: "ADE7953 Apparent Power A"
apparent_power_b:
name: "ADE7953 Apparent Power B"
active_power_a:
name: ADE7953 Active Power A
active_power_b:
name: ADE7953 Active Power B
reactive_power_a:
name: "ADE7953 Reactive Power A"
reactive_power_b:
name: "ADE7953 Reactive Power B"
# NTC Temperature
- platform: ntc
sensor: temp_resistance_reading
name: "Shelly Temperature"
calibration:
b_constant: 3350
reference_resistance: 10kOhm
reference_temperature: 298.15K
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
configuration: DOWNSTREAM
resistor: 32kOhm
- platform: adc
id: temp_analog_reading
pin: GPIO3
switch:
- platform: gpio
name: "Relay"
id: relay
pin:
number: 0
inverted: false
- platform: gpio
name: "Status LED"
id: status_led
pin:
number: 9
inverted: true
restore_mode: ALWAYS_ON
time:
- platform: sntp
id: sntp_time
timezone: America/Los_Angeles
servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
button:
- platform: restart
icon: mdi:power-cycle
name: "ESP Reboot"