Hoping for some help (Can't get any ESP8266 to work) ESPHome Flasher ESP8266 CP210x

Can I get someone to help me figure out why I can’t get my esp8266 to install firmware from esphome. I also tried to install wled on them as a side test and couldn’t get that to work either. They are being recognized by windows and popping up the serial port selection window when attempting to flash esphome and wled.

It should also be noted that I have multiple of these and can’t get any of them to take a flash in esphome when hooked up to my windows laptop.

Then flash works properly when hooked up directly to my hassio instance on a raspberry pi.

image

When I hit “new device”, then connect, then select the com port from the windows menu, it shows connecting spinning and then bounces right back to the dialog box of “skip this step” and “connect”

EDIT:

When I select install and choose manual download. I get the following:

INFO Reading configuration /config/esphome/test3.yaml...
ERROR Unexpected exception while reading configuration:
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 33, in <module>
    sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
  File "/esphome/esphome/__main__.py", line 931, in main
    return run_esphome(sys.argv)
  File "/esphome/esphome/__main__.py", line 909, in run_esphome
    config = read_config(dict(args.substitution) if args.substitution else {})
  File "/esphome/esphome/config.py", line 972, in read_config
    res = load_config(command_line_substitutions)
  File "/esphome/esphome/config.py", line 827, in load_config
    return _load_config(command_line_substitutions)
  File "/esphome/esphome/config.py", line 815, in _load_config
    result = validate_config(config, command_line_substitutions)
  File "/esphome/esphome/config.py", line 742, in validate_config
    result.run_validation_steps()
  File "/esphome/esphome/config.py", line 124, in run_validation_steps
    task.step.run(self)
  File "/esphome/esphome/config.py", line 498, in run
    validated = schema(self.conf)
  File "/esphome/esphome/voluptuous_schema.py", line 34, in __call__
    res = super().__call__(data)
  File "/usr/local/lib/python3.9/dist-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.9/dist-packages/voluptuous/validators.py", line 229, in _run
    return self._exec(self._compiled, value, path)
  File "/usr/local/lib/python3.9/dist-packages/voluptuous/validators.py", line 353, in _exec
    v = func(path, v)
  File "/usr/local/lib/python3.9/dist-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
  File "/esphome/esphome/voluptuous_schema.py", line 34, in __call__
    res = super().__call__(data)
  File "/usr/local/lib/python3.9/dist-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.9/dist-packages/voluptuous/schema_builder.py", line 595, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/esphome/esphome/voluptuous_schema.py", line 118, in validate_mapping
    not isinstance(key.default, vol.Undefined)
  File "/esphome/esphome/config_validation.py", line 1450, in default
    if CORE.is_esp8266:
  File "/esphome/esphome/core/__init__.py", line 590, in is_esp8266
    return self.target_platform == "esp8266"
  File "/esphome/esphome/core/__init__.py", line 586, in target_platform
    return self.data[KEY_CORE][KEY_TARGET_PLATFORM]
KeyError: 'target_platform'

and if I choose “Plug into this computer”, I get “failed to initialize”

They are the Windows drivers, for installing on windows, not the esp8266

1 Like

@nickrout

Thank you for your response on this. I have updated my first post to reflect what you have added. All of the rest of the issues are still existent but thank you for straightening me out on that one.

Your first post still shows you trying to flash the zip file. Don’t.

Ahh, sorry about that. I didn’t delete that first picture. I have updated the first post now. I was able to get the device to flash when I hooked it straight up to the raspberry pi but I am really wanting to get this working when hooked up to my main/ daily driver laptop.

Can you think of anything that could be causing my issues when attached to my windows laptop.

Thank you Nick.

The picture of your device manager seems to show that you have the CP2102 drivers installed, but not sure if they are up to date.

I follow you. So, I went to this website:

but didn’t really know which ones to get. What is your choice on this? And I will install and report back.

It sounds like you are running Home Assistant on the Pi.

  1. In the ESPHome editor, click on Install and select Manual download:

Manual Download

  1. Next select the Legacy format:

Manual Download Legacy

When the code is compiled the .bin file will be in your downloads folder.

  1. In the ESPHome Flasher, select the serial port that the ESP is plugged into.
  2. In “Firmware” browse for the .bin file that was compiled above.
  3. Click on Flash.

@stevemann
Let me give this a go. I hope this works. It is late where I am at so I’ll give this a go as my last thing for the night and report back my results. Worst case, I’ll start back on this tomorrow evening.

Thank you all for trying to help me. I really do appreciate your help.

Thank you so much @stevemann, I spent so much time on this and you made it so easy. I wish I could get the selection “plug into this computer” to work properly but this will get the job done. Thank you so much for this again @stevemann.

So from here, will I be able to upload new code wirelessly?

EDIT: I have updated the code wirelessly now.

And lastly, can I get your expert opinion on the below.

If you don’t mind me asking 1 more thing I would really appreciate it. I have the below code working in an existing esp8266 (development board-- so slightly different pins but I have identified and updated the below code for the new boards). Can you tell me the best way to reuse this code for a new esp8266 board within esphome. It seems like every time I copy paste it and change the names/ identifiers throughout, it makes the device it was copied to stop working.

This code is working on another set of blinds currently. Are there pieces of this that I am not allowed to copy to the new device? The only thing I have tried to change when copying to the new device is anything with either of the 2 formats “dining-room-blinds-circuit” and “Dining Room Blinds Circuit”.

At that point, I copy paste it to a new device within esphome and things go all to crap.

esphome:
  name: dining-room-blinds-circuit

esp8266:
  board: esp01_1m

  on_boot:
    - priority: -200.0
      then:
      - stepper.report_position: # Set stepper to global variable
          id: stepper_motor
          position: !lambda return id(stepper_motor_global);
      - stepper.set_target: # Set stepper to global variable
          id: stepper_motor
          target: !lambda return id(stepper_motor_global);
      - if: # If blind is Closed
          condition:
            - lambda: 'return id(stepper_motor_global) == 0;'
          then: # Publish state etc.
            - cover.template.publish:
                id: dining_room_blinds_circuit
                state: CLOSED
                current_operation: IDLE
      - if: # If blind is Open
          condition:
            - lambda: 'return id(stepper_motor_global) == id(endstop);'
          then: # Publish state etc.
            - cover.template.publish:
                id: dining_room_blinds_circuit
                state: OPEN
                current_operation: IDLE
      - if: # If blind is Neither
          condition:
            - lambda: 'return (id(stepper_motor_global) != 0) && (id(stepper_motor_global) != id(endstop));'
          then: #  # Publish state etc.
            - cover.template.publish:
                id: dining_room_blinds_circuit
                position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
                current_operation: IDLE
# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "E+NoEmg5Wn+cA3mWF5cCTKXAglzqhkCidv85Ydj9lBU="

ota:
  password: "f3ce0bd8c4b823c6c361debbaea21b33"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Dining-Room-Blinds-Circuit"
    password: "eKZl7NVBpWnT"

captive_portal:

# esphome:
#   name: "dining-room-blinds"
#   platform: ESP32
#   board: nodemcu-32s

web_server:
  port: 80
## went from 750 to 500
#################
###############
globals:
  - id: stepper_motor_global # Integer for storing the stepper position in case of reboot
    type: int
    restore_value: True
    initial_value: '0'

  - id: openclosed # Boolean to store OPEN/CLOSED state
    type: bool
    restore_value: True
    initial_value: '0'

  - id: endstop # Variable for storing ENDSTOP (how far to move stepper)
    type: int
    restore_value: True
    initial_value: '750'   # this is the max value # this is the max value

stepper:
  - platform: a4988
    id: stepper_motor
    step_pin: GPIO13
    dir_pin: 
      number: GPIO12
      inverted: true   
    sleep_pin: 
      number: GPIO14
      inverted: true  # inverted since using enable pin
    max_speed: 250
############750 to 500
#############
############
cover:
  - platform: template
    name: Dining Room Blinds Circuit
    id: dining_room_blinds_circuit
    open_action:
      then:
        - logger.log: "Opening"
        - stepper.set_target: 
            id: stepper_motor
            target: 750
        - while:
            condition:
              lambda: 'return id(stepper_motor).current_position < id(endstop);'
            then:
              - cover.template.publish:
                  id: dining_room_blinds_circuit
                  position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
                  current_operation: OPENING
              - delay: 1000 ms
        - globals.set: # Set global to current position
            id: stepper_motor_global
            value: !lambda return id(stepper_motor).current_position; 
        - globals.set: # Set toggle to OPEN (No need for 'optimistic mode')
            id: openclosed
            value: '1'
        - cover.template.publish:
            id: dining_room_blinds_circuit
            state: OPEN 
            current_operation: IDLE
    close_action:
      then:
        - logger.log: "Closing"
        - stepper.set_target: # Send stepper to 0
            id: stepper_motor
            target: '0'
        - while:
            condition:
              lambda: 'return id(stepper_motor).current_position > 0;'
            then:
              - cover.template.publish:
                  id: dining_room_blinds_circuit
                  position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
                  current_operation: CLOSING
              - delay: 1000 ms
        - globals.set: # Set global to current position
            id: stepper_motor_global
            value: !lambda return id(stepper_motor).current_position; 
        - globals.set: # Set toggle to CLOSED (No need for 'optimistic mode')
            id: openclosed
            value: '0'
        - cover.template.publish:
            id: dining_room_blinds_circuit
            state: CLOSED
            current_operation: IDLE
    position_action:
      then:
        - stepper.set_target:
            id: stepper_motor
            target: !lambda return int(id(endstop) * pos);
        - while:
            condition:
              lambda: 'return id(stepper_motor).current_position != int(id(endstop) * pos);'
            then:
              - cover.template.publish:
                  id: dining_room_blinds_circuit
                  position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
              - delay: 1000 ms
        - globals.set: # Set global to current position
            id: stepper_motor_global
            value: !lambda return id(stepper_motor).current_position; 
        - cover.template.publish:
            id: dining_room_blinds_circuit
            position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
            current_operation: IDLE
    stop_action:
      then:
        - stepper.set_target:
            id: stepper_motor
            target: !lambda return id(stepper_motor).current_position;
        - globals.set: # Set global to current position
            id: stepper_motor_global
            value: !lambda return id(stepper_motor).current_position;
        - cover.template.publish:
            id: dining_room_blinds_circuit
            position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
            current_operation: IDLE
    has_position: true
    device_class: blind

switch:
  - platform: template
    name: Reset Dining Room Blinds Circuit
    id: reset
    turn_on_action:
      - stepper.set_target:
          id: stepper_motor
          target: '1500'
      - wait_until: 
          lambda: 'return id(stepper_motor).current_position == 1500;'
      - delay: 1s
      - stepper.set_target:
          id: stepper_motor
          target: '0'
      - globals.set: # Set global to current position
          id: stepper_motor_global
          value: !lambda return id(stepper_motor).current_position; 
      - globals.set: # Set toggle to CLOSED (No need for 'optimistic mode')
          id: openclosed
          value: '0'
      - cover.template.publish:
          id: dining_room_blinds_circuit
          state: CLOSED
          current_operation: IDLE
      - switch.turn_off: reset
  - platform: restart
    name: "Dining Room Blinds Circuit Reboot"

# Text sensors with general information.
text_sensor:
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: Dining Room Blinds Circuit IP
    ssid:
      name: Dining Room Blinds Circuit SSID

# Sensors with general information.
sensor:
  # WiFi Signal sensor.
  - platform: wifi_signal
    name: Dining Room Blinds Circuit WiFi Signal
    update_interval: 60s

This only works if “this computer” is the one running HAOS. In this case your Pi.

Now you’re in trouble.

This is how I copy a working device code to a new device. It may not be the best way, but it works here. The key is in the substitutions: block. This way you only have to change ONE LINE of the code if the devices are similar. (I have posted a sample of one of my YAML files, below). In my example YAML file, look at how I use $(device_name) in all of my name: and device: blocks.

  1. First, click on “Edit” for the existing device YAML file.
  2. Copy the contents.
  3. Go into the ESPHome page and click on “New Device”.
  4. Click on “Continue” (I don’t even know what ESPHome Web is).
  5. Give the device the name of your new device then click on Next.
  6. In the Select your Device Type, it doesn’t matter, just click on “Next”.
  7. You will get “Configuration created!”. Click “Skip”.
  8. Your new device will appear on the ESPHome control panel. Click on “Edit”.
  9. Delete EVERYTHING.
  10. Paste the contents that you copied in step 2.
  11. In the substitutions: block, change it to the new device name.
  12. Click on “Install”, “Manual Download”, “Legacy Format”

That’s a lot of steps, but once you have done a couple, you can do it in under a minute from memory.

Since this code is new to the device, you have to manually upload the .bin file as described above. Subsequent uploads can be done wirelessly.

Sample YAML file:

# geenie-outlet.yaml
# 8-08-22
# Replaces the Tuya ESP chip in the Geenie outlet strip.

substitutions:
  device_name: geenie_outlet
  
esphome:
  name: ${device_name}

esp8266:
  board: esp01_1m

# Multiple networks with DHCP
wifi:
  networks:
  - ssid: Kaywinnet
    password: !secret wifi_password
  - ssid: Serenity
    password: !secret serenity_password
  - ssid: Naboo
    password: !secret naboo_password

web_server:
  port: 80

# Enable logging
logger:
  level: VERBOSE     # default is DEBUG

# Enable Home Assistant API
api:

# Enable Over the Air updates
ota:
  safe_mode: True

text_sensor:
  # Get the WiFi details
  - platform: wifi_info
    ip_address:
      name: ${device_name} IP
    ssid:
      name: ${device_name} SSID
    mac_address:
      name: ${device_name} Mac
  

sensor:
  # WiFi Signal sensor.
  - platform: wifi_signal
    name: ${device_name} RSSI
    update_interval: 60s


############### Stuff for this board ###############
#Relays 
switch:
  - platform: gpio
    pin: 13
    name: "${device_name} Relay1"
    id: ${device_name}_relay1

  - platform: gpio
    pin: 12
    name: "${device_name} Relay2"
    id: ${device_name}_relay2

  - platform: gpio
    pin: 14
    name: "${device_name} Relay3"
    id: ${device_name}_relay3

  - platform: gpio
    pin: 16
    name: "${device_name} Relay4"
    id: ${device_name}_relay4

  - platform: gpio
    pin: 4
    name: "${device_name} Relay-USB"
    id: ${device_name}_relay_usb
    
#Button
binary_sensor:
  - platform: gpio
    pin: 
      number: 5
      inverted: true
    name: ${device_name}_button


#Blink the LED if there's a problem, on otherwise.	
status_led:
  pin:
    number: 0

1 Like

Ahh, I understand. I thought that was what the third option was for: “Plug into the computer running ESPHome Dashboard”-- I got this one to work with the ESP8266 hooked up to the pi.

I was under the impression, “Plug into this computer”, was for my laptop. (I connect to the pi headless through my laptop. Nonetheless, I have it running from my laptop with the method you taught me. I am very appreciative of that. I spent so many hours yesterday being an idiot until you taught me the best way.

Haha, I like it.

I didn’t even know there was something called a “substitutions” block.

Thank you for this. This will be very helpful to others after me also. Essentially I have started down the path of automated tilt blinds and I think this process will be very helpful.

This is perfect.

Thank you for explaining this process. This is what we did to get my first one going. I follow.

So the substitutions block is kind of like a variable. Niceeee. This is great!

Thank you again @stevemann You just saved me so much time on all of this. I am very appreciative of your help.

I didn’t either. I saw it in someone else’s YAML file and had to look it up.

I was working on the dumb copy- paste method to get a new device going before you taught me the proper way and everything validated well until I add this “on_boot” section. Does it have something to do with how I have structured it with the previous lines of code?

This seemed to work well when the esphome section was grouped with the board but now with the sections separated how it is giving a “target platform” error.

esphome:
  name: test

esp8266:
  board: nodemcuv2
  
# esphome:
#   name: "dining-room-blinds"
#   platform: ESP32
#   board: nodemcu-32s
  
###################################################################
###################################################################
###################################################################

  on_boot:
    - priority: -200.0
      then:
      - stepper.report_position: # Set stepper to global variable
          id: stepper_motor
          position: !lambda return id(stepper_motor_global);
      - stepper.set_target: # Set stepper to global variable
          id: stepper_motor
          target: !lambda return id(stepper_motor_global);
      - if: # If blind is Closed
          condition:
            - lambda: 'return id(stepper_motor_global) == 0;'
          then: # Publish state etc.
            - cover.template.publish:
                id: dining_room_blinds
                state: CLOSED
                current_operation: IDLE
      - if: # If blind is Open
          condition:
            - lambda: 'return id(stepper_motor_global) == id(endstop);'
          then: # Publish state etc.
            - cover.template.publish:
                id: dining_room_blinds
                state: OPEN
                current_operation: IDLE
      - if: # If blind is Neither
          condition:
            - lambda: 'return (id(stepper_motor_global) != 0) && (id(stepper_motor_global) != id(endstop));'
          then: #  # Publish state etc.
            - cover.template.publish:
                id: dining_room_blinds
                position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
                current_operation: IDLE
                
###################################################################
###################################################################
###################################################################

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "RcEi8ECuXaY50Xj3Czvxqlu7yaMCblpt35b/HBk2HS0="

ota:
  password: "fd0a3745afd91e62afd7694dc3e2d395"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Test Fallback Hotspot"
    password: "bjzNNVc8Q0iV"

captive_portal:

web_server:
  port: 80

###################################################################
################################################################### STEPPER CHANGE (ENDSTOP)
###################################################################

globals:
  - id: stepper_motor_global # Integer for storing the stepper position in case of reboot
    type: int
    restore_value: True
    initial_value: '0'

  - id: openclosed # Boolean to store OPEN/CLOSED state
    type: bool
    restore_value: True
    initial_value: '0'

  - id: endstop # Variable for storing ENDSTOP (how far to move stepper)
    type: int
    restore_value: True
    initial_value: '750'   # this is the max value # this is the max value

# stepper:
  # - platform: a4988
  #   id: stepper_motor
  #   step_pin: GPIO13
  #   dir_pin: 
  #     number: GPIO12
  #     inverted: true   
  #   sleep_pin: 
  #     number: GPIO14
  #     inverted: true  # inverted since using enable pin
  #   max_speed: 250
    
stepper:
  - platform: a4988
    id: stepper_motor
    step_pin: D7
    dir_pin: 
      number: D6
      inverted: true   
    sleep_pin: 
      number: D5
      inverted: true  # inverted since using enable pin
    max_speed: 250

###################################################################
################################################################### STEPPER CHANGE (TARGET)
###################################################################
    
cover:
  - platform: template
    name: Test
    id: test
    open_action:
      then:
        - logger.log: "Opening"
        - stepper.set_target: 
            id: stepper_motor
            target: 750
        - while:
            condition:
              lambda: 'return id(stepper_motor).current_position < id(endstop);'
            then:
              - cover.template.publish:
                  id: test
                  position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
                  current_operation: OPENING
              - delay: 1000 ms
        - globals.set: # Set global to current position
            id: stepper_motor_global
            value: !lambda return id(stepper_motor).current_position; 
        - globals.set: # Set toggle to OPEN (No need for 'optimistic mode')
            id: openclosed
            value: '1'
        - cover.template.publish:
            id: test
            state: OPEN 
            current_operation: IDLE
    close_action:
      then:
        - logger.log: "Closing"
        - stepper.set_target: # Send stepper to 0
            id: stepper_motor
            target: '0'
        - while:
            condition:
              lambda: 'return id(stepper_motor).current_position > 0;'
            then:
              - cover.template.publish:
                  id: test
                  position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
                  current_operation: CLOSING
              - delay: 1000 ms
        - globals.set: # Set global to current position
            id: stepper_motor_global
            value: !lambda return id(stepper_motor).current_position; 
        - globals.set: # Set toggle to CLOSED (No need for 'optimistic mode')
            id: openclosed
            value: '0'
        - cover.template.publish:
            id: test
            state: CLOSED
            current_operation: IDLE
    position_action:
      then:
        - stepper.set_target:
            id: stepper_motor
            target: !lambda return int(id(endstop) * pos);
        - while:
            condition:
              lambda: 'return id(stepper_motor).current_position != int(id(endstop) * pos);'
            then:
              - cover.template.publish:
                  id: test
                  position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
              - delay: 1000 ms
        - globals.set: # Set global to current position
            id: stepper_motor_global
            value: !lambda return id(stepper_motor).current_position; 
        - cover.template.publish:
            id: test
            position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
            current_operation: IDLE
    stop_action:
      then:
        - stepper.set_target:
            id: stepper_motor
            target: !lambda return id(stepper_motor).current_position;
        - globals.set: # Set global to current position
            id: stepper_motor_global
            value: !lambda return id(stepper_motor).current_position;
        - cover.template.publish:
            id: test
            position: !lambda 'return (float(float(id(stepper_motor).current_position) / float(id(endstop))));' 
            current_operation: IDLE
    has_position: true
    device_class: blind

###################################################################
################################################################### STEPPER CHANGE (TARGET)
###################################################################

switch:
  - platform: template
    name: Reset Test
    id: reset
    turn_on_action:
      - stepper.set_target:
          id: stepper_motor
          target: '1500'
      - wait_until: 
          lambda: 'return id(stepper_motor).current_position == 1500;'
      - delay: 1s
      - stepper.set_target:
          id: stepper_motor
          target: '0'
      - globals.set: # Set global to current position
          id: stepper_motor_global
          value: !lambda return id(stepper_motor).current_position; 
      - globals.set: # Set toggle to CLOSED (No need for 'optimistic mode')
          id: openclosed
          value: '0'
      - cover.template.publish:
          id: test
          state: CLOSED
          current_operation: IDLE
      - switch.turn_off: reset
  - platform: restart
    name: "Test Reboot"
    
###################################################################
###################################################################
###################################################################

# Text sensors with general information.
text_sensor:
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: Test IP
    ssid:
      name: Test SSID

# Sensors with general information.
sensor:
  # WiFi Signal sensor.
  - platform: wifi_signal
    name: Test Signal
    update_interval: 60s

EDIT: Maybe related?

EDIT2: So I ended up getting this working by following the method of putting all properties under “esphome” like the original was. This is confusing to me though because the 2, 2 line sections were generated by esphome for me so I don’t understand why they wouldn’t work as they are but here we are.

Works (no platform error and can validate):

esphome:
  name: "test"
  platform: esp8266
  board: nodemcuv2

Doesn’t work (i.e. platform error):

esphome:
  name: test

esp8266:
  board: nodemcuv2
1 Like