Fail to install Home Assistant Glow

I would like to measure energy with Home Assistant Glow. I have bought the components and I have printed the cases.
I have mounted all component as described in the short description in the link for two HA Glow.

I run HA 2021.9.7 with ESPhome 2021.9.2.

I have successfully installed ESPhome on the first HA Glow according to instruction in the link and it measures energy for me. Now I try to install the second HA Glow. I copied the yaml file and changed the names. When I install the second HA Glow it just failes. The only difference between the two yaml files are the device_name and the friendly_name.

When I validate the config file there are no problems. When I try to install the second HA Glow it builds the software an starts installing but failes after 20 seconds with the following message:
image
I see no other eroor message.
Anyone who knows what can be the problem?

Here is the config file for the second HA Glow:

# Home Assistant Glow
#
# Read your electricity meter by means of the pulse LED on your 
# meter, useful if you do not have a serial port (P1).
#
substitutions:
  device_name: ha-glow-uterum
  friendly_name: uterum
  device_description: "Measure your energy consumption with the pulse LED on your smart meter"
  pulse_pin: GPIO12
  status_led: GPIO5
  # imp/kWh rate ⬇ #
  pulse_rate: '10000'
esphome:
  name: '${device_name}'
  comment: '${device_description}'
  project:
    name: "klaasnicolaas.home_assistant_glow"
    version: "2.0.1"
  platform: ESP32
  board: nodemcu-32s
wifi:
  ssid: !secret wifi_ssid_dlink
  password: !secret wifi_password
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: '${device_name}'
    password: !secret wifi_password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
  password: !secret esphome_api_password
ota:
  safe_mode: true
  reboot_timeout: 10min
  num_attempts: 5
web_server:
  port: 80
  auth:
    username: !secret esphome_web_username
    password: !secret esphome_web_password
output:
  # - platform: gpio
  #   pin: GPIO5
  #   id: output_blue
  - platform: gpio
    pin: GPIO2
    id: output_red
  - platform: gpio
    pin: GPIO4
    id: output_green
light:
  - platform: binary
    internal: true
    id: led_red
    name: Red
    output: output_red
# Status LED for connection
status_led:
  pin:
    # Blue LED
    number: ${status_led}
# Sensors for ESP version and WIFI information
text_sensor:
  - platform: version
    hide_timestamp: true
    name: "${friendly_name} - ESPHome Version"
  - platform: wifi_info
    ip_address:
      name: "${friendly_name} - IP Address"
      icon: mdi:wifi
    ssid:
      name: "${friendly_name} - Connected SSID"
      icon: mdi:wifi-strength-2
sensor:
  - platform: pulse_meter
    name: '${friendly_name} - Power consumption'
    unit_of_measurement: 'W'
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    accuracy_decimals: 0
    pin: ${pulse_pin}
    # internal_filter: 100ms
    on_value:
      then:
        - light.turn_on:
            id: led_red
        - delay: 0.5s
        - light.turn_off:
            id: led_red
    filters:
      # multiply value = (60 / imp value) * 1000
      # - multiply: 60
      - lambda: return x * ((60.0 / ${pulse_rate}) * 1000.0);
    total:
      name: '${friendly_name} - Total energy'
      unit_of_measurement: 'kWh'
      icon: mdi:circle-slice-3
      state_class: total_increasing
      device_class: energy
      accuracy_decimals: 3
      filters:
        # multiply value = 1 / imp value
        # - multiply: 0.001
        - lambda: return x * (1.0 / ${pulse_rate});

Which of the 4 install options are you using?

I connect the board via USB to my windows machine using the “Plug into this computer”. ESPHome finds the board (according the the GUI).

Have you tried to just compile the sketch(manual download option)

It compiles on my system, Are you placing the board in boot mode? Hold the button down on the esp not reset/en the other button for a few seconds. Otherwise try the stand alone flasher.

It does compile for me as well. I have put the board in boot mode by pushing the boot button on the board before I chose the serial device.

I downloaded the esphomeflasher and tried with the compiles ha-glow.bin that I compile via esphome. I get the following error message:

Using 'COM5' as serial port.
Unexpected error: could not open port 'COM5': PermissionError(13, 'Ă…tkomst nekad.', None, 5)

I started esphomeflasher as Administrator on my windows machine…

Edit:
The console says this:

Using 'COM5' as serial port.
Connecting....
Detecting chip type... ESP32
Connecting....

