Page 1 of 1

ESP32 crashes with Micropython with simple test program

Posted: Fri Oct 11, 2019 11:23 am
by Expert
I made a very simple program to test my Espressif ESP32 Vroom32. The board is flashed with 10/9/19 Micropython release. I have it plugged into a Windows10 computer running Python 3.7. The board is connected to the computer via USB. It seems to eventually lose communication with the computer. The LED still blinks after this happens. The board seems to be very picky when it comes to USB cables. I am using the same cables that I use with my Arduinos without issue. I sometimes have to plug a cable into the ESP32 several times before the device manager will recognize the device as working. I have ordered new high-end cables just in case that is the problem.

main.py:

Code: Select all

from time import sleep
from machine import Pin
n = 0
led = Pin(2, Pin.OUT)
while 1:        
    print(n)        
    n += 1
    led.value(not led.value())
    sleep(0.2)
Desktop script:

Code: Select all

import serial, serial.tools.list_ports
import time

def find_port():  #Finds which port the arduino is plugged into
    ports = list(serial.tools.list_ports.comports())
    for p in ports:
        if "EA60" in p[2]:
            return(p[0])
usbport = find_port()
ser = serial.Serial(usbport, 115200) #setup serial
while 1:      
    try:  
        data = ser.readline()
        ser.flushInput()
        data = data.strip().decode()
        print(data) 
        time.sleep(0.02)
    except Exception as e:
        print(e)

Re: ESP32 crashes with Micropython with simple test program

Posted: Fri Oct 11, 2019 11:34 am
by Roberthh
It could indeed be a power problem caused by a bad cable. The ESP32 Wroom consumes a little bit more current than an Arduino, but not exceptionally much. Only like 100mA, that nay proper cable should be able to deliver.
Do you ever see a message coming from the board? Did you try to connect a terminal emulator like Putty?

Re: ESP32 crashes with Micropython with simple test program

Posted: Fri Oct 11, 2019 11:40 am
by ghayne
+1 for the supply problem. I have an ESP32 module here that refuses to run off a normal USB socket on my laptop. If I use an adapter attached to the USB C socket it works fine.

Re: ESP32 crashes with Micropython with simple test program

Posted: Fri Oct 11, 2019 1:08 pm
by Expert
Thanks for the quick replies. I am running on putty now just to see it I get error messages. I should also mention that I am using a powered USB hub. I also ordered better cables. I am testing the board for possible use in a production environment and constant polling of both analog and digital pins are required. The crashing makes me a little nervous about doing this.

Re: ESP32 crashes with Micropython with simple test program

Posted: Fri Oct 11, 2019 1:16 pm
by Expert
I did get this warning with Putty:

W (610) cpu_start: Chip revision is higher than the one configured in menuconfig . Suggest to upgrade it.

Re: ESP32 crashes with Micropython with simple test program

Posted: Fri Oct 11, 2019 1:21 pm
by Roberthh
You can ignore this warning. It is just a hint.
b.t.w.: if the led kept blinking, then the board still worked, only the communication had a problem.

Re: ESP32 crashes with Micropython with simple test program

Posted: Fri Oct 11, 2019 5:29 pm
by Expert
Is this a reliable board, in your opinion, to use in a production environment?

Re: ESP32 crashes with Micropython with simple test program

Posted: Fri Oct 11, 2019 10:32 pm
by Expert
I just got a shipment of an ESP8266. I was having the same issues with power. I plugged the 8266 directly into my computer's USB port and it seemed to fix the problem. I did the same with the ESP32 and it also worked fine. Why would the ESP's behave in this manner when plugged into the powered hub?

Re: ESP32 crashes with Micropython with simple test program

Posted: Sat Oct 12, 2019 6:34 am
by Roberthh
Blame it to that hub. I'm running my devices from a powered hub w/o problems.

Re: ESP32 crashes with Micropython with simple test program

Posted: Sun Oct 13, 2019 8:31 am
by amudhan
I too am a newbie in this. But what I can tell about this issue is that, whenever i have a set of code in Main.py file, my esp32 becomes inaccessible. I have to flash it again to gain control over it. What i do is that i type my code to a different file name and import them in the repl whenever i need to test the code.