I would like to know if the circuit is correct?
There is no one "right" value; it is a collection of trade-offs.

When configured as a general purpose digital I/O pin, most microcontrollers have a pretty high input impedance.  R7 wants to be no more than 10% of that value.  If the datasheet input impedance is 100K, R7 should be 10K or less, etc.  A minor consideration is the static current through R7 when the circuit output is high.  Another consideration is that the higher the R7 value, the more susceptible the uC input is to external noise when M2 is off.  Another point in a high volume production situation is that the fewer number of distinct parts, the better.  If increasing R7 to 10K eliminates the only 2.7K resistor in the entire assembly, that's a good thing.