Recomendation on "colour" sensor

I am looking for a colour sensor, not the normal one on a PCB with 4 LED's around it, I am after something smaller and simpler, like an optical switch in dimensions.

I am building a curtain opener for cord drawn curtains but i need to sort out an end-stop system.

I was thinking of putting some black heat shrink on the curtain cord in 2 places, at full open and at full close. or better yet, 2 different colours to be able to tell the difference between them.

that way i don't have to run cables and make mounts for switches that are going to fail.

I was figuring i could 3D print a guide that the cord goes through directly before the opener to guide the cord past the sensor. If its white, keep going, if its black/red stop as it is full open or full closed.

The normal one would not work well as the cord is about 3mm in diameter.

If i can't find something that will work i may have to design my own based on the IC from the normal ones and an 2 LED's in a housing.

To sense black and white a QRD1114 reflective IR sensor may be what you need. They are very small (<6mm square).

Indeed sensing colour is the wrong approach here - you're not interested in colour as such, just the difference between the two. An IR reflective sensor sounds like a good solution to me.

i would prefer to be able to tell the difference from say white/black/red. that way if there is some sort of power loss and the system loses track if it is open or closed, it can determine if it is open or closed.

Upon power on you have to make an assumption - as this can also mean you're somewhere halfway open and closed!

So: make a decision; which way is fail safe, up or down? For the sake of the argument I'll say up is safe, and winding up further will not damage anything (motor is simply stalled).

Then upon startup, you see a marker. You don't know if you're up or down. You start the motor, start winding up. If some time (a few seconds probably) you still see the marker, it was up already. Otherwise, wait until you see a marker again - now you're up.

Likewise if you don't see a marker upon startup you're somewhere halfway. Start winding up until you see the marker and again you know where you are.

They don't go up or down, they are curtains and go side to side. the issue is, i would only be able to put the marker in a place where it does not go through the workings of the motor, so if it starts up, and goes in the wrong direction, it will start grinding the cord.

I had originally thought of using TMC2130 stepper drivers and using stallguard to tell when the motor starts getting bogged down to check if its at the end, but was unsure if would kick in soon enough to not wear the cord, also they are about $15 each which drives the price up per module a lot. Also the curtains sometimes get a little stiff in places that require a little more power, the tmc2130 would assume it is at the end of its run.

Up/down, side/side... trivial difference.

Mount a microswitch somewhere convenient, so that the cord passes by but the curtain itself will activate the switch. One side is enough. Then when starting up you can start by moving the curtain towards the end stop.

Now you also only need one marker on the cord, as the end stop doubles as second marker.

I wouldn't use a stepper, I'd use a geared down DC motor. At least as much force, easier to control, cheaper, more efficient. Unless you want fine control over how much open/closed, but that's also easily done with a regular DC motor by adding an encoder.

I am trying to avoid using endstops, that is the whole purpose of this thread. As for the steppers, I have heaps of the laying around (they are cheap and easy to get as well) and they are not hard to control, a simple loop of step X times, check sensor make decision to keep looping or stop.

As for more efficient, not really worried about that, will only be powered when opening and closing and will be plugged in with a AC adapter anyway, so it's not like I have to power it off a battery

I will be using an esp8266 and will probably end up using external interrupts.