Heat is actually a smaller part of the problem than is humidity. Your wood doesn't expand a great deal, or shrink, with temperature changes. Your rails do expand, but they only expand about 1/4" over 100' of solid rail (no cuts or joints) with a rise in temps from 32 deg F up to 62 deg F. Four 1/16" gaps over those 100' will take care of any expansion if you have unsoldered joints here and there, say on tangent track.
However, sharp rises in humidity cause your wood to swell, and when it does that it draws the roadbed with it, and if the tracks are ballasted or otherwise well fastened to the roadbed, it will move as well. Those few unsoldered joints, if you have them, will grow to over 1/8" each if your room's humidity rises from 40% to 80% and stays there for five or six days. It takes a while for the wood to absorb humidity, but not weeks.
Okay, so you have a few wider-than-you'd-like gaps, but everything still works and it's still all in line. Now, when the humidity is still at 80%, you decide to extend your layout. You build the benchwork in a morning and lay the roadbed. That afternoon you lay out the rails, and as before, you soldered most curved joints and left most of the tangent track joints free to slide in case of expansion or contraction. However, the next three weeks are very dry, and the new extension shrinks in the now-40% humidity. All your sliding gaps will close up significantly, but your soldiered joints have no outlet for any pressure building up on them. As the surface of the layout shrinks, it wants to draw all the roadbed up into itself linearly, and of course that means the tracks fixed to it begin to go into compression....that builds....and finally the compression overcomes the adhesion and the tracks buckle...up, sideways...
So.............it's mainly the humidity you have to control. I keep a humidistat, a cheap electronic one for $14 had at any hardware store, in my layout. You can get slightly more expensive ones that have a remote sensor. You can be in the house, while out in the building where your layout is, say 20 yards away, the signal between your home unit and the remote sensor in the shed tells you what humidity level you have. If it creeps up higher than 65 in my loft, above my out-building garage, I know to trudge out and plug in the dehumidifier. If it stays in a narrow range near 50%, like it does all wet winter long (defying belief because cool windy wet winters should have high humidity) where I live, I don't need to monitor it except to take a look once a week. Summer time, though, is a different story. Sliding my liftout bridge into place, I can tell when I have been negligent and let the humidity rise too high for too long because it doesn't want to slide down into the gap easily...as it should.