Help needed on DYI Solar Power Monitoring System

Hi Guys I’m making a DIY Solar power monitoring system for my small PV setup

I’ve used a NodeMCU and INA219 with ESPHome for this and the ESP Config is as following

esphome:
  name: solar_power_meter
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "!SECRET"
  password: "!SECRET"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

#Active I2C buss
#Sprcify GPIO pins for ESP board used
i2c:
  sda: 4
  scl: 5
  scan: True
#current-voltage sensor

sensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      name: "Solar Current"
      accuracy_decimals: 3
      filters:
       - multiply: 120
    power:
      name: "Solar Power"
      filters:
       - multiply: 120
    bus_voltage:
      name: "Bus Voltage"
      accuracy_decimals: 3
    shunt_voltage:
      name: "Shunt Voltage"
      filters:
      - multiply: 120
      accuracy_decimals: 3
    max_voltage: 32.0V
    max_current: 3.2A
    update_interval: 1s

The INA219 sends the data in every 1 Seconds and I’m able to get the below output in my HA
image

Now I want to get a “so far accumulate power” and “Day wise accumulated power” generated by the PV system in my HA.

I believe that can be done by a custom sensor with some value template, but I’m no expert in this area, could any one please help me with the above request.

1 Like

Well, With history sensor I’m really confuse how to achieve what I want, would you be able to help me with some more inputs.

I tried the following but I’m not sure what to give in the state

 - platform: history_stats
   name: Power As of now
   entity_id: sensor.solar_power
   type: time
   start: '{{ now().replace(hour=6).replace(minute=0).replace(second=0) }}'
   duration:
     hours: 12

Looking at it again, I may have leapt too soon. I assume Power (being in watts) is the power being delivered at a point in time. What you are wanting is total energy produced in watt hours, in other words an integral of the power over time. I probably should have pointed you here https://www.home-assistant.io/components/integration/

1 Like

Thanks much @nickrout :smiley:

- platform: integration
  source: sensor.solar_power
  name: solar_energy_generated

With the above I’m able to get the following stat.
image

Now how can I get Day wise stat ? Can I use Utility Meter for this ? Will the following give me the proper output which I want ?

utility_meter:
  daily_energy:
    source: sensor.solar_energy_generated
    cycle: daily
2 Likes

I think so.

1 Like

Thanks @nickrout For pointing me in the right direction. :slight_smile:

With the Help of Integration and Utility Meter Sensors I’m able achieve what I wanted.

1 Like

Hi Guys,

Can any one please help me what i need to change in the following script to connect to a particular MQTT Broker server and send messages there. instead of the native HA api:

esphome:
  name: solar_power_meter
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "!SECRET"
  password: "!SECRET"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

#Active I2C buss
#Sprcify GPIO pins for ESP board used
i2c:
  sda: 4
  scl: 5
  scan: True
#current-voltage sensor

sensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      name: "Solar Current"
      accuracy_decimals: 3
      filters:
       - multiply: 120
    power:
      name: "Solar Power"
      filters:
       - multiply: 120
    bus_voltage:
      name: "Bus Voltage"
      accuracy_decimals: 3
    shunt_voltage:
      name: "Shunt Voltage"
      filters:
      - multiply: 120
      accuracy_decimals: 3
    max_voltage: 32.0V
    max_current: 3.2A
    update_interval: 1s

I believe we can connect to a mqtt with the following, but than what to modify in the sensor part so it will push the messages to the mentioned mqtt broker !

# Example configuration entry
mqtt:
  broker: 10.0.0.2
  username: livingroom
  password: MyMQTTPassword

Remove api:. Add discovery: to the mqtt section. Job done.

(Or read the docs)

Well that’s the problem!!

Background:
My initial setup was working fine but after a month or so my Raspberry Pi 4 Memory card got corrupted, I replaced it with another one and after a month or so the other one was also got corrupted, I suspect that as my solar monitoring system sends chunks of messages to Rpi every seconds and it get written in the card the card is getting corrupted.

My workaround:
I had a spare android phone, so I hosted another instance of MQTT Broker and Home assistant in there it is dedicated to this solar monitoring system only. Now in here i want the Solar Monitoring system to send the messages to. but as it is a android device and HA not exactly suppose to with in such env. the discovery is not working properly, so i wanted a manual clear configuration for mqtt

image

When i tried the following my sensor is getting connected to the broker but not pushing any messages !! Please help what m I missing !!

mqtt:
  broker: 192.168.1.181
  username: !secret
  password: !secret
  log_topic: solar/sensor

I have no idea why you would even try to run home assistant on android.

Hi
I will build the same project. Can you help me wiring INA219 to esp8266 with solar panet and battery POWER (18650). I will know battery power (V) and current (A) and autonomy.
Can you help me ?
Regards
Giloris

Hi
I have à similar project for my connected Chicken home (solar project)
I will know battery level
Can you help me please ?
Regards
Giloris