Power strip with six outlets

Hello everyone, I am making a smart power strip with six outlets and a display that makes me read the ON/OFF states of each relay, returns room temperature and water temperature of an aquarium (the Esp32-S3 of the power strip, actually reads me the entities of room temperature and tank water, which are detected by another SP32 with separate probes).
To do this, I am using, as mentioned above, an ESP32-S3, an ST7796 320*480 LCD screen, a 4-channel 5V relay board, a two-channel 5V relay board, and a 5V 2A power supply, which powers the esp and the two relay boards.
Everything seems to work fine, when, however, I connect a load to one of the six sockets, everything goes crazy…esp restarts itself, LCD no longer reads etc.
IF I restart the esp32 without having connected any load to the power strip, everything works fine again, every single channel of the relay boards turns on and off regularly, on the display I read the status of every single channel correctly etc. ; it is enough, however, that I connect anything to one of the six sockets that everything goes to hell.
I am attaching the yaml file:

, in the hope that someone can/will help me.
Thank you and bye

Translated with DeepL.com (free version).
This is the yaml file:

esphome:
  name: acquario
  friendly_name: Acquario
  on_boot:
    if:
      condition:
        time.has_time:
      then:
        - logger.log: Time has been set and is valid!

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "IlXNRQa69lp+OYgvLgZAP+rR/25e8u7sizfnl/opRdk="

 

ota:
  - platform: esphome
    password: "f256321e2622b5deb90bd8aa44a6f29a"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Prova-S3 Fallback Hotspot"
    password: "pC0trGfQMn10"
    
web_server:
  port: 80



captive_portal:

time:
    platform: homeassistant
    id: homeassistant_time      
    timezone: Europe/Rome 

spi:
  clk_pin: GPIO4
  mosi_pin: GPIO5
  id: lcd
  # MISO non è usato per il display ST7735S

color:
  - id: my_red
    red: 100%
    green: 3%
    blue: 5%
  - id: my_blu
    red: 5%
    green: 3%
    blue: 100%
  - id: my_green
    red: 5%
    green: 100%
    blue: 3%
  - id: my_yellow
    hex: ffff00
  - id: my_fucsia
    hex: f400a1
  - id: my_orange
    hex: FF8000


display:
  - platform: ili9xxx
    model: ST7796
    spi_id: lcd
    cs_pin: GPIO15
    dc_pin: GPIO7
    reset_pin: GPIO6
    invert_colors: false
    dimensions: 320x480  #320x480 not possible because of memory limitations
    rotation: 90
    color_palette: 8BIT
    #data_rate: 40MHz
     


    
    lambda: |-
      
      
      it.strftime(3, 3, id(fonts2), "%d %b %Y", id(homeassistant_time).now());
      it.strftime(3, 23, id(fonts2), "%H:%M:%S", id(homeassistant_time).now());
      it.print(140, 0, id(fonts4), id(my_fucsia), "ACQUARIO:");
      it.rectangle (0, 52.5, 480, 267.5, id(my_green));
      it.print(10, 60, id(fonts3), id(my_blu), "Luci:");
      if (id(relay_1).turn_on()) {
        it.print(100, 60, id(fonts3), id(my_green), "ON");
      } else {
        it.print(100, 60, id(fonts3), id(my_red), "OFF");
      }
      it.print(10, 85, id(fonts3), id(my_blu), "Filtro:");
      if (id(relay_2).turn_on()) {
        it.print(100, 85, id(fonts3), id(my_green), "ON");
      } else {
        it.print(100, 85, id(fonts3), id(my_red), "OFF");
      }
      it.print(10, 110, id(fonts3), id(my_blu), "Aria:");
      if (id(relay_3).turn_on()) {
        it.print(100, 110, id(fonts3), id(my_green), "ON");
      } else {
        it.print(100, 110, id(fonts3), id(my_red), "OFF");
      }
      it.print(10, 135, id(fonts3), id(my_blu), "Riscald.:");
      if (id(relay_4).turn_on()) {
        it.print(100, 135, id(fonts3), id(my_green), "ON");
      } else {
        it.print(100, 135, id(fonts3), id(my_red), "OFF");
      }
      it.print(10, 160, id(fonts3), id(my_blu), "Refrig.:");
      if (id(relay_5).turn_on()) {
        it.print(100, 160, id(fonts3), id(my_green), "ON");
      } else {
        it.print(100, 160, id(fonts3), id(my_red), "OFF");
      }
      it.print(10, 185, id(fonts3), id(my_blu), "Aux:");
      if (id(relay_6).turn_on()) {
        it.print(100, 185, id(fonts3), id(my_green), "ON");
      } else {
        it.print(100, 185, id(fonts3), id(my_red), "OFF");
      }
        
        it.rectangle (160, 57.5, 185, 40, id(my_green));
        it.rectangle (160, 57.5, 185, 107.5, id(my_green));
        it.rectangle (5, 57.5, 150, 160, id(my_green));
      
      


