user261: I have following setup:

Arduino Duemilanove
Small water heater connected with optical relay (PWM is ok)
Waterproof DS18B20 temperature sensor
Unknown amount of water (but temperature sensor and heater are always underwater).

How can I accurately control water temperature, based on temperature sensor readings? By accurately, I mean up to accuracy of temperature sensor (in this case, ±0.5°C). Everything should run on Arduino, so no additional data storage or processing power is available. For debugging, I can obviously use computer.
I have tried running PID, but it seems really hard to 

Avoid overshooting - going over target temperature either initially, or when (cold) water is added
Stabilize properly after adding cold water.


user79: You need to know the response time of your system and the repeatability of your measurements to characterize your data (establish confidence). I suggest taking samples and average them before turning the heater back on.
Imho, water will not happily stay within 0.5°C. Can you allow for coarse and fine modes? Use a higher PWM for great differences and then lower PWM for when close to target. 
Once homed in on your target, there are a few means you can try to improve temperature stability. While pre-built things like PID work for many, I normally implement functionality like this manually.

261: <p>I have following setup:</p>

<ul>
<li>Arduino Duemilanove</li>
<li>Small water heater connected with optical relay (PWM is ok)</li>
<li>Waterproof DS18B20 temperature sensor</li>
<li>Unknown amount of water (but temperature sensor and heater are always underwater).</li>
</ul>

<p>How can I accurately control water temperature, based on temperature sensor readings? By accurately, I mean up to accuracy of temperature sensor (in this case, ±0.5°C). Everything should run on Arduino, so no additional data storage or processing power is available. For debugging, I can obviously use computer.</p>

<p>I have tried running PID, but it seems really hard to </p>

<ol>
<li>Avoid overshooting - going over target temperature either initially, or when (cold) water is added</li>
<li>Stabilize properly after adding cold water.</li>
</ol>
 79: <p>You need to know the response time of your system and the repeatability of your measurements to characterize your data (establish confidence). I suggest taking samples and average them before turning the heater back on.</p>

<p>Imho, water will not happily stay within 0.5°C. Can you allow for coarse and fine modes? Use a higher PWM for great differences and then lower PWM for when close to target. </p>

<p>Once homed in on your target, there are a few means you can try to improve temperature stability. While pre-built things like PID work for many, I normally implement functionality like this manually.</p>
