Balcony solar monitor with PZEM (ESPHome)

Reads power, voltage, frequency and energy of a plug-in solar kit and calculates the daily yield in Home Assistant.

Level: Intermediate Board: ESP32 DevKit V1 (WROOM-32) Power & blackouts

⚠ Safety

Mains voltage can kill. Use certified isolated modules in an enclosure, fuse and RCD the circuit, switch the power off before wiring, and ask a qualified electrician if you are unsure. Check the rules for your country.

What you need

Buy the parts kit · Estimated total: $22.50

ESP32 DevKit V1 (30 pin, WROOM-32) × 1
$4.00
Buy at AliExpress Buy at Amazon.com
PZEM-004T v3.0 (100A, coil) × 1
$9.00
Buy at AliExpress Buy at Amazon.com
Inline fuse holder + fuses × 1
$1.50
Buy at AliExpress Buy at Amazon.com
Plastic project enclosure × 1
$3.00
Buy at AliExpress Buy at Amazon.com
Lever connectors (WAGO type) 2/3-pin × 2
$5.00
Buy at AliExpress Buy at Amazon.com
🇺🇦 Ukraine🌍 Other countries

Other countries: order these parts on AliExpress with the links below.

Some links are affiliate links: we may earn a commission at no extra cost to you.

Wiring

ModuleModule pinESP32 pinNote
PZEM-004T TX / RXUARTGPIO16 (RX) / GPIO17 (TX)the PZEM board is optically isolated; 5V from the PZEM supply side only to the opto
PZEM-004T AC inL / Non the AC side of the micro-inverter plugin an enclosure, qualified person
Current coilaround Lone live wire only

Code

balcony-solar.yaml
esphome:
  name: balcony-solar

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
api:
  encryption:
    key: !secret api_key
ota:
  - platform: esphome
    password: !secret ota_password
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

time:
  - platform: homeassistant
    id: ha_time

uart:
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 9600

modbus:

sensor:
  - platform: pzemac
    current:
      name: "Solar current"
    voltage:
      name: "Grid voltage"
    power:
      name: "Solar power"
      id: solar_power
    energy:
      name: "Solar energy total"
    frequency:
      name: "Grid frequency"
    power_factor:
      name: "Power factor"
    update_interval: 10s
  - platform: total_daily_energy
    name: "Solar yield today"
    power_id: solar_power
    unit_of_measurement: "kWh"
    accuracy_decimals: 2
    filters:
      - multiply: 0.001

Flash a ready firmware from the browser Paste your error into the AI Error Doctor

Build tips

  • The PZEM goes on the AC side of the micro-inverter, not on the panels.
  • Check the registration and plug rules for plug-in solar in your country before connecting to the grid.

← ← All projects

Related ideas

⛔ High risk

Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.

Smart energy meter

Reads voltage, current, power and kWh with PZEM-004T and publishes them to a web page, MQTT or Home Assistant.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●○ Intermediate
  • Build time 2–4 h
Pick parts / kit
⛔ High risk

Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.

Mains voltage monitor

Measures 220 V mains through an isolated ZMPT101B module and warns about sags, surges and blackouts in Telegram or Home Assistant.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●○ Intermediate
  • Build time 2–3 h
Pick parts / kit
⛔ High risk

Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.

Inverter load manager

Watches the inverter / battery current and switches off non-critical loads with a relay when the battery runs low.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●● Advanced
  • Build time 3–5 h
Pick parts / kit

Comments

No comments yet. Share your experience or ask a question.

Comments are moderated.