font:
  - file: "fonts/arial.ttf"
    id: fonts
    size: 20
  - file: "fonts/arial.ttf"
    id: fonts1
    size: 14
  - file: "fonts/arial.ttf"
    id: fonts2
    size: 21
  - file: "fonts/arial.ttf"
    id: fonts3
    size: 22
  - file: "fonts/Ramillas.ttf"
    id: fonts4
    size: 40

# Definizione dei relè e interruttori
switch:
  - platform: gpio
    pin: GPIO42
    id: relay_1
    name: "Luci"
  - platform: gpio
    pin: GPIO41
    id: relay_2
    name: "Filtro"
  - platform: gpio
    pin: GPIO40
    id: relay_3
    name: "Aria"
  - platform: gpio
    pin: GPIO39
    id: relay_4
    name: "Riscaldatore"
  - platform: gpio
    pin: GPIO38
    id: relay_5
    name: "Refrigerazione"
  - platform: gpio
    pin: GPIO37
    id: relay_6
    name: "Aux"


binary_sensor:
  - platform: gpio
    name: "Interruttore Luci"
    pin: 
      number: GPIO36 # Interruttore Luci
      mode: 
        input: true
        pullup: true
      inverted: true
    on_press:
      then:
        - switch.turn_on: relay_1
    on_release: 
      then:
        - switch.turn_off: relay_1
    filters:
        - delayed_on_off: 50ms

  - platform: gpio
    pin: 
      number: GPIO35 #Interruttore Filtro
      mode: 
        input: true
        pullup: true
      inverted: true
    name: "Interruttore Filtro"
    on_press:
      then:
        - switch.turn_on: relay_2
    on_release: 
      then:
        - switch.turn_off: relay_2
    filters:
        - delayed_on_off: 50ms

  


# ================================================================================================ #
# light
# ================================================================================================ #
light:
  - platform: esp32_rmt_led_strip
    id: led_ww
    rgb_order: GRB
    pin: GPIO20
    num_leds: 1
    rmt_channel: 0
    chipset: ws2812
    name: "on board led"
    internal: True
    # effects:
    #   - pulse:
    #       transition_length: 500ms
    #       update_interval: 500ms

# ================================================================================================ #
# text_sensor
# ================================================================================================ #
text_sensor:
  - platform: version
    hide_timestamp: true
    name: "${friendly_name} ESPHome Versione"
    entity_category: diagnostic

  - platform: wifi_info
    ip_address:
      name: "${friendly_name} IP Address"
      icon: mdi:wifi
      entity_category: diagnostic
    ssid:
      name: "${friendly_name} Connected SSID"
      icon: mdi:wifi-strength-2
      entity_category: diagnostic
  


  

# ================================================================================================ #
# sensor
# ================================================================================================ #
sensor:
  - platform: wifi_signal
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: "diagnostic"

  

  - platform: homeassistant
    id: temp_ambiente
    entity_id: sensor.broadlink_rm4_pro_studio_maxi_temperatura



  
# ================================================================================================ #
# script
# ================================================================================================ #
script:
  - id: led_blink_red
    then:
      - light.turn_on:
          id: led_ww           
          red: 100%
          green: 0%
          blue: 0%
          brightness: 40%
          transition_length: 50ms
          #effect: pulse
      - delay: 1100ms
      - light.turn_off:
          id: led_ww

  - id: led_blink_green
    then:
      - light.turn_on:
          id: led_ww           
          red: 0%
          green: 100%
          blue: 0%
          brightness: 30%
          transition_length: 50ms
          #effect: pulse
      - delay: 1100ms
      - light.turn_off:
          id: led_ww         

