I have an LM317LZ connected to a 1000uf, 10V capacitor and a 10uf capacitor. The regulator is working but not very well. I have 5 AA batteries in series at 2400 mAh for my power source. The input voltage when charged is about 6.6V and when discharged completely 5.7V. The regulated voltage is set for 3.15V, which it hits perfectly most of the time. However, it is not perfect. There are some irregularities I will show. The setup is 2 analog inputs on an MCP3008 ADC connected to an ESP8266. One input is for raw voltage(I used resistors to get them in the range of the MCP3008). And the other input is for the regulated voltage. I stream this to a DB online and here are the two plotted.

The blue is raw battery voltage and the orange is the regulated one. I think the spikes are sensor issues as the battery should not produce those. But, what is causing this?

What is causing my power supply (blue) to do this and also why is my regulator not "correcting" this? After 2000 samples everything seems to run smoothly. The sample rate is 1 per 10 seconds, so 8000 samples is 80000 seconds.

The blue is raw battery voltage and the orange is the regulated one. I think the spikes are sensor issues as the battery should not produce those. But, what is causing this?

What is causing my power supply (blue) to do this and also why is my regulator not "correcting" this? After 2000 samples everything seems to run smoothly. The sample rate is 1 per 10 seconds, so 8000 samples is 80000 seconds.