I tested several values, one that works is R6 = 5k6 and R13 = 1k2
Ah so with the 10k and 1k you have in your original schematic, it does not work? Just to clarify... since my initial guess was that this should not work. The updated values rise the level closer to the threshold voltage of the transistor but it's still pretty low.
I use this with a photoresistor and a mcp23017 powered at 5 v with pullup enabled.
when c1_out is not conected to the mcp it has 2.6V when I connect it to the mcp it has 5V (the mcp`s pullup)
So just to clarify even more, this is when the OpAmp output is low and the LED is off, right? You don't have any problems turning on that LED?
maybe calculating a propper voltager divider could solve the 2.6V issue?
Yes but to do that, you have to know the output voltage of the OpAmp. The problem is that this is difficult to figure out; An ideal OpAmp can have any output voltage between whatever you supply to it. In your case that is between 0 V and 5 V. But a real OpAmp does not work like that. A real OpAmp needs some "head room" between the supply rails and the output voltage. Maybe your output voltage is constrained to the range of 1 V to 4 V or even worse. Not only does this depend on the OpAmp, but also on the load you are attaching to the output.
That is unless you go for a rail to rail OpAmp, and even then, whether you can get close to the rail still depends on that load current. If you had an OpAmp that could go to 0.2 V and up to 3 V or whatever, you wouldn't even need that divider. At 0.2 V, your transistor is off and at 3 V, you can turn it on hard. You would still need a base resistor and maybe a pull-down but that's another story.
That said, the 2.6 V could be just due to leakage. The LED is off when you measure the 2.6 V, right? Reading 5 V when you have the expander in place points towards that direction. Anyway, does it work the way it should? If so and it's not drawing excess current anywhere (which I don't see how it could) you're fine I guess. Personally though I would not feel comfortable as there is the possibility that this works because you are on the edge of some parameters, so I would investigate this further to make sure that this is rock solid also when temperature changes etc.
Just out of curiosity, it would be interesting to measure the OpAmp output voltage and the base voltage of the transistor, both when the transistor is on and when it's off.
HTH, regards
Matt