Having problems with ESP-01s and relay. getting it to work

hi all,

I have a esp-01s attached to a relay board acting as a switch between two usb ports. I’ve flashed the ESP-01s using ESPHome-Flasher-1.1.0

this is the yaml I flashed

esphome:
  name: elsbeths_charger_test
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret ssid
  password: !secret password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Elsbeths Charger Test"
    password: !secret appass

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

# Enable Web server.
web_server:
  port: 80

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time


# Sensors with general information.
sensor:
  # Uptime sensor used in following formatted uptime sensor
  - platform: uptime
    name: "Elsbeths Charger Test Do Not Use"
    id: e_charger_test_do_not_use
    internal: true
    update_interval: 600s

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: Elsbeths Charger test WiFi Signal
    update_interval: 600s

when flashing it tell me everything is ok, but when I plug the ESP-01s into the relay board and connect to 5v power via usb nothing shows in home assistant, nothing shows in my wifi hub I dunno what I have done wrong.

i’ve got photos on my phone that I’ll add in a sec to help see what I have done.

any help is greatly appretiated

thank you in advance

I haven’t looked at your wiring, but it seems like the only functionality you’ve enabled in the code and will show up in home assistant so far is a WiFi signal sensor. Have you added it to home assistant using configuration->integrations->Esphome?

Hi Matthew,

thanks for your reply. Yeah that’s right so far I was just putting on something to get me started and to see if everything is working, I guessed I could do all the rest OTA as I work on it.

I’ve tried setting a static IP ans adding it to Home assistant vie config->Integrations->ESPhome but it says to include the api: which as far as I understand I have…

I’ve removed the static IP settings, reset my router and restarted my Pi runing Home Assistant but it still wont show up. my thought was maybe the chip isnt getting power… so I checked my wireing, the relay is getting 5v and the chip is getting 3v (Ive rounded the voltage) so I’m totally stummped now…

Can you get the logs after flashing it? I’m not familiar with these units, but with other units I can get logs after flashing to see if it boots and connects correctly. Then if it doesn’t work in its final position, it is likely either a power issue or a WiFi signal issue.

Once I’ve flashed it, it comes up with this

And that’s it, nothing else after this.

looking at you code I cant see the code talking to the relay Switch
shouldn’t you have some code in there pointing to the switch GPIO0

 # Switch to turn on/off the chime.
  - platform: gpio
    id: relay
    inverted: true
    name: Elsbeths Charger Switch
    pin: GPIO0

also the only way I get esp working is by add a IPaddress manually

wifi:
  ssid: "bla-bla"
  password: "bla-bla-bla"
  
  manual_ip:
    static_ip: ipaddress not in dhcp range
    gateway: ipaddress pointing to your router
    subnet: 255.255.255.0

then goto Integrations hit the plus seach for esphome type in above ipaddress and above password for esp home

tried that, still nothing… I reverted my yaml to this

esphome:
  name: elsbeths_charger_test
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret ssid
  password: !secret password
  manual_ip:
    static_ip: 192.168.0.53
    gateway: 192.168.0.1
    subnet: 255.255.255.0
    dns1: 192.168.0.1
    dns2: 192.168.0.1
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Elsbeths Charger Test"
    password: !secret appass


captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

# Enable Web server.
web_server:
  port: 80

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time


# Sensors with general information.
sensor:
  # Uptime sensor used in following formatted uptime sensor
  - platform: uptime
    name: "Elsbeths Charger Test Do Not Use"
    id: e_charger_test_do_not_use
    internal: true
    update_interval: 600s

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: Elsbeths Charger test WiFi Signal
    update_interval: 600s

# Text sensors with general information.
text_sensor:
  # Expose ESPHome version as sensor.
  - platform: version
    name: Elsbeths Charger ESPHome Version

