Hi! I don't know if this is the right forum for this but my project has some electronics in it. I am an absolute beginner in electronics. I am making a capacitive wave height sensor for a wave flume. I am encountering some problems with what I believe is a temperature drift or something of the sort.
For the electronics, I am using a relaxation oscillator that charges and discharges a capacitor (the probe) and I measure the frequency of the signal by counting the number of signal wave fronts with a Raspberry Pi Pico 2. The frequency is pretty high, in the 200 to 800kHz range (It gives me a better resolution). I compare the measurement with two other reference capacitors to find the "real" capacitance of the probe. I then calibrate it with two points (high and low water level).
Recently I noticed that when I lower the water level and then fill the container up again, the capacitance changes by about 10pF (570 to 560) for the same level. The same thing happens when I leave the container overnight without any changes to the water level. When I come back the next morning it has changed. I'm guessing it's the temperature of the water, since my setup is in a garage and since the water filling up the container is a different temperature from the water already in it. The reference signal wave front counts don't change, only the probe one does, so I don't think the temperature drift is coming from the electronics. I also want to mention that I tried counting the period with the Pi internal clock, which was working well, but I found that there was an even bigger drift (when I was counting the period, the oscillator frequency was way lower, about 20-80kHz, if that's relevant). It could also be something else that's causing this that I haven't thought of.
Obviously, this is a complete flop for a probe that will be used outside where the environment is constantly changing. I'm open to any ideas regarding this problem, or advice for my circuit.