Chip Info:
 - Chip Family: ESP32
 - Chip Model: ESP32D0WDQ6 (revision 1)
 - Number of Cores: 2
 - Max CPU Frequency: 240MHz
 - Has Bluetooth: YES
 - Has Embedded Flash: NO
 - Has Factory-Calibrated ADC: YES
 - MAC Address: 08:3A:F2:59:AC:AC
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
 - Flash Size: 4MB
 - Flash Mode: dio
 - Flash Frequency: 40MHz
Erasing flash (this may take a while)...
Unexpected error: Error while erasing flash: Timed out waiting for packet content

Any ideas?

It looks like it’s still not in flash mode. You could try hold the reset down, then press and hold flash, release the reset and hit the flash command, hold flash button for a few more seconds.

Hm, I’m not sure I understand the instruction. My board looks like this:
image
I have two buttons: boot and EN. I used the button EN as the reset button in your instruction above. Correct?

Hold down en. While holding en, press and hold boot down. Release en, continue to hold boot. Start the flash process from esphome. Watch the log output when it connects release to boot button. It’s a timing thing you may have to try a few times before it flashes.

You can also try unplugging the esp, then holding down boot connect the usb and while still holding boot, start the flash process from esphome.

1 Like

The first part made it for me. Now it flashed the board. Great!

It showed up as a new entity and I could add it as an energy consumer. Good!

However, on the ESPHome dashboard this board is still OFFLINE even if the entity exists… Something is still messy!

See what ip the router has assigned, if you can make it static at the router. Then add manual ip to your wifi config.

wifi:
  ssid: "xxxxx"
  password: "xxxxxx"
  manual_ip:
    static_ip: 192.168.0.131(use ip assigned by router here)
    gateway: 192.168.0.1
    subnet: 255.255.255.0

Well, I have mounted the HA Glow at the meter with double sided tape. It delivers values to HA Energy. I need to remount it which I can do ofcourse.
My other HA Glow has dynamic IP and that one is ONLINE in ESPHome dashboard. I can’t understand why there is a problem with this one.
Is there another way to make the connection?

In the router I can see that my second glow has received an IP. Can it be enough to set a static IP in the router and restart the HA Glow? Then it will have a static IP even if the wifi config as you describe above is not updated.

It’s like winking at someone in the dark, you know what you’re doing but no one else does. In this case the router knows that its a static address but as far as home assistant and esphome, they have no idea.

They are still going through the process as if it was dynamic. That is known to cause some connection problems with esphome.

1 Like

I realize that also. But I can’t understand why it works with dynamic IP for the other HA Glow. How is that possible?

Can I compile a new version of the software via HA ESPHome and then via the web interface to the HA Glow upload it?

I succeeded by doing this:

  • Assigned a static IP in the router (did not restart the HA Glow)
  • Compiled a new version with the config you proposed and saved it as a file
  • Made a OTA update by browsing to the dynamic IP of the my browser to reach the HA Glow

Now both my HA Glow are online.

Thanks a lot for helping me! I learned a lot.

1 Like

My setup is now broken again. I have two Home Assistant Glow and after upgrading one of them to have a dedicated IP address I then tried to do the same thing for the other HA Glow. That failed and now I can’t flash it at all…

This is what I now try to do:

  • In ESPHome web gui I add a new entity where I put a configuration for HA Glow and the IP address thing added above.

Now I have tried two ways to flash my board:

  1. Via Home Assistant ESPHome gui. I have connected my board via USB to my Windows computer and chose “Plug into this computer”.
    I hold the boot button on the board, chose the correct serial port and press “Connect”. I can see that ESPHome connects (it says “Connecting” and then “Preparing installation”). Then it says “Installing… it can take two minutes”. It stops after ~15 s and says “Installation failed”.
  2. Via esphome-flasher 1.3.0 for Windows x64.
    I start by in Home Assistant ESPHome gui chose install and chose “Manual download” to get a .bin file.
    I connect my board to the windows computer, start esphome-flasher. I chose the serial port and the .bin file compiled above and press “Flash ESP”. It connects and I can see the following screen in the console:

    After ~1 minute it looks like this in the console beloe the text in the console above:

    When I press “View Logs” it says this:

My interpretation from the esphome-flasher printout is that esphome-flasher connects to the board but then fails for some reason. I have tried the proposed solutions in earlier posts to put the board in flash mode:

  • Hold the “boot” button when pressing Flash
  • Hold buttons "en"and “boot”, release “en”, press boot and release “boot” when connected.

