ESP32 crashes with Micropython with simple test program

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Expert
Posts: 10
Joined: Mon Sep 30, 2019 12:16 pm
Contact:

ESP32 crashes with Micropython with simple test program

Post by Expert » Fri Oct 11, 2019 11:23 am

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)

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 crashes with Micropython with simple test program

Post by Roberthh » Fri Oct 11, 2019 11:34 am

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?

User avatar
ghayne
Posts: 42
Joined: Sat Jun 08, 2019 9:31 am
Location: Cwmllynfell, Wales

Re: ESP32 crashes with Micropython with simple test program

Post by ghayne » Fri Oct 11, 2019 11:40 am

+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.

Expert
Posts: 10
Joined: Mon Sep 30, 2019 12:16 pm
Contact:

Re: ESP32 crashes with Micropython with simple test program

Post by Expert » Fri Oct 11, 2019 1:08 pm

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.

Expert
Posts: 10
Joined: Mon Sep 30, 2019 12:16 pm
Contact:

Re: ESP32 crashes with Micropython with simple test program

Post by Expert » Fri Oct 11, 2019 1:16 pm

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.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 crashes with Micropython with simple test program

Post by Roberthh » Fri Oct 11, 2019 1:21 pm

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.

Expert
Posts: 10
Joined: Mon Sep 30, 2019 12:16 pm
Contact:

Re: ESP32 crashes with Micropython with simple test program

Post by Expert » Fri Oct 11, 2019 5:29 pm

Is this a reliable board, in your opinion, to use in a production environment?

Expert
Posts: 10
Joined: Mon Sep 30, 2019 12:16 pm
Contact:

Re: ESP32 crashes with Micropython with simple test program

Post by Expert » Fri Oct 11, 2019 10:32 pm

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?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP32 crashes with Micropython with simple test program

Post by Roberthh » Sat Oct 12, 2019 6:34 am

Blame it to that hub. I'm running my devices from a powered hub w/o problems.

amudhan
Posts: 1
Joined: Sun Oct 13, 2019 8:27 am

Re: ESP32 crashes with Micropython with simple test program

Post by amudhan » Sun Oct 13, 2019 8:31 am

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.

Post Reply