The development of human-robot cooperation and the demand of high-precision robot control have increasingly spurred the usage of joint torque sensors. A build-in torque sensor for harmonic drive is researched in this paper, which utilizes strain gauges attached to the surface of the flexspline to measure torque. As the strain signal is significantly affected by the rotation of wave generator, positioning error of strain gauges and uneven distribution of the load torque, a new torque sensing technique with on-line torque estimation is developed to eliminate disturbance and achieve better measurement precision. Meanwhile, the dynamic strain of flexspline is obtained by finite element method, which is utilized to optimize the layout of strain gauges for lower disturbance. The proposed torque sensing technique is implemented and verified by experimental results.compliant elements adds mechanical components, makes the joint structure more complex and increases the joint elasticity.