Measuring DC voltage using voltage divider

I am trying to monitor remotely the status of a very old security system. The voltage on one of the the ports is 6V when the alarm is on and 0V when it’s off. I am using two 10K resistors to get 3V on the Imp input pin. The Imp pin is configured as ANALOG_IN and the read returns most of the time what I am expecting, about 50,000. Occasionally it returns random values between 20,000 and 65535. Is this normal? Is there anything special about analog inputs I should be aware of? Maybe the current is too low? BTW, when the voltage is zero it always returns zero.
port <- hardware.pin8; port.configure(ANALOG_IN); server.log(;

Thanks, DrJack! Sounds like the capacitor is a good idea. I will keep you posted.

Perhaps it is reading correctly and that’s what the voltages actually are. As a test you could put a second IMP in and see if both IMPs get the same readings.

You could perhaps be picking up some noise spikes on the line, which you could suppress with a capacitor of about 1 to 10 microfarad from your analog pin to ground.

Works like a charm with a 10 mF capacitor. Thanks again!