ESP32 crashes with Micropython with simple test program
Posted: 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:
Desktop script:
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)
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)