Control of the bath depth is critical in many applications of the patch-clamp technique, particularly when the capacitance of cells is determined to assess secretion or transmitter release or in studies of ion currents sensitive to small changes in the hydrostatic pressure. We describe an inexpensive technique for tight control of the bath depth with the aid of a commercially available ultrasound sensor. The sensor continuously determines changes in the distance to the bath surface with a resolution of about 10 mum. The signal from the sensor is digitized in a microcontroller card and used to send on or off signals at 100 Hz to a peristaltic pump that removes volume from the bath. The inflow into the bath can be realized in a versatile way. The capacitance of Sylgard-coated patch-clamp glass electrodes, demonstrated to be extremely sensitive to small changes in the area moistened by bath solution, is constant within the noise level of +/-3 fF when immersed into a depth-controlled bath, even during exchange of the bath medium. Thus, when small changes in the cell capacitance are measured in patch-clamp experiments, errors due to alterations in the pipette capacitance caused by bath depth fluctuations are eliminated.