Libs:
- wiringPi
Hardware:
- Pull-up resistor (10k) to 3.3v on GPIO 24 (=THERMO_BUTTON_PIN)
- floating GPIO 4 (=AUDIO_BUTTON_PIN)
In short, I want to implement an auto-recognition for one of two selfmade HATs. As you can guess, the other HAT has the properties of the first one vice versa. Based on this, i ask the following after booting my program:
wiringPiSetup();
pinMode(THERMO_BUTTON_PIN, INPUT);
pinMode(AUDIO_BUTTON_PIN, INPUT);
pullUpDnControl(THERMO_BUTTON_PIN, PUD_DOWN);
pullUpDnControl(AUDIO_BUTTON_PIN, PUD_DOWN);
if(digitalRead(THERMO_BUTTON_PIN) == HIGH){
printf("Thermo-HAT registered. Starting thermo-branch.\n");
hat_type = thermo;
}
if(digitalRead(AUDIO_BUTTON_PIN) == HIGH){
printf("Audio-HAT registered. Starting audio-branch.\n");
hat_type = audio;
}
The output is:
Thermo-HAT registered. Starting thermo-branch.
Audio-HAT registered. Starting audio-branch.
What i already know/tried:
A pin configured as input has no defined voltage, that's why the "pullUpDnControl" is in place. It doesn't seem to do anything, sadly. The voltage on the pulled up pins stays around 2.7v, while the floating one stays at 2.1v. When disconnecting the HAT, it shows normal 3.3v pull-up behavior, the other one stays at a few millivolts. This tells me that the raspi's input doesn't have enough resistance, so some voltage gets lost over the pull-up, which should not happen. I also disabled the 1-wire bus, which seems to cause problems on GPIO 4.
Why are the voltages in this between state? At least the pulled up GPIO should show the 3.3v.