The below is with MicroPython 1.10 stable.
This locks up my ESP32 from AZDelivery (found on USA Amazon.com)
>>> from machine import Pin
>>> led = Pin(1, Pin.OUT, 1)
as well as this:
>>> from machine import Pin
>>> led = Pin(1, Pin.OUT)
In both cases, the LED lights solid blue and stays lit, but the machine is unresponsive and has to be either reset or disconnected.
I have successfully run the Arduino blink sketch so I know this must be some MicroPython issue. The LED seems to be used for activity in Micropython.
My main sketch runs well, using uasyncio and uselect. I am even having luck with asynchronous generators! It's been a duct tape and bail out the boat situation, and I'll post further on that when I have the chance -- I have some questions there. Still, I'm learning and I'm really enjoying it.
I'd just like to be able to control the only LED on the board. Otherwise, I'm fairly impressed at the difference from my ESP8266 boards.
I've been looking pretty hard for the solution to this issue but I haven't found anything yet. I'm sure it's just a simple thing.
Any help would be greatly appreciated!
Thanks!
Issues blinking ESP32 onboard LED
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: Issues blinking ESP32 onboard LED
GPIO1 is the TXD0 pin on the UART serial used by the REPL it can't be used for anything else with MP
It the LED is connected to it then it should flash when ever data is being sent to the serial terminal.
It the LED is connected to it then it should flash when ever data is being sent to the serial terminal.
Re: Issues blinking ESP32 onboard LED
I've been trying to change the REPL ports but so far no luck. I saw this issue on GitHub:
https://github.com/micropython/micropyt ... issues/158
It seems relevant. I tried these settings in sdkconfig.h
#define CONFIG_CONSOLE_UART_CUSTOM 2
#define CONFIG_CONSOLE_UART_CUSTOM_NUM 0
#define CONFIG_CONSOLE_UART_TX_GPIO 17
#define CONFIG_CONSOLE_UART_RX_GPIO 5
I got the firmware compiled. I didn't manage to get a REPL prompt afterward. Perhaps I need to change something else in the code?
It seems that there might also be a solution with uos.dupterm() but I wasn't successful with this path either.
It seems like there might be a way to do this. I don't mind trying -- I just need a little guidance.
https://github.com/micropython/micropyt ... issues/158
It seems relevant. I tried these settings in sdkconfig.h
#define CONFIG_CONSOLE_UART_CUSTOM 2
#define CONFIG_CONSOLE_UART_CUSTOM_NUM 0
#define CONFIG_CONSOLE_UART_TX_GPIO 17
#define CONFIG_CONSOLE_UART_RX_GPIO 5
I got the firmware compiled. I didn't manage to get a REPL prompt afterward. Perhaps I need to change something else in the code?
It seems that there might also be a solution with uos.dupterm() but I wasn't successful with this path either.
It seems like there might be a way to do this. I don't mind trying -- I just need a little guidance.
Re: Issues blinking ESP32 onboard LED
Okay, the last post is still being approved.
I managed to get the LED to work by setting this in sdkconfig.h:
#define CONFIG_CONSOLE_UART_CUSTOM 17
#define CONFIG_CONSOLE_UART_CUSTOM_NUM_0 16
#define CONFIG_CONSOLE_UART_TX_GPIO 17
#define CONFIG_CONSOLE_UART_RX_GPIO 16
I then had to hook up with a USB-UART device (I may have called it by the wrong name) to those pins. REPL worked fine.
It's not exactly practical since it's tedious for me to connect the wires by hand (I'm not as young as I used to be). But it works.
I'm not saying this is solved. Is there some other way I could do this while retaining the REPL on pins 0 and 1? I have a feeling that I might have an issue with just this particular board. I can try with a breadboard, I suppose. I'm not very good with those but I think I have enough jumper wires to do it.
Thanks again for any input. Also, thank you to @OutoftheBOTS_ whose comment pointed me in the right direction.
I managed to get the LED to work by setting this in sdkconfig.h:
#define CONFIG_CONSOLE_UART_CUSTOM 17
#define CONFIG_CONSOLE_UART_CUSTOM_NUM_0 16
#define CONFIG_CONSOLE_UART_TX_GPIO 17
#define CONFIG_CONSOLE_UART_RX_GPIO 16
I then had to hook up with a USB-UART device (I may have called it by the wrong name) to those pins. REPL worked fine.
It's not exactly practical since it's tedious for me to connect the wires by hand (I'm not as young as I used to be). But it works.
I'm not saying this is solved. Is there some other way I could do this while retaining the REPL on pins 0 and 1? I have a feeling that I might have an issue with just this particular board. I can try with a breadboard, I suppose. I'm not very good with those but I think I have enough jumper wires to do it.
Thanks again for any input. Also, thank you to @OutoftheBOTS_ whose comment pointed me in the right direction.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: Issues blinking ESP32 onboard LED
Well u can't use that pin for both a UART and a general GPIO at the same time it is either 1 of the other. I would assume that the blue LED is connected to that pin for the purpose of seeing that your serial port is transmitting not for the purpose of using it as a general LED.
If your really need to use this board and have an LED rather than reroute the REPL to a different UART then connect a UART to USB converter to connect to your PC why don't u just connect an LED to another pin. Just get an LED and solder the correct size resistor to 1 end then connect it across the new pin and gnd. The pin should be able to otuput enough current to light a small LED
If your really need to use this board and have an LED rather than reroute the REPL to a different UART then connect a UART to USB converter to connect to your PC why don't u just connect an LED to another pin. Just get an LED and solder the correct size resistor to 1 end then connect it across the new pin and gnd. The pin should be able to otuput enough current to light a small LED
Re: Issues blinking ESP32 onboard LED
Hi,
I am using ESP32 WROOM DEVKIT v1.
The blue led is on GPIO2 and turning it on and off in MP goes sth like this (it works
):
>>> from machine import Pin
>>> led = Pin(2, Pin.OUT)
>>> led.on()
>>> led.value()
1
>>> led.off()
I am using ESP32 WROOM DEVKIT v1.
The blue led is on GPIO2 and turning it on and off in MP goes sth like this (it works

>>> from machine import Pin
>>> led = Pin(2, Pin.OUT)
>>> led.on()
>>> led.value()
1
>>> led.off()
Re: Issues blinking ESP32 onboard LED
From the Problem Solving with Python Forum, I learned that the ON value is 0 and the OFF value is 1, which frankly I find to be counter-intuitive.
To be honest, that was counter-intuitive for me; I would expect the ON value to be 1. But that also explained why machine.Pin(2, machine.Pin.OUT) was setting the built-in LED to ON.
I spend about an hour figuring this out. I hope this explanation helps people like me.
To be honest, that was counter-intuitive for me; I would expect the ON value to be 1. But that also explained why machine.Pin(2, machine.Pin.OUT) was setting the built-in LED to ON.
I spend about an hour figuring this out. I hope this explanation helps people like me.
Re: Issues blinking ESP32 onboard LED
There is the Signal class and an abstraction on top of Pin. It allows to declare, wehter the logic is straight or inverted. In case of the on-board LED, you have an inverted logic. When using that, ON switched the LED on.