Power use of your ESP32 + ESPHome + PZEM-004T, free over MQTT

See how much each appliance uses from your phone and find out if a fridge or freezer stopped working. Free on EzGYM.

The ESP32 + ESPHome + PZEM-004T measures power use and publishes it over MQTT. EzGYM gives you the server (broker) for free, with a username and password for each device: no Raspberry Pi to maintain and no cloud to pay for.

Every reading is kept for 90 days and shown in a chart from 6 hours to 30 days. You set a minimum and a maximum in watts: for example, if a freezer uses less than 20 W for more than 30 minutes, the power or its breaker is off, and we email you.

It works for cold rooms, display fridges, pumps or the whole shop, and shows next to the temperature sensors.

How to set it up

  1. 1 Create your free EzGYM account, go to Sensors and add a “Power use (W)” sensor.
  2. 2 Write down the server, username, password and topic the app gives you.
  3. 3 Wire the PZEM-004T v3 to the ESP32 (meter TX to GPIO16, RX to GPIO17, plus 5 V and GND) and add the block below with your data to the ESPHome YAML. The sensor must be named “consumo”.
  4. 4 Install the firmware on the ESP32 from ESPHome.
  5. 5 In a few minutes you see the power use in EzGYM.
uart:
  rx_pin: GPIO16
  tx_pin: GPIO17
  baud_rate: 9600

modbus:

sensor:
  - platform: pzemac
    power:
      name: consumo
    update_interval: 60s

mqtt:
  broker: devices.ezdis.net
  port: 1883
  username: sn4k2p9x7q1m
  password: TheSensorPassword
  topic_prefix: s/sn4k2p9x7q1m
  discovery: false

In this example, sn4k2p9x7q1m is the sensor username and s/sn4k2p9x7q1m its topic: replace them, and the password, with the ones the app gave you when you added the sensor. They are not your app login.

Frequently asked questions

Which username and password do I enter in the ESP32 + ESPHome + PZEM-004T?

The sensor ones, not your account ones: when you add the power sensor in Sensors, EzGYM shows its username (it starts with “sn”) and its password. The password is shown only once; if you lost it, tap New password in the sensor page.

How often is power sent?

Shelly devices send every change in power; Tasmota and ESPHome send once a minute with the setup in this guide. We keep the average, minimum and maximum of each minute.

Can it measure the whole shop?

Yes, with a meter in the electrical panel: the Shelly Pro 3EM for three-phase (it adds up the three phases) or a PZEM-004T for single-phase.

How much does it cost?

Nothing: the broker, the charts and the email alerts are free, up to 30 sensors per account.

More guides

Create a free account