When I search for similair problems I see proposals to look at which cable used. Since it seems to understand which board I have I think I do have the right cable. It has worked earlier to flash other boards.

What can I do now?

The only thing I can think of is use a different usb port.

Open esphome flasher as administrator.

Or use OTA?

Or plug it into the computer running esphome?

It was interesting to connect the board to my computer running HA and ESPHome. This is the output:

INFO Reading configuration /config/esphome/ha-glow-varmepump.yaml...
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/ha-glow-varmepump
Processing ha-glow-varmepump (board: nodemcu-32s; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif32 3.10006.210326 (1.0.6) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
Library Manager: Installing Hash
Library Manager: Already installed, built-in library
Dependency Graph
|-- <AsyncTCP-esphome> 1.2.2
|-- <FS> 1.0
|-- <ESPAsyncWebServer-esphome> 1.3.0
|   |-- <AsyncTCP-esphome> 1.2.2
|   |-- <Crypto> 0.2.0
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|   |-- <ArduinoJson-esphomelib> 5.13.3
|-- <ESPmDNS> 1.0
|   |-- <WiFi> 1.0
|-- <ArduinoJson-esphomelib> 5.13.3
|-- <noise-c> 0.1.3
|   |-- <libsodium> 1.10018.1
|-- <DNSServer> 1.1.0
|   |-- <WiFi> 1.0
|-- <Update> 1.0
|-- <WiFi> 1.0
Retrieving maximum program size /data/ha-glow-varmepump/.pioenvs/ha-glow-varmepump/firmware.elf
Checking size /data/ha-glow-varmepump/.pioenvs/ha-glow-varmepump/firmware.elf
RAM:   [=         ]  12.9% (used 42252 bytes from 327680 bytes)
Flash: [=====     ]  53.2% (used 975894 bytes from 1835008 bytes)
========================= [SUCCESS] Took 8.95 seconds =========================
INFO Successfully compiled program.
INFO Running:  platformio run -d /config/esphome/ha-glow-varmepump -t upload --upload-port /dev/ttyACM2
Processing ha-glow-varmepump (board: nodemcu-32s; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif32 3.10006.210326 (1.0.6) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - tool-mkspiffs 2.230.0 (2.30) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
Library Manager: Installing Hash
Library Manager: Already installed, built-in library
Dependency Graph
|-- <AsyncTCP-esphome> 1.2.2
|-- <FS> 1.0
|-- <ESPAsyncWebServer-esphome> 1.3.0
|   |-- <AsyncTCP-esphome> 1.2.2
|   |-- <Crypto> 0.2.0
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|   |-- <ArduinoJson-esphomelib> 5.13.3
|-- <ESPmDNS> 1.0
|   |-- <WiFi> 1.0
|-- <ArduinoJson-esphomelib> 5.13.3
|-- <noise-c> 0.1.3
|   |-- <libsodium> 1.10018.1
|-- <DNSServer> 1.1.0
|   |-- <WiFi> 1.0
|-- <Update> 1.0
|-- <WiFi> 1.0
Retrieving maximum program size /data/ha-glow-varmepump/.pioenvs/ha-glow-varmepump/firmware.elf
Checking size /data/ha-glow-varmepump/.pioenvs/ha-glow-varmepump/firmware.elf
RAM:   [=         ]  12.9% (used 42252 bytes from 327680 bytes)
Flash: [=====     ]  53.2% (used 975894 bytes from 1835008 bytes)
Configuring upload protocol...
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Use manually specified: /dev/ttyACM2
Uploading /data/ha-glow-varmepump/.pioenvs/ha-glow-varmepump/firmware.bin
Serial port /dev/ttyACM2
Connecting....
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
WARNING: Detected crystal freq 41.01MHz is quite different to normalized freq 40MHz. Unsupported crystal in use?
Crystal is 40MHz
MAC: 08:3a:f2:59:ad:08
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Warning: Could not auto-detect Flash size (FlashID=0xffffff, SizeID=0xff), defaulting to 4MB
Compressed 17104 bytes to 11191...

A fatal error occurred: Timed out waiting for packet content
*** [upload] Error 2
========================= [FAILED] Took 12.26 seconds =========================

Anyone who understand what this can mean?

What esp32 device have you got? Many chinese ones you pick up on aliexpress, bangood etc are built out of dodgy components.

Of course googling the error would find this [SOLVED] Failed to connect to ESP32: Timed out waiting for packet header | Random Nerd Tutorials

1 Like

I did buy my board from Banggood…

Thanks for the link. I will try the method recommended. :+1: