Why are GPIOs 34 and 35 always LOW ?

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Why are GPIOs 34 and 35 always LOW ?

Postby GeorgeFlorian1 » Mon Jul 19, 2021 1:32 pm

I have a WROVER-B and I am trying to use GPIO32,33,34 and 35 as buttons. So when I press the button, it should put the pin to LOW.

The problem is that GPIO 34 and 35 are always LOW.

Code: Select all

#define RST_BUTTON 33
#define Input_1 32
#define Input_2 34
#define Input_3 35

 pinMode(RST_BUTTON, INPUT);
  pinMode(Input_1, INPUT);
  pinMode(Input_2, INPUT);
  pinMode(Input_3, INPUT);
  delay(50);

  digitalWrite(RST_BUTTON, HIGH);
  digitalWrite(Input_1, HIGH);
  digitalWrite(Input_2, HIGH);
  digitalWrite(Input_3, HIGH);
  delay(50);
GPIO 32 and 33 act correctly (go LOW only when being pressed) but GPIO 34 and 35 are always LOW even though they aren't being pressed.

I did connect external Pull-up resistors to 34 and 35. They are still always LOW.

Why ?
Last edited by GeorgeFlorian1 on Tue Jul 20, 2021 11:14 am, edited 1 time in total.

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

Re: Why are GPIOs 34 and 35 always LOW ?

Postby pipi61 » Mon Jul 19, 2021 2:14 pm

Input only pins
GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have internal pull-ups or pull-down resistors. They can’t be used as outputs, so use these pins only as inputs:
GPIO 34
GPIO 35
GPIO 36
GPIO 39
https://randomnerdtutorials.com/esp32-p ... nce-gpios/
use external pullup resistors

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Re: Why are GPIOs 34 and 35 always LOW ?

Postby GeorgeFlorian1 » Tue Jul 20, 2021 11:14 am

pipi61 wrote:
Mon Jul 19, 2021 2:14 pm
Input only pins
GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have internal pull-ups or pull-down resistors. They can’t be used as outputs, so use these pins only as inputs:
GPIO 34
GPIO 35
GPIO 36
GPIO 39
https://randomnerdtutorials.com/esp32-p ... nce-gpios/
use external pullup resistors
Thanks.
I did connect external PullUp resistors. They are still always LOW.

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

Re: Why are GPIOs 34 and 35 always LOW ?

Postby pipi61 » Tue Jul 20, 2021 12:56 pm

pinMode(GPIO, OUTPUT);
digitalWrite(GPIO, STATE);
---
pinMode(GPIO, INPUT); or INPUT_PULLUP INPUT_PULLDOWN
xxx=digitalRead(GPIO);
---
If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor. See the Digital Pins tutorial for more information. https://www.arduino.cc/reference/en/lan ... italwrite/

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Re: Why are GPIOs 34 and 35 always LOW ?

Postby GeorgeFlorian1 » Tue Jul 20, 2021 2:47 pm

pipi61 wrote:
Tue Jul 20, 2021 12:56 pm
pinMode(GPIO, OUTPUT);
digitalWrite(GPIO, STATE);
---
pinMode(GPIO, INPUT); or INPUT_PULLUP INPUT_PULLDOWN
xxx=digitalRead(GPIO);
---
If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor. See the Digital Pins tutorial for more information. https://www.arduino.cc/reference/en/lan ... italwrite/
I am using GPIO 34 and 35 which do not have internal resistors. I have added external pull-up resistors.
I have written GPIO 34 and 35 as such:

Code: Select all

#define Input_2 34
#define Input_3 35

pinMode(Input_2, INPUT);
pinMode(Input_3, INPUT);
delay(50);

digitalWrite(Input_2, HIGH);
digitalWrite(Input_3, HIGH);
delay(50);
Yet, they are always LOW.

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

Re: Why are GPIOs 34 and 35 always LOW ?

Postby pipi61 » Wed Jul 21, 2021 6:30 pm

You are in write mode only.
gpio34/35 INPUT only (without pullup)
if you need to check the pin state use the
pinMode(GPIO, INPUT);
xxx=digitalRead(GPIO); if you need to check the pin status, use
-------
digitalWrite(..) can only be used for output pins, then you can set the output voltage level to high or low.

Chandu
Posts: 1
Joined: Thu Jun 09, 2022 6:50 am

Re: Why are GPIOs 34 and 35 always LOW ?

Postby Chandu » Thu Jun 09, 2022 7:11 am

I have an ESP32-WROVER-E and I am trying to use GPIO 34,36 and 39 as buttons. So when I press the button, it should put the pin to LOW and high and vice versa. The problem is that GPIO 34,36 and 39 are always LOW.

we configured the pins as input pins and tried to read the pin status using the ESP IDF read function, gpio_get_level().
we observe the pin reads 0 all the time. We tried connecting pull-up resistors at each pin but didn't help.
if any one of you have any suggestions that might help reading the pins? let us know.

sivar2311
Posts: 3
Joined: Sun Jun 12, 2022 3:48 pm

Re: Why are GPIOs 34 and 35 always LOW ?

Postby sivar2311 » Sun Jun 12, 2022 4:24 pm

I guess your wiring is wrong
GPIOs 34,35,36 and 39 needs external pullup or pulldown resistors.
The code to initialize these pins is

Code: Select all

  pinMode(34, INPUT);
  pinMode(35, INPUT);
  pinMode(36, INPUT);
  pinMode(39, INPUT);
The code to read these pins is

Code: Select all

  bool gpio_34_state = digitalRead(34);
  bool gpio_35_state = digitalRead(35);
  bool gpio_36_state = digitalRead(36);
  bool gpio_39_state = digitalRead(39);
There are no digitalWrite involved.

The state interpretation (pressed or released) depends on the selected wiring.

Pull-Up:
HIGH = released
LOW = pressed

Pull-Down:
HIGH = pressed
LOW = released

Here is the PULL-UP wiring:
PULLUP.png
PULLUP.png (146.28 KiB) Viewed 19059 times
Here is the PULL-DOWN wiring:
Pulldown.png
Pulldown.png (150.52 KiB) Viewed 19059 times

savage
Posts: 23
Joined: Mon Jul 15, 2019 9:24 pm

Re: Why are GPIOs 34 and 35 always LOW ?

Postby savage » Sun Jun 12, 2022 11:15 pm

Chandu wrote:
Thu Jun 09, 2022 7:11 am
we configured the pins as input pins and tried to read the pin status using the ESP IDF read function, gpio_get_level().
If you are not initializing the pin through gpio_config(), try a call to gpio_reset_pin() before setting the pin direction and reading the pin. Some pins are not connected to the IOMUX at startup and gpio_config() & gpio_reset_pin() are the only IDF functions that will do that for you.

Who is online

Users browsing this forum: No registered users and 42 guests