Esp32-c3 super mini problem

Hi
I am using esp32-c3 super mini
Is this board name right ? (esp32-c3-devkitm-1)
Want to open parking door , parking door board have 4 pin (com,up,down,stop)(if you short connect com to up = door go up)
This code not working at all… , can someone help pls? ty…

GPIO21 => connected to Up
Gnd => connected to Com

esphome:
  name: esphome-web-66cc9c
  friendly_name: esphome-web-66cc9c

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "UfQ+xxxxxxxxxxxxxxxxxxxxxxx="

ota:
  - platform: esphome
    password: "xxxxxxxxxxxxxxxxx"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-66Cc9C"
    password: "xxxxxxxx"

captive_portal:

switch:
  - platform: gpio
    pin: 
      number: GPIO21
      inverted: true
      mode:
        output: True
        open_drain: True
    name: "Parking Door Open Switch"
    id: open_switch
    icon: "mdi:gate"
    on_turn_on:
    - delay: 300ms
    - switch.turn_off: open_switch
  - platform: gpio
    pin: 
      number: GPIO20
      inverted: true
      mode:
        output: True
        open_drain: True
    name: "Parking Door Close Switch"
    id: close_switch
    icon: "mdi:gate"
    on_turn_on:
    - delay: 300ms
    - switch.turn_off: close_switch
  - platform: gpio
    pin: 
      number: GPIO10
      inverted: true
      mode:
        output: True
        open_drain: True
    name: "Parking Door stop Switch"
    id: stop_switch
    icon: "mdi:gate"
    on_turn_on:
    - delay: 300ms
    - switch.turn_off: stop_switch
cover:
  - platform: template
    name: "Parking Door"
    open_action:
      # Cancel any previous action
      - switch.turn_off: close_switch
      # Turn the OPEN switch on briefly
      - switch.turn_on: open_switch
      - delay: 0.1s
      - switch.turn_off: open_switch
    close_action:
      - switch.turn_off: open_switch
      - switch.turn_on: close_switch
      - delay: 0.1s
      - switch.turn_off: close_switch
    stop_action:
      - switch.turn_off: close_switch
      - switch.turn_on: stop_switch
      - delay: 0.1s
      - switch.turn_off: stop_switch
    optimistic: true
    assumed_state: true

Also tested this simple aurdino code (before started working on esphome)(its working)

#define DOOR_PIN 21 
#define CABLE_UP_PIN 2  
#define CABLE_DOWN_PIN 3 
int state1 = 1;

void setup() {
  pinMode(DOOR_PIN, OUTPUT);
  //pinMode(CABLE_UP_PIN, INPUT);
  //pinMode(CABLE_DOWN_PIN, INPUT); 
  digitalWrite(DOOR_PIN, LOW);
  Serial.begin(9600); 
}

void loop() {
    Serial.write("up-high\n");
    digitalWrite(DOOR_PIN, HIGH);
    delay(100);
    digitalWrite(DOOR_PIN, LOW);
  delay(5000); 
}

photo_2024-11-15_17-27-23

Why you want to use GPIO20/21 for that, they are default UART0 pins.

1 Like

Who cares? He’s not using the UART and if he does, the RX/TX can be assigned to any pin you like.

1 Like

I care. When trying to resolve unknown problems with “not so common” board, I prefer to use pins that are not default specific pins. Just a habit for me.
I don’t know how logger component plays with those pins for example…

2 Likes

This seems like an unusually short time. Can you increase that to 1s for testing?

1 Like

I do. The C3 uses the USB UART by default for logging so UART0 is unused unless specifically configured.

3 Likes

Good.
I told my general opinion for debugging.

Update:
This arduino code working fine.
pinmode must be changed from output to input


#define DOOR_PIN 3 
void setup() {
}

void loop() {
   pinMode(DOOR_PIN, OUTPUT);
    digitalWrite(DOOR_PIN, HIGH);
    delay(500);
    digitalWrite(DOOR_PIN, LOW); 
    pinMode(DOOR_PIN, INPUT);
  }
  
  delay(3000);
}

That code doesn’t make any sense with the previous posts.
You are triggering high instead of low.

In my parking board , there is no need of high or low i think , only simple short from ground to pin = action.
state high = action.
state low = action.
only if i switch to input its remove short effect.

That can’t be done with: digitalWrite(DOOR_PIN, HIGH);

Yes i think that is Demonstrative…!
digitalWrite(DOOR_PIN, HIGH or low…);

Changing the pinmode form input to output do the trick.

I disagree. When you change the pin from high impedance state to output and set it high, you feed 3.3V to your pin.