My thought is that Luke felt Han dying / Kylo’s power rising again / the awakening of the Force again / maybe even Rey’s awakening too. And when that happened, he communicated with R2 in some way to wake up, so that Luke could make himself be found now that he is needed again.