The related hardware diagnostic could be found here: ESP8266 not working with MPU 6050 over wire library and I2C .But I'm not so sure it's a hard ware issue any more because I got the reading for GyroZ was somewhat reasonable but the absolute value of output angle for x and y could be over 360.
An ESP 8266 is connected to MPU6050 and extract the proper data of gyro speed and acceleration GyroX, GyroY, GyroZ and AccX,AccY,AccZ.
The algorithm to obtain the angle was below:
to obtain the elapsed time
currentTime = micros(); // Current time actual time read elapsedTime = (currentTime - previousTime) / 1000000; // Divide by 1000000 to get seconds
to obtain the calculated angle
Acc_angle_x = atan(AccY / sqrt(pow(AccX, 2) + pow(AccZ, 2)) ) * 180 / PI - Acc_angle_calibration_x; Acc_angle_y = -atan(AccX / sqrt(pow(AccY, 2) + pow(AccZ, 2)) ) * 180 / PI - Acc_angle_calibration_y;// a sign was required to correct the angle
and apply the complementary filter
complementary_angle_x = (complementary_angle_x + GyroX * elapsedTime) * (1 - filter_strength) + Acc_angle_x * filter_strength; complementary_angle_y = (complementary_angle_y + GyroY * elapsedTime) * (1 - filter_strength) + Acc_angle_y * filter_strength;
output_angle_x = complementary_angle_x; output_angle_y = complementary_angle_y; output_angle_z=GyroZ;// directly output the angular speed instead of angle
The output was
angle x= 45.98 angle y= -40.72 angle speed z= 0.20 Acc_angle_x = 45.99 Acc_angle_y = -40.72 Acc_angle_calibration_x = -1.05 Acc_angle_calibration_y = -4.19
Thus, apparently, there was something wrong with the calculation of Acc_angle_x and Acc_angle_y because the same code worked for Nano. The function atan was from Math library and all the value were float.
Also, on nano, the calibration angle for for angle calculated from acceleration was
Acc_angle_calibration_x = -1.05 Acc_angle_calibration_y = -4.19
However, on ESP 8266 the calculated angle from acceleration was kept steady at angle_x and angle_y as shown above.