digitalRead on pin 34.
digitalRead on pin 34.
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?
Re: digitalRead on pin 34.
GPIO 34-39 have no internal configurable pullup/down, you have to add a 10kohm resistor from the GPIO to 3,3V
Re: digitalRead on pin 34.
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?
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));
}
Re: digitalRead on pin 34.
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 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
Re: digitalRead on pin 34.
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.techdog86 wrote: ↑Tue Jun 01, 2021 5:06 pmHi,
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
Who is online
Users browsing this forum: lbernstone and 97 guests