-1
\$\begingroup\$

I got a Lolin S2 mini development board, featuring an ESP32 S2.

We're building a follow-me robot. The DC motors are controlled by this motorshield via I2C.

The motorshield requires a modified library.

The GitHub repo of our project is here.

Now to my problem:

The robot works fine when connected via USB to the computer sending serial data, but when I run the robot off a battery, I get sporadic freezes.

I can't easily debug the robot without a serial interface (I'm a noob, don't have debugging hardware,) but by turning an LED on/off at different times during execution I narrowed the freeze down to the setMotor() call to the modified library.

My question(s):

How can the USB serial connection influence the behavior of the ESP? Maybe it's a power issue? Maybe the serial connection interrupts something with the I2C communication between the ESP and the motor shield? How can I go about debugging this?

EDIT: I'm using the Wemos Battery shield to supply 5V 1A to the board, using a 4.2V lipo. The motordriver is supplied by the battery directly. All the boards just stack together, I didn't add any other relevant circuitry.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Since you suspect a power issue, what is the battery voltage? How are you powering the module? Did you put a diode to prevent the battery from powering VBUS and frying the computer's USB port? This question needs more schematics ;) \$\endgroup\$
    – bobflux
    Jun 28, 2022 at 11:02
  • \$\begingroup\$ Thank you for the reply, I added some additional information to the post. I don't have a diode between vbus and the computer, is that actually necessary? \$\endgroup\$
    – nikscha
    Jun 28, 2022 at 17:16
  • \$\begingroup\$ So, a boost to make 5V from the battery... To eliminate any influence from the PC, and only focus on power, can you test while ESP32 is not powered by the battery and boost, but instead by a USB powerbank, or a cellphone charger, basically anything that outputs 5V. You should also probe the battery voltage with a scope, check if it dips when the motor starts. You can do that on USB power, so it doesn't crash, the goal is to check how low the battery drops when the motor starts. \$\endgroup\$
    – bobflux
    Jun 28, 2022 at 18:33
  • \$\begingroup\$ Another possibility would be the motor current running through the GND traces on your boards instead of going through the wires. So I wonder how it's all wired together. \$\endgroup\$
    – bobflux
    Jun 28, 2022 at 18:38
  • \$\begingroup\$ Please check the power requirement of your motor shield. \$\endgroup\$
    – liaifat85
    Nov 13, 2023 at 12:26

2 Answers 2

0
\$\begingroup\$

you're going to have to figure this our by trying different things, eg: disconnect the USB data lines and leave only the USB power lines, see what happens. try same with only the USB ground line remaining, etc...

\$\endgroup\$
0
\$\begingroup\$

Remove any while(!Serial) you could have anywhere in your code. I've seen many examples with this loop, to wait for the Serial connection to be ready. If there is no serial connection, it will loop forever.

\$\endgroup\$
1
  • \$\begingroup\$ Could you edit your answer and explain why that would help? \$\endgroup\$ Nov 9, 2023 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.