An alternative to a voltage divider circuit is a dedicated logic-level shifter or converter. They come in IC (chip) form and breadboard-friendly breakout modules. There's no math involved because they are more or less plug and play, and they include multiple channels so that they can convert multiple I/O streams simultaneously.
The following image shows typical 4-channel (left) and 8-channel (right) logic-level conversion breakout modules. The 4-channel on the left is built using MOSFETs, while the 8-channel on the right uses a TXB0108 IC. Please note that while we will cover MOSFETs in Chapter 7, Turning Things On and Off, our focus will be using MOSFETs as switches, not logic-level conversion applications:
Logic-level shifter modules also have two halves – a low voltage side and a high voltage side. In relation to your Raspberry Pi, we connect...