2009 was the year when Apple changed from the hard drive stick on sensor and started utilising the hard drives internal temperature in the newly introduced 21.5" and 27" models. In the older 21.5" and 27" iMac's the 3 fans run flat out if the sensor isn't detected, this wasn't due to overheating. If your iMac is a 2009 or 2010 model simply leave the sensor lead plugged into the logic board, then cut off the hard drive sensor plug, strip back the black and grey wires, solder together and insulate. In these models Apple used a shorting link in place of the sensor when only an SSD was fitted, this mod achieves the same. In the 2011 and the last of the old style 2012 models, Apple utilised a custom drive with extra pins on the power connector. You can use a purchased board to add in a sensor, or if you know what you are doing, use a 10p 2N3704 transistor linked and integrated into the harness cable to add a sensor. In the newer thin/current models you can use an SSD to replace the conventional hard drive without any sensor problems.
"I've done this with several iMacs and MacBooks." - not needed for MacBooks, they don't utilise hard drive temperature sensors.
The hard drives in some Mac Mini's have a temperature sensor added to the hard drive, a small smd based board stuck on. They can easily be removed and attached to a replacement HD or SSD.
Personally I prefer a hardware solution, you then know the temperature sensing is working as Apple intended.
What iMac model do you have?