Home Automation India Documentation

website·Indexed 30 days ago

https://home-automation-india.netlify.app

A resource for home automation enthusiasts and DIYers featuring guides on energy monitoring with PZEM-004T, ESPHome powered solar WiFi weather stations, inverter battery monitoring, and WLED ambient lighting. Includes instructions for flashing custom firmware like Tasmota or ESPHome onto Tuya-based devices using Tuya CloudCutter.

Tokens
2.9K
Snippets
8
Records
18
Agent score
75%

What's inside Home Automation India

  1. Overview of Tuya CloudCutter for Beken-based devices

    Tuya CloudCutter is an over-the-air (OTA) exploit used to flash custom firmware onto Tuya-based Wi-Fi smart devices that use Beken chipsets. This method allows developers to bypass the need for hardware modifications (like chip swapping or soldering) to achieve local control. Through the LibreTiny project, these devices can be integrated with ESPHome and Home Assistant, providing a seamless experience for those familiar with the ESPHome ecosystem.
  2. Find educational YouTube channels for home automation

    The following YouTube channels are recommended for DIY enthusiasts and developers looking for insights, practical tips, and guidance on smart home experiences and home automation projects:

  3. Install and configure WLED firmware

    Install the WLED firmware on the ESP8266 (Wemos D1 Mini) by following the official binary installation guide. During setup, configure the number of LEDs, maximum current, and WiFi credentials.

    Stability Tip: In the WLED UI WiFi settings, ensure the appropriate stability checkboxes are checked to prevent frequent ESP8266 freezes or restarts.

    # Installation guide: https://kno.wled.ge/basics/install-binary/
  4. Hardware setup for Inverter Battery Monitor

    To monitor inverter battery voltage, current, and temperature using a NodeMCU/D1 Mini, follow these hardware requirements:

    1. Power Supply: Use an LM2596 step-down converter. You must tune the LM2596 using a multimeter before connecting it to the NodeMCU/D1 Mini, as the default output may be 12VDC or higher. Adjust the screw on top to decrease the voltage to a level safe for the microcontroller.
    2. Voltage Divider: Since the NodeMCU/D1 Mini has a limited input voltage on the A0 pin, use a voltage divider circuit. Calculate the required resistors (R1 and R2) based on your battery voltage (typically 12.5V to 14V) to ensure the output voltage at the A0 pin is approximately 3.5V.
    3. Power Monitoring: Integrate a POW or similar power monitoring device to calculate remaining battery life during power failures. Power failure can be detected when battery voltage drops below normal levels or via a smart switch connected to the inverter input.
  5. Wire WLED strip to Wemos D1 Mini

    Follow these wiring instructions to connect the hardware:

    1. Connect the 5V DC output from the SMPS to both the LED strip (+ and -) and the Wemos D1 Mini (+5V and -).
    2. Solder a 1000uF capacitor to the 3.3V and GND pins of the Wemos D1 Mini.
    3. Connect the LED strip Data pin to pin D5 on the Wemos D1 Mini.
  6. Connect PZEM-004T sensor to ESP8266

    The PZEM-004T is designed for 5V, but ESP chips (like the D1 Mini) use 3.3V GPIOs. To prevent damage to the ESP, a 1K resistor must be added to reduce the voltage for the RX line. If the sensor fails to work when powered by 5V after adding the resistor, try powering the PZEM sensor from the ESP 3.3V pin.
    ESP 5V   <-->  PZEM 5V
    ESP GND  <-->  PZEM GND
    ESP RX   <-->  PZEM TX
    ESP TX   <-->  PZEM RX
  7. Hardware requirements for WLED ambient light

    To build the ambient light project, you will need the following hardware components:

    • WLED strip (WS2812), 30 or 60 LEDs per meter (optional aluminum channel)
    • WeMo D1 Mini
    • 1000uF capacitor
    • 230V to 5V 2A SMPS (Power Supply)
    • Power cord
    • Enclosure
    • Tools: Glue gun, soldering iron, and short wires.
  8. Calculate Battery Backup and Status in Home Assistant

    Create template sensors in Home Assistant to derive the UPS mode, battery status, load percentage, and estimated backup time based on the battery voltage and inverter power consumption.
    - platform: template
      sensors:
        battery_backup_time:
          friendly_name: Battery Backup Time
          unit_of_measurement: 'Hours'
          icon_template: 'mdi:car-battery'
          value_template: >
            {% if is_state('sensor.ups_mode', 'Battery') %}
              {{ ( 150 * (states('sensor.battery_voltage')|float) * 1 * 0.8 / states('sensor.inverter_energy_power')| float )| round(2) }}
            {% else %}
              ~
            {% endif %}
    
        ups_mode:
          friendly_name: UPS Mode
          icon_template: 'mdi:flash-off'
          value_template: >
            {% if states('sensor.battery_voltage')| float > 13.50 %}
              Mains
            {% else %}
              Battery
            {% endif %}
    
        ups_load:
          friendly_name: UPS Load
          unit_of_measurement: '%'
          icon_template: 'mdi:download'
          value_template: >
            {% if is_state('sensor.ups_mode', 'Battery') %}
              {{ ( states('sensor.inverter_energy_power')| float * 100 / (1050 * 0.8) )| round(2) }}
            {% else %}
              0
            {% endif %}
    
        battery_status:
          friendly_name: Battery Status
          icon_template: 'mdi:information'
          value_template: >
            {% if states('sensor.battery_voltage')| float > 13.50 %}
              Fully Charged
            {% elif states('sensor.battery_voltage')| float < 10.50 %}
              About to Die
            {% else %}
              Charge/Discharge
            {% endif %}
  9. Configure PZEM-004T in ESPHome

    Use the pzemac platform in ESPHome to monitor AC current, voltage, energy, power, frequency, and power factor. Note that on the D1 Mini, logging should be disabled if the PZEM is connected to the hardware UART pins, as the board only has one UART interface.
    uart:
      rx_pin: 12
      tx_pin: 14
      baud_rate: 9600
    
    sensor:
      - platform: pzemac
        current:
          name: "PZEM-016 Current"
          id: aac
          internal: true
        voltage:
          name: "PZEM-016 Voltage"
          id: vac
          internal: true
        energy:
          name: "PZEM-016 Energy"
          id: eac
          internal: true
        power:
          name: "PZEM-016 Power"
          id: w
          internal: true
        frequency:
          name: "PZEM-016 Frequency"
          id: f
          internal: true
        power_factor:
          name: "PZEM-016 Power Factor"
          id: pf
          internal: true
        update_interval: 2s
    
      - platform: total_daily_energy
        name: "Energy kwh"
        power_id: w
        filters:
          - multiply: 0.001 # Multiplication factor from W to kW
        unit_of_measurement: kWh
        accuracy_decimals: 1
  10. Configure ESPHome for Battery and Temperature Monitoring

    Use the following ESPHome configuration for an ESP8266 (NodeMCUv2) to monitor battery voltage via the A0 pin and temperature/humidity via a DHT sensor on pin D0. Note that the calibrate_linear filter values for the battery voltage must be calibrated using a multimeter for accuracy.
    esphome:
      name: battery_monitor
      platform: ESP8266
      board: nodemcuv2
    
    wifi:
      ssid: XXYYZZ
      password: XXYYZZ
      fast_connect: true
      reboot_timeout: 0s
      manual_ip:
        static_ip: 192.168.1.116  # Required to flash again via OTA
        gateway: 192.168.1.1
        subnet: 255.255.255.0
    
    logger:
      level: DEBUG
    
    api:
      password: XXYYZZ
    
    ota:
      password: XXYYZZ
    
    sensor:
      - platform: adc
        pin: A0
        name: Battery Voltage
        update_interval: 10s
        filters:
          - calibrate_linear:  # min 2 values required
              - 0.95 -> 13.51 # need to caliberate using Multimeter
              - 0.96 -> 13.52
    
      - platform: dht
        pin: D0
        temperature:
          name: "Battery Temperature"
        humidity:
          name: "Battery Humidity"
        update_interval: 60s