Issues blinking ESP32 onboard LED

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
oserror
Posts: 43
Joined: Tue Feb 12, 2019 12:26 am

Issues blinking ESP32 onboard LED

Post by oserror » Tue Feb 12, 2019 12:36 am

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!

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Issues blinking ESP32 onboard LED

Post by OutoftheBOTS_ » Tue Feb 12, 2019 4:48 am

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.

User avatar
oserror
Posts: 43
Joined: Tue Feb 12, 2019 12:26 am

Re: Issues blinking ESP32 onboard LED

Post by oserror » Tue Feb 12, 2019 3:31 pm

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.

User avatar
oserror
Posts: 43
Joined: Tue Feb 12, 2019 12:26 am

Re: Issues blinking ESP32 onboard LED

Post by oserror » Tue Feb 12, 2019 4:42 pm

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.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Issues blinking ESP32 onboard LED

Post by OutoftheBOTS_ » Tue Feb 12, 2019 9:37 pm

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

seb77
Posts: 1
Joined: Fri May 03, 2019 9:16 am

Re: Issues blinking ESP32 onboard LED

Post by seb77 » Fri May 03, 2019 9:22 am

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()

tbalci
Posts: 1
Joined: Thu Oct 21, 2021 7:02 pm

Re: Issues blinking ESP32 onboard LED

Post by tbalci » Thu Oct 21, 2021 7:13 pm

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.

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

Re: Issues blinking ESP32 onboard LED

Post by Roberthh » Thu Oct 21, 2021 7:23 pm

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.

Post Reply