Defining pins for the esp32 wroom 32

Hey guys,
so I am using the esp32 wroom 32. But I am searching for the numbers to define the pins I have tried to just set them by the names on the boards (G0 to 0) but I've got a problem. if I set every pin to INPUT and check if anything is connected it doesnt work. If I am connecting G2 with G4 (all set INPUT), G0 is connected, same thing to when I dont have anything connected. All the time it shows me that G0 is connected. If I connect anything with G0 it works and the other pin also shows as connected but only with G0.

Thats why I thought I'm maybe using the wrong definitions for my Arduino.

#include <Arduino.h>

int pinsToCheck[] = {32, 33, 34, 35, 25, 26, 27, 14, 12, 13, 2, 3, 23, 22, 19, 18, 17, 16, 4, 2, 15};
int numPins = sizeof(pinsToCheck) / sizeof(pinsToCheck[0]);

void setup() {
  Serial.begin(9600);
  for (int i = 0; i < numPins; ++i) {
    pinMode(pinsToCheck[i], INPUT);
  }
  while (!Serial) {
    // Warte, bis die serielle Verbindung hergestellt ist
  }
}

void loop() {
  for (int i = 0; i < numPins; ++i) {
    int pinState1 = digitalRead(pinsToCheck[i]);
    Serial.print("Pin ");
    Serial.print(pinsToCheck[i]);
    Serial.print(" State: ");
    Serial.println(pinState1);
    
    for (int j = i + 1; j < numPins; ++j) {
      int pinState2 = digitalRead(pinsToCheck[j]);
      Serial.print("Pin ");
      Serial.print(pinsToCheck[j]);
      Serial.print(" State: ");
      Serial.println(pinState2);

      if (pinState1 && pinState2) {
        Serial.print("Connected: ");
        Serial.print("Pin ");
        Serial.print(pinsToCheck[i]);
        Serial.print(" and Pin ");
        Serial.println(pinsToCheck[j]);
      }
    }
  }
  Serial.println();  // Leere Zeile für bessere Lesbarkeit im Serial Monitor
  delay(1000);
}

Are you selecing the correct board for the Tools menu

I am using the esp32 dev module because there is no other

The esp32 dev module doesn't have pins defined as G.
Which board do you actually have?

ESP32-WROOM-32 thats, what is written on the CPU

But it has pins marked as G0, G1, G2 etc?

yes

https://www.amazon.de/APKLVSR-Entwicklungsplatine-Mikrocontroller-USB-Schnittstelle-ESP-WROOM-32/dp/B0C61GKRJS/ref=sr_1_2_sspa?__mk_de_DE=ÅMÅŽÕÑ&crid=35E45DBK6K1QK&keywords=esp32&qid=1704196894&sprefix=esp32%2Caps%2C85&sr=8-2-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&th=1

Amazon: APKLVSR ESP32 Development Board NodeMCU Modules, ESP32 Development Board 2.4 GHz Dual Core WLAN WiFi Bluetooth 2-in-1 Microcontroller ESP-WROOM-32 Chip CP2102 Pack of 3

The generic ESP32 board should work, if you use just the pin numbers without the G

What were you expecting to see?
Is there something connected that is HIGH or LOW?
If there is nothing connected it could read HIGH or LOW.

I cant find the generic ESP32 under ESP32 Arduino

I wanted to read, which pin is connected to which. Like G2 to G4.

You define all pins as inputs. If you connect an input to an input it may read high or low

You should install the latest board package
Go to Tools->Board->Board Manager
Find ESP32 by Espressif Systems and install

I have installed it already but cant find it I am sorry, is it just generic ESP32 and is it all the way on the top of the list? Thank you very much for your help :slight_smile:

I would select ESP32 Dev Module as the board

By generic I meant the ESP32 dev mod

yeah thats what I was using but unfortunatly had the problems. Thats what happenes:

Pin2 with Pin4:
Pin 0 State: 1
Pin 2 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 2 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 5 State: 0

Pin 2:
Pin 0 State: 1
Pin 2 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 2 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 5 State: 0

no Pin connected:
Pin 0 State: 1
Pin 2 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 2 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 4 State: 0
Pin 5 State: 0
Pin 5 State: 0

Not sure what is wrong. Your code isn't even printing out the correct pin numbers that you have in the pinsToCheck[] array.

Sorry, that was the old error, I changed the code sry. thats the right error message:

Connected: Pin 3 and Pin 0
Pin 23 State: 0
Pin 22 State: 0
Pin 19 State: 0
Pin 18 State: 0
Pin 17 State: 0
Pin 16 State: 0
Pin 4 State: 0
Pin 2 State: 0
Pin 15 State: 0
Pin 0 State: 1
Pin 22 State: 0
Pin 19 State: 0
Pin 18 State: 0
Pin 17 State: 0
Pin 16 State: 0
Pin 4 State: 0
Pin 2 State: 0
Pin 15 State: 0
Pin 0 State: 1
Pin 19 State: 0
Pin 18 State: 0
Pin 17 State: 0
Pin 16 State: 0
Pin 4 State: 0
Pin 2 State: 0
Pin 15 State: 0
Pin 0 State: 1
Pin 18 State: 0
Pin 17 State: 0
Pin 16 State: 0
Pin 4 State: 0
Pin 2 State: 0
Pin 15 State: 0
Pin 0 State: 1
Pin 17 State: 0
Pin 16 State: 0
Pin 4 State: 0
Pin 2 State: 0
Pin 15 State: 0
Pin 0 State: 1
Pin 16 State: 0
Pin 4 State: 0
Pin 2 State: 0
Pin 15 State: 0
Pin 0 State: 1
Pin 4 State: 0
Pin 2 State: 0
Pin 15 State: 0
Pin 0 State: 1
Pin 2 State: 0
Pin 15 State: 0
Pin 0 State: 1
Pin 15 State: 0
Pin 0 State: 1
Pin 0 State: 1

It still doesn't match the pins you have in pinsToCheck[]
Something else is wrong somewhere.