An apparatus, including a magnetic field generator, a first magnetic field sensor configured for attachment to a proximal end of a surgical tool configured for insertion into a body, and a calibration device that includes a second magnetic field sensor and a proximity sensor, wherein the field sensors generate respective location signals responsive to a magnetic field emanating from the generator and traversing the field sensors. The apparatus includes a control unit, which receives the signals from all the sensors, extracts respective location and orientation coordinates of the field sensors based on the signals, computes a conversion relation between the coordinates of the first sensor and a distal end of the tool that is brought into contact with the calibration device, and subsequently applies the conversion relation, together with the coordinates of the first sensor, in providing a visual indication of a location of the distal end inside the body.