Control a ceiling fan using Esphome and NodeMCU but only full speed working, speed 1,2 and 3 are not?

I’ve been following this tutorial… https://youtu.be/AJwdF4L6HNU

Here you’ll find everything that I’ve done…

Why have you opened another thread?

Where is here?

The first thread was about how do I make a fan regulator and second one is I am unable to get control speed, they both are different… follow this link to see what I am using: Fan Speed Control with & without Internet | Blynk | ESP32 Projects - YouTube

We need to see your code. I am not interested in following some youtube video to see it. The video jockey is not even using esphome. You are.

Hey, Thank you so much for your help but the issue is resolved, the error was the wrong connection of Resistors, once I connected them properly according to the circuit diagram it worked like charm. I was aware I had done the mistake in connection and so I was asking you to check the connection… But anyways thank you once again…

You still need to address this unless you want to burn your house down.

Yes I understand, I am not using it on live things, I was just testing things out… Thank You… I will fix it when I go live with real connections.

I hope you will be able to do a write up with your esphome code for the benefit of others. Cheers.

You were so right regarding this… it caught fire during the testing process only… I was trying to make it work using a touch sensor as well as using ESPHome… and all of a sudden the resistor was on fire…

I mean once you have a module that doesn’t catch fire. :slight_smile:

Yes I know that, I was just letting you know what happened… I am ready with code, all I want now is to get stable resistors, which do you think I should go with?

Fan Speed Controller - DIYWiki seems to say 400v for each component, but I saw another site that said 600v.

Hello this is my code to control the fan speed and this works well, but the only problem I am having is when I press the button/sensor it updates but the updated version is not shown in HA Dashboard, how can I link sensors with output.

Thank You.

switch:
  - platform: gpio
    pin: D5
    name: "Master Bedroom Fan Speed Relay 1"
    id: mbedspeed1
  - platform: gpio
    pin: D6
    name: "Master Bedroom Fan Speed Relay 2"
    id: mbedspeed2
  - platform: gpio
    pin: D7
    name: "Master Bedroom Fan Speed Relay 3"
    id: mbedspeed4

binary_sensor:
  - platform: gpio
    pin: D0
    name: 'Turn Off Fan'
    on_click:
      then:
        - switch.turn_off: mbedspeed1
        - switch.turn_off: mbedspeed2
        - switch.turn_off: mbedspeed4

  - platform: gpio
    pin: D1
    name: 'Fan Speed 1'
    on_click:
      then:
        - switch.turn_on: mbedspeed1
        - switch.turn_off: mbedspeed2
        - switch.turn_off: mbedspeed4

  - platform: gpio
    pin: D2
    name: 'Fan Speed 2'
    on_click:
      then:
        - switch.turn_off: mbedspeed1
        - switch.turn_on: mbedspeed2
        - switch.turn_off: mbedspeed4

  - platform: gpio
    pin: D3
    name: 'Fan Speed 3'
    on_click:
      then:
        - switch.turn_on: mbedspeed1
        - switch.turn_on: mbedspeed2
        - switch.turn_off: mbedspeed4
        
  - platform: gpio
    pin: D4
    name: 'Fan Speed 4'
    on_click:
      then:
        - switch.turn_off: mbedspeed1
        - switch.turn_off: mbedspeed2
        - switch.turn_on: mbedspeed4
        
output:
  - platform: template
    id: custom_fan
    type: float 
    write_action:
      - if:
          condition:
            lambda: return ((state == 0));
          then:
            # action for off
            - switch.turn_off: mbedspeed1
            - switch.turn_off: mbedspeed2
            - switch.turn_off: mbedspeed4
      - if:
          condition:
            lambda: return ((state > 0) && (state < 0.3));
          then:
            # action for speed 1
            - switch.turn_on: mbedspeed1
            - switch.turn_off: mbedspeed2
            - switch.turn_off: mbedspeed4
            
      - if:
          condition:
            lambda: return ((state > 0.3) && (state < 0.6));
          then:
            # action for speed 2
            - switch.turn_off: mbedspeed1
            - switch.turn_on: mbedspeed2
            - switch.turn_off: mbedspeed4
      - if:
          condition:
            lambda: return ((state > 0.6) && (state < .9));
          then:
            # action for speed 3
            - switch.turn_on: mbedspeed1
            - switch.turn_on: mbedspeed2
            - switch.turn_off: mbedspeed4
      - if:
          condition:
            lambda: return ((state == 1));
          then:
            # action for speed 4
            - switch.turn_off: mbedspeed1
            - switch.turn_off: mbedspeed2
            - switch.turn_on: mbedspeed4
            
fan:
  - platform: speed
    id: mbedfan
    output: custom_fan
    name: "Master Bedroom Fan"
    speed_count: 4

Hi - Were you able to fix circuit and code?

WTF! Do I see Dupont wires and a breadboard used for mains voltages and currents? The only parts here that are probably rated for that are the capacitors. Shouldn’t this whole thread be removed to save lives?

@Jpsy I have clearly mentioned this is only for testing purposes and doesn’t go into the wall, I have made actual PCBs and stuff to actually support this system, I am well aware using this can easily cause a fire while testing itself one of the resistors caught fire…

It can kill you without fire. The insulations are not rated for high voltages. Others might try to copy that. I do not recommend to show such experiments in public, even if I did them in private. And you did not expect the resistors catching fire yourself. It was not under control and it will not be for others. I am just afraid that we might injure people here.

@hussainimustafa325 - so were you able to take it to the wall with actual pcb or you had to adjust Hw?? i had a look at the youtube and looks like circuit worked for that guy…