the Breakout board is what I’ve attached the ESP-01s to in order to flash it as mentioned here
My wiring for the relay is as follows
Please see photos at the start for the actual wiring.
As far as I can see it’s all OK and I’ve checked the polarity with my multimeter.
What is your load? It is on by default (normally closed terminal).
How much current is it drawing?
Is the power supply beefy enough to provide enough power for the esp and the load?
the USB is plugged into my laptop which is delivering 1a and 5.07v I’ve also tried it in a wall socket where it is getting 2a but with no joy.
as I have two I split one down to start again and only wired the 5v and ground of the input, connected it to a 5v 2a power adaptor (that I use to charge my phone) but still no joy. after words I checked the charger again to see if mybe i had blown it but it still works perfectly and if I connect the ESP-01s to the breadboard again for power, everything is great.
the load that will be attached to the relay will be my phone, but at the moment I havent attached anything to that end as I am just trying to find out where I am going wrong with gettign it to work. Yes it is on by default, the idea is to have the relay turn the power off but in the event of a problem the cable wil open and just charge as normal.
is there any way to check the relay is actually working? and in order for the esp-01s to work does it only need power?
edit:
ok I have played some more and not sure if this will help or not… I thought if I go back to the start (everythign wired up as in the diagram) but this time use dupont wires between the ERSP-01s and the relay I could see if any one connection is causing the problem. so I wired up the 3.3v on the relay to the 3.3v on the board, with the gnd - gnd . the chip powerd up and was visable in ESPhome, I could also see logs. so I pulled the power and connected each gpio in one at a time checking to see if any cause problems, gpio0 is the only one that for some reason prevents the board from booting up.
so I thought maybe I could ignore that one and move the switch on my yaml to gpio2, on doing this i get a blue led turnign on when I flick the switch in HA but other than that, nothing with the relay. any ideas?
my current Yaml file :
esphome:
name: robins_usb_charger
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret ssid
password: !secret password
manual_ip:
static_ip: 192.168.0.54
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: "Robins Charger Fallback Hotspot"
password: !secret appass
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
# enable over the air updates
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 the following formatted uptime sensor
- platform: uptime
name: "Robins Charger Do Not Use"
id: robins_charger_do_not_use
internal: true
update_interval: 600s
# WiFi Signal sensor.
- platform: wifi_signal
name: Robins Charger WiFi Signal
update_interval: 600s
# Text sensors with general information.
text_sensor:
# Expose ESPHome version as sensor.
- platform: version
name: Robins Charger ESPHome Version
# Sensor to display uptime in Days/hours/minutes
- platform: template
name: "Robins Charger Uptime"
lambda: |-
uint32_t dur = id(robins_charger_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
# Exposed switches.
switch:
# Switch to restart the charger.
- platform: restart
name: Robins Charger Restart
# Switch to turn on/off the charger.
- platform: gpio
id: relay
name: Robins Charger
pin:
number: 0
inverted: true
this is not my code, I cant program to save myself, this is howerver snips of code from various threads and projects that I think work in doing what I want. there may be better easier ways to do this , if so please feel free to tel me, my aim is to try and get this to work and hopefully learn something of how it works along the way.
thank you for all your help, I can appretiate this is not easy, and I appretiate the time you are all taking to help me
robin
Can you please point to the exact relay you are using as they are not all the same.
I wasn’t aware that they are not all the same.
here is the link to the ones I bought.
https://www.aliexpress.com/item/32880024822.html?spm=a2g0s.9042311.0.0.25394c4dP8mgmO
hope that helps and thank you for your time
There are two very similar devices. On one you simply turn a gpio (usually gpio0) on and off to turn the relay on and off. The second sort you have to send a hex code out a uart to turn the relay on and off. I suspect from the q&a on that aliexpress ad that you have the second type. There is a config for the seccond type in another thread. I will try and find it.
Wow thank you Nick, I’ll have a play with that and see how I get on.
again thank you
No problems. There is further reading here https://tasmota.github.io/docs/devices/LC-Technology-WiFi-Relay/
That link has changed, see my post above this one
Got it working! thank you to everyone!
After a load of help from all of you very kind people you worked out that in order for me to see the logs (to know that I at least have a working ESP-01s) i had to only have the gpio0 pin connected to gnd for flashing, and to relaease it during flashing so that on reboot is was no longer in flash made and would therefore display my logs. This also had the effect of allowing ESPHome and Home assistant to see the chip and add it as an integration. THANK YOU.
after knowing the ESP-01s chip was ok the next step was the relay. I tried the above method but realised that my first problem is that gpio0 was preventing the ESP-01s from powering up, so no matter what i tried with the programing it wasn’t going to make any difference unless I could solve this next “baby step”. On searching I found a video on youtube saying to connect 3.3v with CHPD with a jumper wire and to remove a resistor from the board. By this point I had already decided that the relay wasn’t working and I’d probably need to buy a new one so I had nothing to loose, I soldered the jumper wire and desoldered the resistor. on inserting the chip and powering it on the relay worked… with a snag… it just turned on and off repeatedly so was no more use than before… but I had power to the ESP-01s chip so I viewed it as a success! then I found out my solderign was rubbish… as the jumper wire fell off and the relay worked! as it should!
so, I’ve included the picture of which resistor i removed below
and my finished yaml file incase anyone is interedted (as said before I can’t program, this is not my work but a collection of other peoples work that i’ve put together with kind permission from all of them and with thanks from me… )
esphome:
name: robins_usb_charger
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret ssid
password: !secret password
manual_ip:
static_ip: 192.168.0.54
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: "Robins Charger Fallback Hotspot"
password: !secret appass
captive_portal:
logger:
baud_rate: 0 #need this to free up UART pins
# Enable Home Assistant API
api:
# enable over the air updates
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 the following formatted uptime sensor
- platform: uptime
name: "Robins Charger Do Not Use"
id: robins_charger_do_not_use
internal: true
update_interval: 600s
# WiFi Signal sensor.
- platform: wifi_signal
name: Robins Charger WiFi Signal
update_interval: 600s
# Text sensors with general information.
text_sensor:
# Expose ESPHome version as sensor.
- platform: version
name: Robins Charger ESPHome Version
# Sensor to display uptime in Days/hours/minutes
- platform: template
name: "Robins Charger Uptime"
lambda: |-
uint32_t dur = id(robins_charger_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
# Exposed switches.
switch:
# Switch to restart the charger.
- platform: restart
name: Robins Charger Restart
# Switch to turn on/off the charger.
- platform: gpio
id: relay
name: Robins Charger
pin:
number: 0
inverted: true
So again, thank you to everyone for all your help and patience with me in gettign this to work.
I applaud your determination and not falling into the blame-others trap when you ran into a roadblock.
thank you Matthew, I dont see the point in a blame game… at the end of the day after you have blamed everyone and their grannies you still fall down to having to solve the problem, I’d much rather not waste anyones time in blame and get right to the solve the problem. that way we all learn faster and in learning we grow our abilities which normally prevents needing to blame anyone in the future
Thanks, it will be very usefull when I will receive my ESP01S …
Ok … thanks for all your tips… worked flowless for me. For I had chance, the ESP01S I got from amazon didn’t requiered to swap the resistance or to wire CH_PD to VCC.
The main difference I am seeing is the position of the transistor nearby R1 & R2. Mine is above R1 not on the left side.
Great post and share. I’ve adapted to a relay board v 4.0 and it works flawlessly. I just notice that the uptime not alway reset after a power loss or a hW reset and since doesn’t happen always is not easy to troubleshoot.
@Joao-Sousa-71, So a 4.0 version of this relay module is available? Can you please share the link? Thank you
It was in aliexpepress. Here you have the link:
Just after posting this I was able to find it on AliExpress and ordered. Thanks anyway.