Resetting esp32

train001
Posts: 8
Joined: Thu Jan 21, 2021 4:29 pm
Location: Nottingham ish

Resetting esp32

Postby train001 » Thu Jan 21, 2021 4:39 pm

I have what I think is the minimal circuit to run a motor off a battery using a esp32 on wifi. I suppose I could eliminate the charging board for the lifepo4, but I don;t think it makes any difference. I have the esp32 (wemos mini d1, but same happens with nodemcu) serving a web page with faster/slower buttons and all that seems fine, it gives the right feedback and the response of the motor is as expected.

When I set it to run faster it just stops. I get a boot message and it starts again and works fine again until I turn up the speed.

What I don't understand is I thought the idea of the motor controller was to avoid these things interacting, ie the motor can draw power from it's battery, and same for the esp32. But it seems the more the motor draws the more likely the esp to reset.

I'm a decent enough programmer, but it's the hardware side I'm struggling with. I have seen advice about putting capacitors across the power input to the esp32. I might try that at some point it seems I would need two capacitors a 104 and a larger one. And some people mention a Schottky diode. I'd rather get it right first time :)

Any help appreciated.

Rob
Attachments
curcuit diagram.jpg
curcuit diagram.jpg (107.09 KiB) Viewed 8594 times

chegewara
Posts: 2362
Joined: Wed Jun 14, 2017 9:00 pm

Re: Resetting esp32

Postby chegewara » Thu Jan 21, 2021 5:43 pm

You didnt post any logs, but is there printed by any chance log like this one?

Code: Select all

Brownout detector was triggered

becorey
Posts: 92
Joined: Sat Mar 28, 2020 4:18 pm

Re: Resetting esp32

Postby becorey » Fri Jan 22, 2021 7:58 am

The motor and esp each have their own battery, but GND is connected. The motor is inductive, from a changing load or speed it can dip or spike it's power supply. Perhaps it is dumping energy into GND which raises it's potential, decreases the gap between GND and vdd giving you temporary low voltage.
Definitely look for the brownout detector as chegewara mentioned, that is the clearest indicator the esp saw low voltage and panicked.
If you have a scope, probe what your 3.3v to the esp is doing.

Usually things with motors like power tools have pretty large caps across the motor terminals, over 100uF electrolytic. 104 (0.1uF) is tiny.

It also helps to have bypass caps near the esp32, ideally one .1uF and one 1uF, close as possible to the vdd pins.

You could also do something like an optoisolator for your pwm signals so that the motor and esp circuit are truly isolated.

train001
Posts: 8
Joined: Thu Jan 21, 2021 4:29 pm
Location: Nottingham ish

Re: Resetting esp32

Postby train001 » Fri Jan 22, 2021 9:35 am

I did expect to see the brownout message, but it is not there. So I am not really sure why it resets. I think it reboots twice, and then works. I am very new to this. I've broken a couple by forgetting to disconnect the usb when I put a 9v battery on v5.0 (hopefully I am getting wiser :) ).

I am away from this for today, but will put the logs up when I get back to it. At first it was gibberish until I realised there must be a default baud rate and used that for my serial message, so I could see the error. Living and learning :)

The previous message look like useful things to pursue. I think as I'm running it on v3.3 there is little leeway. Having said that it does it on usb too, and if I put 9v in the v5.0 pin.

I have some bigger capacitors to try.

I assume isolating the grounds would be a bad idea?

Ideally I would run the whole thing off one lipo battery, but I do like the idea that the lifepo4 is always in the voltage range for the v3.3 pin.

train001
Posts: 8
Joined: Thu Jan 21, 2021 4:29 pm
Location: Nottingham ish

Re: Resetting esp32

Postby train001 » Fri Jan 22, 2021 10:20 am

Just to clarify the motor is a 0 - 6v "high torque" motor. It is in a garden railway loco and the standard set up for the kit would just be an on/off switch giving 3v. So it is not a big motor.

Another thought. Could it be the mini motor controller is not as well behaved as a bigger one? I have a bigger one with heat sink etc, and if memory serve this had the same fault early on. Apologies, I have tried a few things starting with it all on a breadboard with a nodemcu and now it is installed in a loco with a d1 and different batteries and different motor controller. None of the configurations have been free of this problem, so I clearly misunderstand something.

