Cannot read digital pin

lucian_v
Posts: 3
Joined: Mon Feb 11, 2019 7:29 pm

Cannot read digital pin

Postby lucian_v » Mon Feb 11, 2019 7:34 pm

Hi all,
I am using a LOLIN32 board, v1.0.0 together with an arduino nano. ESP32 receive some data on serial from nano (using pins - 16,17), and also run in AP mode with a webserver on it.

My issue is that I am not able to read a digital pin which I set as "INPUT", where actually I get LOW or HIGH from arduino uno using a voltage divider to not go over 3V. I tried with pis 12,15,33 on ESP32 side and no matter what I get always 1 when I do readDigital(pin);
Even if the arduino nano is set to HIGH or LOW, or even if I put ESP pin to gnd or 3.3V.

Can you please help me somehow ? I have no idea why I am getting this

Thanks in advance.

idahowalker
Posts: 166
Joined: Wed Aug 01, 2018 12:06 pm

Re: Cannot read digital pin

Postby idahowalker » Wed Feb 13, 2019 9:43 pm

I wrote
In setup

Code: Select all

pinMode ( pinTest, INPUT );
 pinMode( BlinkLED, OUTPUT ); // for blink LED
xTaskCreatePinnedToCore ( fBlinkBuiltIn, "fBlinkBuiltIn", TaskStack10K1, NULL, Priority2, NULL, TaskCore1 ); //assigned to core 1
in a task:

Code: Select all

void fBlinkBuiltIn( void* pvParameters )
{
  // https://esp32.com/viewtopic.php?t=1746
  // gpio_set_level(gpio_num_t gpio_num, uint32_t level)
  // toggle built in LED off/on
  for (;;)
  {
    Serial.println ( digitalRead ( pinTest ) );
    vTaskDelay( pdMS_TO_TICKS( 10 ) );
    REG_WRITE( GPIO_OUT_W1TS_REG, BIT27 ); // GPIO27 LOW (set)
    vTaskDelay( pdMS_TO_TICKS( OneK ) );
    REG_WRITE( GPIO_OUT_W1TC_REG, BIT27 ); //GPIO27 HIGH (clear)
  }
  vTaskDelete( NULL );
}
I used pin 12, 15, 33 for the value of pinTest, setting a jumper wire from gnd to 3.3 volts on an ESP board, and did not have an issue with reading the inputs and printing the values from those pins.

Your code?

Your wiring diagram?

Did you connect the grounds?

What voltage is your voltage divider putting out at the ESP32 connection?

Have you isolated the ESP32 from the other device and tried to get those pins to do inputs with a wire?

Why not just write code to just read the pins and disconnect the ESP32 from everything else (isolated), move a jumper wire back and forth, (gnd to 3.3) to see if the state changes, as printed out on the serial monitor. if it still does not work, the ESP32 got fried. ESP32's blow quicker then fuses but not as fast as crowbar circuits blow fuses.

If I was to use a resistor network from 5 volts to 3.3 on an ESP32, I'd use a 3.3 Zener as input protection to the ESP32.

lucian_v
Posts: 3
Joined: Mon Feb 11, 2019 7:29 pm

Re: Cannot read digital pin

Postby lucian_v » Mon Feb 18, 2019 8:34 am

Hi,
Seems was my mistake somehow(probably wiring) because when I started over on a clean board it worked. Even so, I noticed that esp32 cannot start if pin 12 is High, but I fixed the issue

Thanks a lot for help

Who is online

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