Updated circuit: Feedback on the ESP32 circuit (switch debouncing), please?

Hello lovely people,

I'm a software developer by trade and recently got into home automation. After much delibration and (re)searching, I ended up using an ESP32 with A4988 stepper motor controller to control a NEMA 17, that'll drive a timing belt to open/close the curtains.

I made the basic circuit work (using only 2/3 input pins on the A4988 driver) but this is the final version I decided on.

  • I'll use all the input pins on the driver
  • There's a limit switch that'll tell me when the curtain is in open position.
  • Two other push buttons for manual control to turn the circuit on/off
  • An external LED to show the status of the operation at the moment.

The main questions I have for this are:

  1. Am I using the correct GPIO pins from ESP? I came to know that not all ESP pins are created equal. This is the board I'm using. Data Sheet, Internal Schematic. This is the A4988 chip I'm using.
  2. Are the decoupling capacitors placed correctly and with correct capacitance?
  3. I'm planning on using only one power source to power the whole project, am I using the buck converter correctly to power the 5V devices?
  4. The A4988, and other components run off of 3.3V ESP output, is that okay?
  5. The LED, switches, etc I plan to set up using INPUT_PULLUP or INPUT_PULLDOWN and I haven't connected any external ones, is that okay or do I need some 220Ω resisistors?
  6. The ground I read that needs to be common across the circuit, I assume there shouldn't be a problem with connecting the devices directly to the 12V ground if they're being powered 5V power from after the buck conversion?
  7. Any other tips/mistakes?

Thanks a lot!

There's no serial resistor to the IO27 pin. 220 ohm....

1 Like

Hi,
Welcome to the forum.

As you are pulling the digital input pins HIGH when the switches/buttons are closed, you will need a 10K pull down resistor on each of the input pins to make sure the inputs go LOW when the the switches are open.

Tom... :grinning: :+1: :coffee: :australia:

1 Like

Okay, from other replies, it seems that I need to connect the resistors on every I/O components to the ESP. Also found out that I need to add a capacitor to input switches to reduce debouncing.

LED: 220Ω
Switches: 10kΩ and a capacitor for debouncing.

Thanks

Hi,

Only the inputs you use and if they are going to be in an open circuit state at sometime.

Tom... :grinning: :+1: :coffee: :australia:

1 Like

Consider extra filtering on the ESP32 side as the chip is 3.3V and prone to resets with voltage dips. Unless you need the 5V, you may want to go straight to 3.3V and use a quality DC-DC module.

Is there harm in using 5V? Using a single DC-DC converter for 3.3V, wouldn't it cause a drop in current when I connect both ESP and A4988 as they'd be in parallel?

Ah yeah, thanks! I meant the input switches, and the output LED. :smiley:

How do you plan to program this board? You need to bring out TX0, RX0, EN, GPIO0, and GND to a header for a programmer if you plan to program it.

I plan to control the pins via WiFi. The plan is like this:

  1. Have a local server with an API that returns the values on how much the motor has to move and when (if manually)
  2. Connect to Wifi and set up ArduinoOTA for WiFi control.
  3. On setup and every midnight, get the values for the day's sunrise/sunset times and store them in variables
  4. Also call the local API to get the values on how much to move the motor
  5. In the loop, the motor moves when the next_position is different than current_position
  6. Next_position is set by certain rules
    6.1 If the current time is one of the trigger times
    6.2 If I change the values in DB (from the API), I send a signal to the WiFi client of the ESP to get the new values from API
    6.3 If the two push buttons are pressed (single press sets the next_postition to max or min position depending on the button, a long press moves the curtain slowly)
    6.4 If the limit switch is triggered by the curtain opening (manually), I set the current_position to min_position
  7. Depending on the next_position, calculate the number of rotations send the signals to A4988.
  8. Changing the other inputs (sleep, steps, enable) etc is the same. I'll update the DB and send a signal to ESP to get the latest values from the API.

Lemme know if there's any flaw in this. I have tested just a very basic version but haven't implemented it all.

Reread @liuzengqiang's question again, you misunderstood it.

You're right, my bad I didn't. I have been able to program and change the pin configurations from WiFi so far without having to bring out the said pins (TX0, RX0, EN, GPIO0, and GND) to any programmer header. What exactly is that btw, I'm hearing it for the first time?

How do you program your ESP32s now?

Okay I think I now got it. I am not using a direct ESP32, I have a development kit from AZDelivery.de. I am able to program it directly.

Goes to show how new I am when the basic questions go over my head :smiley:

So your ESP32 will be programmed before assembly?

What about later changes? OTA only?

Correct, even now I've put the ESP away from my desktop and I program it from my laptop. I set up the OTA during the initial setup.

If possible I would bring the connections to some header, it doesn't hurt, does it?

Also I'll put the ESP (and A4988) on a connector on the through hole PCB I'll make finally. So I can remove the chips easily as needed.

The ESP is meant to stay near my window near the top of the wall, controlling the curtains

Sorry, I overlooked that you want to use a removable module for the ESP32.