Check out Sparkfun's Logic Level converter. It includes a schematic, you should be able to do almost exactly the same thing by hand, but you'll probably need to use different resistor values to get the correct voltages. It includes two circuits, one for connecting a low voltage transmitter to a high voltage receiver, and one for connecting a high voltage transmitter to a low voltage receiver. It sounds like the former is what you're asking for.
The datasheet is very sparse, but all the information you need is plainly on it.
What you see here is a internal description of how it works, and the Mode Select pin. This is a 6 input to 6 output level shifter. It is not bi-directional, and you can only translate from one level to the other, no mixing and matching. The diagram shows that an input goes into the inverter (not gate), powered by VCC. It is then shifted before going into another inverter, powered by VDD, resulting in the output.
From this you can see that Vcc is the Voltage Supply for the Input level, and VDD is the Voltage Supply for the Output level.
The Mode select table tells you how the Mode pin should be handled. The TTL and Cmos does not refer to simply voltage levels, but how to interpret them.
And the Electrical Characteristics tell you the rest.
Here you can see what voltage, comparatively, will be interpreted. Cmos treats a Low and a High roughly equally. A Input Low (0) is treated as a little under half of the Voltage Supply level (Vcc), and a Input High (1) is treated as a little over half of the Vcc (When VCC = 5, anything under 1.5V, then up to 2.25v is logic 0, anything above 3.5V, then until 2.75V is logic 1).
TTL on the other hand, has a smaller, fixed range for logic low. An input (at VCC = 5v) between 1.5 and below is Logic 0, and 1.5 and above is Logic 1.
You need to look at the STM32's datasheet to figure out if it uses TTL or cmos level output.
Best Answer
After reviewing your earlier circuit and some of the discussion there (you should modify your question to refer directly to it and also extract the important details from the discussion there and re-post it in your question here), I'll propose this circuit:
simulate this circuit – Schematic created using CircuitLab
The above circuit uses two \$10\:\textrm{k}\Omega\$ pull-up resistors for \$V_{OUT}\$. This can be changed if you need a lower impedance output when high (with some implications for the other resistor values.) I didn't gather from you a specific output impedance so I just used those.
The circuit uses \$R_6\$ and \$R_7\$ to inject some current into \$Q_1\$'s base node. Because the circuit includes carefully designed hysteresis, the output will be held low until both inputs transition to \$+5\:\textrm{V}\$. Then it will transition high. Once high, though, the output will stay high until both inputs transition back to \$2.7\:\textrm{V}\$. (The hysteresis is substantial so it should be relatively immune to noise.)
The behavior looks like this:
Here it is with added noise on the two inputs:
As I understand you, there are four LEDs indicating five states for your tank of water. With all four LEDs off, the water in the tank is below the threshold where you then want a motor turned on to fill the tank. With all four LEDs on, the water in the tank is above the threshold where you then want the motor turned off (to stop filling the tank.)
When an LED is on, the voltage on one side of the LED (relative to ground, I'm assuming) is \$2.7\:\textrm{V}\$ (which makes sense, since the LED will drop a certain voltage not unusually in that range.) When the LED is off, the voltage across it is \$5\:\textrm{V}\$ (which also makes sense, if a low-side switching circuit isn't allowing much LED current.)
I think you are then suggesting using the voltage present one two nodes, one node from one side of the lowest-level indicating LED and one node from the highest-level indicating LED as a means to signal when to operate your motor.
I see the table like this:
$$ \begin{array}{r|lccc|l} \textrm{State} & \textrm{LED}_{low} & \textrm{LED}_{low-mid} & \textrm{LED}_{high-mid} & \textrm{LED}_{high} & \textrm{Action}\\ \hline \textrm{empty} & 5.0 & 5.0 & 5.0 & 5.0 & \textrm{turn motor ON}\\ \textrm{filling} & 2.7 & 5.0 & 5.0 & 5.0 \\ \textrm{filling} & 2.7 & 2.7 & 5.0 & 5.0 \\ \textrm{filling} & 2.7 & 2.7 & 2.7 & 5.0 \\ \textrm{full} & 2.7 & 2.7 & 2.7 & 2.7 &\textrm{turn motor OFF}\\ \textrm{draining} & 2.7 & 2.7 & 2.7 & 5.0 \\ \textrm{draining} & 2.7 & 2.7 & 5.0 & 5.0 \\ \textrm{draining} & 2.7 & 5.0 & 5.0 & 5.0 \\ \textrm{empty} & 5.0 & 5.0 & 5.0 & 5.0 & \textrm{turn motor ON}\\ \textrm{...} \end{array} $$
The very high input impedance of the given circuit should not cause any trouble for your LED displays or the circuits driving them. Use the first and last LED columns shown above as your two nodes for the circuit. It will produce a LOW output when the motor should be OFF and will produce a HIGH when the motor should be ON. Couldn't be simpler.
The output impedance might matter. But it is trivial to reduce the output impedance with a very simple added stage, if you need it.
The circuit is resistant to noise, uses parts that are available anywhere in the world where electronic parts are available, and the parts are widely supplied, too. And they cost next to nothing. Nothing boutique here. Not even close.