becorey
Posts: 92
Joined: Sat Mar 28, 2020 4:18 pm

Re: Resetting esp32

Postby becorey » Sat Jan 23, 2021 2:51 am

You need a bulk cap for the motor V+ supply, try that first. If you look at the L298N datasheet pg 8, it shows a 470uF cap.
And in this article, the module he's using has a 220uF cap for each motor. https://lastminuteengineers.com/l298n-d ... -tutorial/

A larger motor controller would allow for higher sustained current, running a larger motor. If high current / heat dissipation is not your issue, a larger motor driver probably wouldn't address it.

train001
Posts: 8
Joined: Thu Jan 21, 2021 4:29 pm
Location: Nottingham ish

Re: Resetting esp32

Postby train001 » Sat Jan 23, 2021 6:42 pm

Hi Becorey. I didn't understand.

My motor should go in both directions, do I put the capacitor on the input to the motor controller, or can I get a big enough one to go on the motor which does not have polarity? The diddy one across the motor terminals is to reduce noise, I'm not expecting it to smooth the load, sorry I should have been clearer about that. Again I don't know if that is necessary or the right way to address that problem. It is all stuffed into quite a small space and I don't know if noise from the motor could even cause a microprocessor to reset.

The link did not mention a capacitor (although it was very interesting). Was that the right url?

Rob

train001
Posts: 8
Joined: Thu Jan 21, 2021 4:29 pm
Location: Nottingham ish

Re: Resetting esp32

Postby train001 » Sat Jan 23, 2021 6:55 pm

Here are the reset codes, mixed in with a few message of my own to try and see what is going on
  1. v100
  2. message incoming v100
  3. sent the data
  4. ets Jun  8 2016 00:22:57
  5.  
  6. rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  7. configsip: 0, SPIWP:0xee
  8. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  9. mode:DIO, clock div:1
  10. load:0x3fff0018,len:4
  11. load:0x3fff001c,len:1044
  12. load:0x40078000,len:8896
  13. load:0x40080400,len:5816
  14. entry 0x400806ac
  15. ets Jun  8 2016 00:22:57
  16.  
  17. rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  18. configsip: 0, SPIWP:0xee
  19. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  20. mode:DIO, clock div:1
  21. load:0x3fff0018,len:4
  22. load:0x3fff001c,len:1044
  23. load:0x40078000,len:8896
  24. load:0x40080400,len:5816
  25. entry 0x400806ac
  26. 6
  27. 0
  28. 0
  29. 0
  30. 0
  31. 0
  32. 0
  33. 0
  34. 0
  35. 0
  36. server is:
  37. 192.168.1.17

becorey
Posts: 92
Joined: Sat Mar 28, 2020 4:18 pm

Re: Resetting esp32

Postby becorey » Mon Jan 25, 2021 6:29 am

Yes, put the bulk cap on the input to the motor driver. Electrolytic caps have polarity and also tons of capacitance in small space. Think of the motor driver as just redirecting the input DC voltage to the positive or negative motor terminal to control direction (and also pwm to control speed). So a cap across the motor terminals would see flipping polarity. But a cap from the VCC driver supply to GND will always have the same polarity applied.

The article doesn't talk about the cap but it had a good photo of the board, that's why I linked it, but it doesn't directly talk about the bulk capacitance issue.

train001
Posts: 8
Joined: Thu Jan 21, 2021 4:29 pm
Location: Nottingham ish

Re: Resetting esp32

Postby train001 » Mon Jan 25, 2021 1:56 pm

OK. I now understand there is a capacitor on each type of l298n I have used. The one I have been using is 100 and the other with the heatsink has bigger capacitors.

I now wonder if this is why the motor can run fast for a bit, perhaps during that time the capacitor on the motor controller discharges, and then it starts drawing current from the esp32 power source.

I can put a bigger capacitor on the power supply of the controller, I'll post results here.

Who is online

Users browsing this forum: No registered users and 99 guests