Wiring a sensor to a Pi from memory goes wrong quickly, because the header has 40 pins and the numbering is easy to mix up. Raspberry Pi OS has a command that draws the header for you, so you can check the pin before you plug a wire into it.
Type this on the Pi, or over SSH:
pinout
The Raspberry Pi documentation says the command displays a pinout map showing the physical pin positions, the logical GPIO identifiers and the pin functions. That covers the three things people confuse: pin 3 on the board is not GPIO 3, and the label on a breakout board can follow either scheme. Seeing both numbers next to each other in one picture settles it.
A good habit is to run it in a second terminal while you wire things up, then check each wire against the picture before the Pi is powered on. Switching the power off first is still the right order, since a wire moved on a live header can short two pins.
The same documentation page also covers GPIO permissions. To use the pins from a normal user account, that account has to be in the gpio group:
sudo usermod -a -G gpio <username>
Replace <username> with the account name. I’d note that group changes are normally picked up at the next login, so log out and in again (or reboot) before you judge whether it worked.
The caveat is that pinout shows the layout, not the state. It does not tell you what a pin is set to at this moment or whether something else already uses it. For that you need a tool that reads the live pin state, and I have only verified the layout command for this tip.
It also assumes the Pi is the one you think it is. Header maps differ between models in details such as extra connectors, so run it on the board in front of you, not on a different one from memory.
Further reading: Raspberry Pi documentation: GPIO pinout and permissions