Schmitt Trigger not reaching full saturation
Output voltage drop vs current sourcing. Source: LM2904 datasheet.

The datasheet explains the answer. 

The best you're going to get out of that op-amp is > 1 V less than the positive supply. As you try to pull more current the voltage droops and collapses completely at > 30 mA. With your 220 Ω resistor you're probably hoping for 10 mA. I've marked on the graph that you can expect about 1.5 V drop in output voltage.


  So what's the non-ideal thing that is causing this problem?


Output doesn't reach V+.


  I think it could be related with any maximum output current the op amp can drive, ...


There are both voltage and current limitations.


  ... but the datasheet actually does not give any information about output current. 


Experience is knowing where to look. You're wiser now!



Update - a possible workaround.







simulate this circuit &ndash; Schematic created using CircuitLab

Figure 2. Addition of a pull-up resistor and diode will give the GPIO a further +0.7 V on both high and low conditions.

You need to work out if this would solve the problem.