digitalRead on pin 34.

harshcht
Posts: 6
Joined: Fri Mar 31, 2017 2:57 am

digitalRead on pin 34.

Postby harshcht » Mon Jun 05, 2017 11:40 am

I was trying to digital read (using arduino IDE) on my pin GPIO34 of esp32. However digitalRead(34), returns 0 irrespective of whether I press the button or not. I have connected the pin to 3.3 V sourse using a push button. Is there something I am doing wrong as the function works fine on pin 19 or any other pin but not on the pins with ADC. Is it that these pins cannot be used with digital read?

Thorvard
Posts: 2
Joined: Mon Feb 13, 2017 5:12 pm

Re: digitalRead on pin 34.

Postby Thorvard » Mon Jun 05, 2017 4:09 pm

GPIO 34-39 have no internal configurable pullup/down, you have to add a 10kohm resistor from the GPIO to 3,3V

harshcht
Posts: 6
Joined: Fri Mar 31, 2017 2:57 am

Re: digitalRead on pin 34.

Postby harshcht » Thu Jun 08, 2017 6:11 am

Thanks @thorvard Now it is working well with digitalRead however if I put in the following code.
It does not work properly and digitalRead gives zero even at 3.3 v analog input. Can I use both digital Read and analog read on the same pin?

Code: Select all

   void setup() {
       // put your setup code here, to run once:
       Serial.begin(112500);
       pinMode(34,INPUT);
      
      
       

     }

            void loop() {
      // put your main code here, to run repeatedly:
      //Serial.println("in loop");
       int a =0;
             for(int i=0;i<1000;i++)
      {
      a=a+ analogRead(34);
      }
       
         
         
        Serial.println(a/1000);
        
        Serial.println(digitalRead(34));
        }

techdog86
Posts: 1
Joined: Mon May 31, 2021 8:03 pm

Re: digitalRead on pin 34.

Postby techdog86 » Tue Jun 01, 2021 5:06 pm

Hi,

I realize the original post was some time ago, but I encountered the same issue and wanted to post my findings. If anyone has an update, or resolution I would appreciate it.

I tried to use pin 34 as an input on the ESP32 and I found that I could get it to work as an analog input (reads 4095 when 3.3v applied) but I could not get the digitalRead function to recognize the input even when using an external 10K pull-up resister.

My guess is that the voltage or current used to recognize the digitalRead is very specific, and therefore the software is not recognizing it or perhaps its designed to only work as an analog input.

In any case, you could write a software work around that uses the analogInput as a digitalInput or just use available pins on the 0-31 bus, but I am yet to find a way to get digitalRead (or direct registry reading) to work.

If anyone found a solution please share.

Cheers

jeremyp
Posts: 1
Joined: Thu Jun 10, 2021 2:31 am

Re: digitalRead on pin 34.

Postby jeremyp » Thu Jun 10, 2021 2:41 am

techdog86 wrote:
Tue Jun 01, 2021 5:06 pm
Hi,

I realize the original post was some time ago, but I encountered the same issue and wanted to post my findings. If anyone has an update, or resolution I would appreciate it.

I tried to use pin 34 as an input on the ESP32 and I found that I could get it to work as an analog input (reads 4095 when 3.3v applied) but I could not get the digitalRead function to recognize the input even when using an external 10K pull-up resister.

My guess is that the voltage or current used to recognize the digitalRead is very specific, and therefore the software is not recognizing it or perhaps its designed to only work as an analog input.

In any case, you could write a software work around that uses the analogInput as a digitalInput or just use available pins on the 0-31 bus, but I am yet to find a way to get digitalRead (or direct registry reading) to work.

If anyone found a solution please share.

Cheers
I have a circuit using a 16 channel mux to read a bunch of inputs, I happen to be reading the mux's value on io34. The inputs are a mix of analog and digital signals. I found that an analogRead appears to change something about that input channel but I found that calling pinMode(34, INPUT); after doing an analogRead has alleviated the problem. I am not an expert on what happens when these functions are called so I can't say why this works only that it worked in my situation.

Who is online

Users browsing this forum: No registered users and 51 guests