I increased the sensitivity of the sensor which didn't seem to make much difference. Then I added a tempered glass screen protector, which I thought would give the sensor no chance. But strangely, with the protector on, the sensor now works so much better.