ESP32 servos uncontrolled movement during upload

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
TPP
New user
Posts: 2
Joined: 19 Mar 2023, 15:15

ESP32 servos uncontrolled movement during upload

#1 Post by TPP » 19 Mar 2023, 15:36

I use ESP32 to run servos. Always during upload the servos have uncontrolled movments (connected to GPIOs), so I desided to use an relais, to switch the power supply of the servos on, during setup routine of code, so during upload the servos have no power, so I avoid the uncontroled movements. So I wrote a simple Arduino code, that switches the relais (an Arduino modul on a small pcb) on high during 5sec, then off, only for test.
When I upload the first time the code to the ESP32, relais is off during upload, then 3sec on, then off, exactly as expected.
When I upload again, then the relais is on for 1sec during upload, and then 3sec during execution of setup routine.
Same happens again with 3rd upload.
I also tried with a pulldown 47kohm in the signal line of the relais, same result. I also tried all GPIOs, knowing that some are not recommended for, but didn‘t any, that worked as expected.

My target is, that relais during upload never is on, only when I controll it by my code.
Has somebody a solution for me?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESP32 servos uncontrolled movement during upload

#2 Post by Ath » 19 Mar 2023, 16:36

This forum is about ESPEasy, an Arduino-based firmware for ESP8266 and ESP32 that offers quite a lot of functionality out of the box, not for generic Arduino questions.

You could try to use ESPEasy to control your servos and relay, but the most import issue seems to be that you are using GPIO pins that are used during boot of the ESP. Checking for GPIOs that are safe to used, and/or have a defined state during boot would be the best solution here. Check out this documentation for what GPIOs to avoid.
/Ton (PayPal.me)

TPP
New user
Posts: 2
Joined: 19 Mar 2023, 15:15

Re: ESP32 servos uncontrolled movement during upload

#3 Post by TPP » 19 Mar 2023, 17:52

Thanks for the hint. But this I was already aware, and it happens for example also with GPIO21 (totally uncritical pin). I have the impression, since only the first time it runs correct, something will be stored in the ESP32, that leads to the different behavior with the second run, and I hoped there is a way to tell the device during the upload, how the ESP32 should behave (equal to the first run), the problem could be fixed. But I am not aware if such a possibility exist and if so, how to handle it.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32 servos uncontrolled movement during upload

#4 Post by TD-er » 19 Mar 2023, 21:57

You can store some values in RTC memory which will be kept as long as the unit remains powered.
This can be useful to detect whether you're starting from a cold boot or warm boot.

It is also possible your pins are not fully reset during boot.

But as Ton also mentioned, this is a support forum for ESPEasy, not about generic Arduino programming issues.

bidrohini
Normal user
Posts: 101
Joined: 03 Nov 2022, 16:24

Re: ESP32 servos uncontrolled movement during upload

#5 Post by bidrohini » 20 Mar 2023, 08:22

It sounds like the GPIO pin you are using to control the relay may be in an undefined state during the upload process, causing the relay to turn on briefly. One solution you could try is to configure the GPIO pin as an output and set it to a known state (e.g. low) before starting the upload process.

By the way, since you are using servo motor, I think its better to use a servo controller instead of a relay. You can buy or design one like this:

https://www.pcbway.com/project/sharepro ... e221b.html

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32 servos uncontrolled movement during upload

#6 Post by TD-er » 20 Mar 2023, 09:38

Interesting board. I did expect it to have a PWM chip, but it looks like it is only using ESP32 GPIO pins.
Anyway, the topicstarter can have a look to see which pins are apparently good to use for a servo.


N.B. The ESP32 can also be configured to have some pins locked at a specific state during sleep or reboot.
But you need to use low-level commands from the IDF SDK (not Arduino) to set these.
It can also result in higher stand-by currents if you want to use deep-sleep.

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests