Photon analog input problem

It's unlikely to be a software issue on the Photon.

I use a circuit like this on my analog inputs:

You add a 100Ω series resistor into the ADC, and a D1213A TVS which does two thiings: it protects against some ESD via the zener diode, and also protects against voltage above 3.3V or below 0V with the rail-to-rail diodes.

If the source is a voltage divider, you can skip the 100Ω series resistor (look farther up in that post).