GPIO2 manual output level very low (DEVKITC)

grantb
Posts: 10
Joined: Thu Oct 18, 2018 9:51 pm

GPIO2 manual output level very low (DEVKITC)

Postby grantb » Thu Oct 18, 2018 10:05 pm

I'm working through the Blink example and it's finally building and loading OK I think. I just have the board alone (no breadboard) and it is powered by USB. There is no other hardware. The Blink example toggles GPIO2 every second by code. I can see the level on my oscilloscope changing about 0.2v but that is all. I thought maybe an internal pullup is needed since I have no LED on that pin. Still only 200mV. Am I configuring the pin correctly? Or must I use an external pullup even to see action on the scope?

Code: Select all

/* 
Can run 'make menuconfig' to choose the GPIO to blink,  or you can edit the following line and set a number here.
*/
#define  BLINK_GPIO  GPIO_NUM_2     // 


void blink_task(void *pvParameter)
{
    /* 
    Configure the IOMUX register for pad BLINK_GPIO (some pads are muxed to GPIO on reset already, but some default to other
    functions and need to be switched to GPIO. Consult the Technical Reference for a list of pads and their default functions.)
    */
    gpio_pad_select_gpio(BLINK_GPIO);

    /* Set the GPIO as a push/pull output */ 
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
    gpio_set_pull_mode(BLINK_GPIO, GPIO_PULLUP_ONLY);

    while(1) 
        {
        /* Blink off (output low) */
        gpio_set_level(BLINK_GPIO, 0);

        vTaskDelay(1000 / portTICK_PERIOD_MS);
        
        /* Blink on (output high) */
        gpio_set_level(BLINK_GPIO, 1);

        vTaskDelay(1000 / portTICK_PERIOD_MS);
        }
}


//void app_main()
extern "C" void app_main(void)
{
xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
}
I can use a different GPIO if #2 is not a good choice. I'm using PlatformIO in Visual Studio Code.

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: GPIO2 manual output level very low (DEVKITC)

Postby ESP_Sprite » Fri Oct 19, 2018 3:09 am

Having a pull-up (or pull-down) on an output (that is not specifically confiugured as open-drain) does not make sense. Suggest you remove the pull-up code and try again; I don't recall the code implementation but it may have the side effect of configuring the GPIO as an input.

grantb
Posts: 10
Joined: Thu Oct 18, 2018 9:51 pm

Re: GPIO2 manual output level very low (DEVKITC)

Postby grantb » Fri Oct 19, 2018 2:42 pm

I wasn't aware of the default configuration so if it was open drain I was going to add an pullup. Otherwise I was going to see what the gpio config functions do. Anyway it appears that by default some other function is controlling that pin and I haven't waded through the fog to see what's going on in the code since it's obviously not just a stub by default (meaning even though I'm only toggling a pin that there is a ton of other stuff going on behind my back whether I need it or not).

Solution for now is I moved to gpio 32 and it works fine. I will go through the pin configurations to see what they really do and then swing back around to see what is going on by default on gpio 2.

raadiy@yahoo.com
Posts: 6
Joined: Sat Oct 06, 2018 1:02 am

Re: GPIO2 manual output level very low (DEVKITC)

Postby raadiy@yahoo.com » Tue Oct 30, 2018 1:13 pm

Hi, I too appear to be having an issue with my esp32s nodemcu board. The blink example works with the inbuilt led on the board, but when I connect an external led, it does not work. I tried with GPIO 32, but no success. Not sure if it is my board at fault. Does anyone have similar issues with the nodemcu esp32s board?

grantb
Posts: 10
Joined: Thu Oct 18, 2018 9:51 pm

Re: GPIO2 manual output level very low (DEVKITC)

Postby grantb » Wed Oct 31, 2018 2:30 pm

Are you sinking current from the supply through the LED to the GPIO? I don't know if there's enough current available to source it through the LED to ground (each case of course with a current limiting resistor).

I need to spend more time looking at the GPIO modes and pullup configuration before I'm able to comment on that. Not all GPIO's are readily available, that much I know. Some may need re-configuration in order to use them.

raadiy@yahoo.com
Posts: 6
Joined: Sat Oct 06, 2018 1:02 am

Re: GPIO2 manual output level very low (DEVKITC)

Postby raadiy@yahoo.com » Wed Oct 31, 2018 3:04 pm

Thanks for your answer Grant. After flashing the "blink", and then seeing that the blue led on the board blinks, as per the example code, I connected the LED to the GPIO-2 PIN, but no luck.
Here is a pin-out of a board which is a likeness of the one I am using. (https://cdn.instructables.com/FE4/P1BY/ ... .LARGE.jpg).
I originally attempted to connect a 7-way relay to the nodemcu board, but when i saw that the GPIO pins - 16 through 23, that I had connected to the relay were'nt working, I decided to test the pins, which is when I realised that not all GPIO pins were "usable".
I then attempted to verify if the board I have has "working" nodemcu GPIO pins. I also googled and saw that not all GPIO pins are usuable, but however GPIO 2 should have worked (i thought)... I do not know how to troubleshoot the board. If it were in the software, I could play around...

grantb
Posts: 10
Joined: Thu Oct 18, 2018 9:51 pm

Re: GPIO2 manual output level very low (DEVKITC)

Postby grantb » Thu Nov 01, 2018 3:15 pm

Yeah this is the problem with not doing bare-metal coding. There is a LOT of other code running on the micro(s). RTOS, etc.

I'm pretty sure GPIO2 is usable, it's just a matter of finding out what code is squatting on it. That's where I didn't have time to investigate. Someone mentioned "unconfig" (or some similar term) to free the pin from it's previous assignment. They also thought it might be the RTC clock but I don't recall for sure. This should be pretty easy to solve because all the modules seem to come up this way so a lot of people must have run into this before. "Should be". I'd like to know the answer too.

raadiy@yahoo.com
Posts: 6
Joined: Sat Oct 06, 2018 1:02 am

Re: GPIO2 manual output level very low (DEVKITC)

Postby raadiy@yahoo.com » Thu Nov 08, 2018 1:36 am

As it turned out, I was using few cables that were faulty. :(
Thanks for looking into this problem.

Who is online

Users browsing this forum: No registered users and 73 guests