The GPIO-0 button is not working

JainamShah
Posts: 16
Joined: Thu Jul 29, 2021 6:52 am

The GPIO-0 button is not working

Postby JainamShah » Tue Aug 31, 2021 1:21 pm

Hello,
I am working on the basic code for monitoring the state of GPIO0 which is the input button. For printing the state of a button I am using ESP log file. The code is working properly on the console. GPIO0 is active high so on pressing the button it gives the value 0 and in the normal state, it gives 1.

But while I am printing the logs on putty the GPIO0 pin works in Active low mode. Which stops the working of the Button. If I give the 3.3V to the GPIO0 pin it detects.

So, the problem is in the Putty GPIO0 pin is working as active LOW.

Here I am attaching the code.
  1.  
  2. void app_main()
  3. {
  4.     PUSH_BUTTON = 0
  5.     gpio_config_t io_config;
  6.     io_config.pin_bit_mask = 1ULL << PUSH_BUTTON;
  7.     io_config.mode = GPIO_MODE_INPUT;
  8.     io_config.intr_type = GPIO_INTR_DISABLE;
  9.     gpio_config(&io_config);  
  10.     while(1)
  11.     {
  12.         ESP_LOGI(TAG,"%d",gpio_get_level(PUSH_BUTTON));
  13.     }
  14. }
  15.  
I am using GPIO0 pin as input in my main project. And I want to work this on clean pc which doesn't have installed ESP32 IDF. So, I am using PuTTy.

Please help me with this.

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

Re: The GPIO-0 button is not working

Postby ESP_Sprite » Wed Sep 01, 2021 3:31 am

The issue you may have here is that GPIO0 is also a bootstrap pin used to get the chip into bootloader mode. On many devboards, there is an auto-reset circuit that uses the serial ports DSR/DTR to control the the GPIO0 and EN pin of the chip to do this under computer control (as in: when you flash your chip, you don't have to press any buttons to get the chip into flashing mode). My guess is that Putty also sets these control lines in such a state that GPIO0 is pulled low by default. I don't think Putty allows you to change this behaviour.

Solutions would include not using GPIO0 but a different IO pin, or removing the auto-reset circuit from the board. If you can find a terminal emulator that allows you to directly control DTR/DSR, that would also work.

JainamShah
Posts: 16
Joined: Thu Jul 29, 2021 6:52 am

Re: The GPIO-0 button is not working

Postby JainamShah » Wed Sep 01, 2021 5:29 am

Hello ESP_Sprite,
Thanks for the reply.

I have tried other emulators too. like Realterm and Teraterm. They have access to the DSR/DTR. But still, the problem is not solved.
Also, I have given the external supply to the board. At that time the button is working properly. So, I only experienced a problem when I connect the board to the emulator. I have read the GPIO0 pin's boot mode part. But here we are only monitoring the device not flashing or anything else.

Yes, the only solution is to use other GPIOs. But I really want to know what exactly happens here that internally working GPIO changes its state.

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

Re: The GPIO-0 button is not working

Postby ESP_Sprite » Wed Sep 01, 2021 9:46 am

So can you properly use the button when you make DTR and DSR either both high or both low? Also, what hardware (devkit) are you using in the first place?

JainamShah
Posts: 16
Joined: Thu Jul 29, 2021 6:52 am

Re: The GPIO-0 button is not working

Postby JainamShah » Wed Sep 01, 2021 10:58 am

When I am printing the logs in any emulator, Pressing the button connects the ground to the 0th pin. Unfortunately, the GPIO0 is in the active low state so the functionality of the button is stopped.
Also, I have tried both cases when DSR\DTR is set and not set.
I am using ESP32-WROOM-32D version-4 board.

Who is online

Users browsing this forum: Google [Bot] and 50 guests