# Sensor to display uptime in Days/hours/minutes      
  - platform: template
    name: "Elsbeths Charger Uptime"
    lambda: |-
      uint32_t dur = id(e_charger_test_do_not_use).state;
      int dys = 0;
      int hrs = 0;
      int mnts = 0;
      if (dur > 86399) {
        dys = trunc(dur / 86400);
        dur = dur - (dys * 86400);
      }
      if (dur > 3599) {
        hrs = trunc(dur / 3600);
        dur = dur - (hrs * 3600);
      }
      if (dur > 59) {
        mnts = trunc(dur / 60);
        dur = dur - (mnts * 60);
      }
      char buffer[17];
      sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
      return {buffer};
    icon: mdi:clock-start
    update_interval: 600s



# Global to store the on/off state of the chime
globals:
  - id: charger
    type: bool
    restore_value: true
    initial_value: 'true'

# Exposed switches.
switch:
  # Switch to restart the doorbell.
  - platform: restart
    name: Elsbeths Charger Restart

  # Switch to turn on/off the chime.
  - platform: gpio
    id: relay
    inverted: true
    name: Elsbeths Charger test
    pin: GPIO0

on uploading this to the ESP-01s there were no logs when I try to find it in integrations there is nothing found.

I suspect that you aren’t completing the right sequence of flashing and rebooting required with these units, but I’ve never used one. Hopefully someone with more direct knowledge can help.

Ahh ok, thank you for your help :slight_smile:
I’ll see what I can find on that and try to solve it

again, thank you

smoko time here (at work can’t give you screen shots)

winging it here think you have to add debug to the logger section

logger:
  level: DEBUG

just check the spacing

and do the reboot thing to the esp

thank you Myle, though unfortunately that didnt change anything.

I’ve tried to use Frencks doorbell tutorial to upload the yaml, even tried to upload that file and alter it from there, but still the same problem… my thoughts now are that I have a faulty ESP-01s

any other ideas?

did you read this

https://tasmota.github.io/docs/#/devices/LC-Technology-WiFi-Relay?id=lc-technology-wifi-relay-single-relay

talk about “serial communications used to control the relays”

have you tryed tamota on it if that dont work them ill say it a faulty ESP-01

Baby steps, try it without the connecting to the relay board. (You’ll need to power it, which you were doing to flash it anyway)

Does it work?

Hi nick , baby steps it what I was trying (but maybe the wrong steps)…

Acording to esp home flasher I can flash the chip, that to me says its getting power (also a led on the esp-01s flashed blue). Other than that nothing I’ve tried works or shows any signs of life.

Once flashed there are no logs shown in esp home flasher.

Humour me please… What’s the flashing process? Just thinking I may have this wrong…

What I’ve done…

Got a breakout board and…

  1. Soldered a dupont cable to link vcc with chpd.
  2. Soldered a dupont cable to link gnd with gp0
  3. soldered a dupont cable to tx and a separate one to rx.

Connected my FTDI adaptor as follows

Vcc - > 3v
Gnd - > gnd
Rx - > Tx
Tx - > Rx
Voltage jumper set to 3v (checked about 10 times)

Connected to pc then select port, select bin file and press flash chip.

It shows as flashing, says complete and that’s it…

I’m wondering if my error is in the above rather than my yaml file…

I believe you have to pull up or down a specific pin to get it to boot. I think you are still in flashing mode.

I think I was wrong in suggesting you should see logs after flashing, all of the esp units I’ve used allow for this, but apparently not this one.

I think this way it stays in flash mode. GND to gp0 is only needed for flashing.

ok I re-worked the flashing procedure.

removed all my wires and fitted pins to the breakout board then pressed it into a breadboard.

wired it as above except I put a normally open tempory switch between ground and gpio0.

when flashing I held the button down then when finished I reset the chip and released the button, my logs showed in esphome flasher. so I know the chip is working and everything there is ok… Phew!!

i still cant find it in home assistant though. when i conect it up and reboot it sometimes shows up but if I go throguht intigrations nothing is there and I get an error

Can’t connect to ESP. Please make sure your YAML file contains an ‘api:’ line.

I’m sure that is set correctly… have I got that wrong?

Can you ping the device?

I asked you about the logs in esphome, not esphome flasher.

Sorry I ment to reply to that as well. I can ping it only when it is in the breakoutboard right after flashing. but at no other time

Can you ping the device.