# ================================================================================================ #
# interval
# ================================================================================================ #
interval:
  - interval: 3s
    then:
      if:
        condition:
            api.connected:
        then:
          - script.execute: led_blink_green

  - interval: 1.5s
    then:
      if:
        condition:
          not:
            api.connected:
        then:
          - script.execute: led_blink_red   

I hope that someone can/will help me.
Thank you and bye

Your wiring would be important. Diagram please?

yes I’d be interested to see the schematic of the 5V PS.

Sorry, I am not properly understanding your request, could you please explain me what is useful for you? Thank you in advance

I soldered the in/out jumper of the ESP32-S3 to power the ESP32-S3 from the PN 5V and GND. Then I brought the 5V line from the 5V2A power supply to the 5V and GND jumpers of both the esp32 and the two relay boards. Basically all the 5V power is taken from a single 5V-2a power supply (I also tried with a 5V-3A and had the same problems)

We can’t help you unless we know how it is wired. A schematic or wiring diagram.

With this photo you can understand the schematic?

Define “power strip” and “load on sockets”.

1 Like

No i cannot. There are no relays or power supplies or wires.

So your 5V DC supply is cable tied to the mains voltage active? Seperate those for starters - then try again.

There are probably other issues but that’s a start. Like what are the specs of your 5V supply?

Here the schematic, thanks

Quite exotic circuit. One output from Esp triggers 6 relays that switch some unidentified 2-phase AC devices…?

Troubleshooting electrical issues can be hard when the device is right there in front of you. When it is far away, it is extremely important that the person who is close to the device/circuit is extremely precise in their descriptions of what they are doing/done and what they see.

There are MANY reasons why it might not be working (more than there are reasons for it to work the way you want).

Here are some questions that might guide the detective work.

  1. Does the problem occur with any load?
  2. What different loads have you tried?
  3. Try it with a single LED lamp?
  4. Do you have a voltmeter and know how to use it?
  5. Connect the DVM to the 5V circuit and set it to display the minimum voltage. Now reproduce the problem. What is the minimum voltage read by the voltmeter?
  6. What is the exact model of the relay boards you are using? There are several different styles of these and some are not compatible with 3V3 devices.
  7. Exactly how do you have the relay boards hooked up? Your YAML and schematic do not match.
  8. Your wiring choices are less than ideal, with the close routing of high voltage AC and low voltage signals. It might or might not be part of the problem.

Without a proper schematic, we’re just guessing. I assume that the five boxes in your image are outlets, but I have no clue how they are connected.

About the only thing that can do as you describe is a voltage drop on the 5V supply. Use a battery USB power “brick” to power the ESP then see if the problem persists. If the problem goes away with the ESP powered by battery, then there’s your problem.

https://www.iec.ch/world-plugs

Style L
probably Italy

and there are six of them

The problem seems to be determined by the Esp32-S3 which, probably could be “disturbed” by the 220V line.
Using the same configuration as the Stile L sockets, I tried programming an ESP32 and connected it to the same power supply and the same schematic and the six relays all work fine (I turn on and off the aquarium pumps, lights and heater without any problem):
The only thing that doesn’t work, however, is that with an ESP32 I can’t even use lCD ST7796 due to lack of RAM (ESP32’s 4MB is low).
Having identified, then, the problem (ESP32-S3), do you think there is a method to shield it and not make it suffer with interference?
Thanks and ciao

You absolutely need to route the AC wiring separately from Esp wiring (relay signals/display etc).
If you use pumps (or any other inductive load), you need RC-snubbers across relay outputs.

Thanks, LIKE THIS ?

Yes, or maybe this…

I must be doing something wrong because, I’ve always hid those power strips out of sight, under beds, desks, behind the couch, etc… They look cool and all with a nice lcd display like that but, unfortunately once you start using the outlets or use all of them, it seems like those half-dozen power cords would be a huge interference seeing that little screen, especially if the thing is on the floor and pushed back out of the way to not create tripping hazards with all those power cords under feet…

If that’s what you needed and your happy with your project and it works, well that’s all that matters! If it were me, I wouldn’t have combined the power strip with a display and have all those wires up at eye level so you can read the screen…

Maybe it’s just me that thinks it’s odd but, everyone thinks i’m odd for sitting down to pee so, IDK. You did a good job on the build and looks like you really took some pride in what you made so good work!