Simplest angle sensor?

In a new project I need to read angle. Ether digital or analog.
Accuracy within 1 degree is perfectly acceptable.
Sample rate should be around 50 Hz

I tried with the MPU6050, it's quick and accurate, but it doesn't like sudden movement and lots of noise enter the system. Applying long filters will slow down everything, and I prefer to avoid complicated codes as much as I can.

Is there any "better" sensor out there, suit my application?

Thanks a LOT for your help!

Something I forgot to mention - The sensor is installed on a machine which have plenty of vibration and sudden movements. I want to have clean 1 axis angle regardless of those movements.

The problem is not the sensor, it is the software, which you forgot to tell us about. Check out the "How to use this forum" post.

Assuming you mean tilt angle, it would be unrealistic to expect and perhaps impossible to measure with 1 degree accuracy at 50 Hz sample rate, in a noisy environment with sudden movements.

yoramlavee:
Something I forgot to mention - The sensor is installed on a machine which have plenty of vibration and sudden movements. I want to have clean 1 axis angle regardless of those movements.

I assumed the problem was the sensor type and was was asking advice for a different type.
So you say the sensor should give me stable read regardless o quick movements?

here is the code im using - it's a sample code I found working and and just trying to get the LED lit when passing above a limit. When I move the sensor quick below that limit, it still make the LED lit...

#include<Wire.h>

const int MPU_addr=0x68;
int16_t axis_X,axis_Y,axis_Z;

int minVal=265;
int maxVal=402;
int SetAngle;
int KillSw_pin = 7;

double x;
double y;
double z;

void setup(){
pinMode(KillSw_pin, OUTPUT);
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(250000);
SetAngle = 34;

}

void loop(){

Wire.beginTransmission(MPU_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true);
axis_X=Wire.read()<<8|Wire.read();
axis_Y=Wire.read()<<8|Wire.read();
axis_Z=Wire.read()<<8|Wire.read();
int xAng = map(axis_X,minVal,maxVal,-90,90);
int yAng = map(axis_Y,minVal,maxVal,-90,90);
int zAng = map(axis_Z,minVal,maxVal,-90,90);

x= RAD_TO_DEG * (atan2(-yAng, -zAng)+PI);
y= RAD_TO_DEG * (atan2(-xAng, -zAng)+PI);
z= RAD_TO_DEG * (atan2(-yAng, -xAng)+PI);

if (SetAngle > x) {
digitalWrite(KillSw_pin, HIGH);
}

else {
digitalWrite(KillSw_pin, LOW);
}

}

Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Oops...sorry again.

#include<Wire.h>

const int MPU_addr = 0x68;
int16_t axis_X, axis_Y, axis_Z;

int minVal = 265;
int maxVal = 402;
int SetAngle;
int KillSw_pin = 7;
double x;
double y;
double z;

void setup() {
  pinMode(KillSw_pin, OUTPUT);
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);
  Serial.begin(250000);
  SetAngle = 34;
}
void loop() {

  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr, 14, true);
  axis_X = Wire.read() << 8 | Wire.read();
  axis_Y = Wire.read() << 8 | Wire.read();
  axis_Z = Wire.read() << 8 | Wire.read();
  int xAng = map(axis_X, minVal, maxVal, -90, 90);
  int yAng = map(axis_Y, minVal, maxVal, -90, 90);
  int zAng = map(axis_Z, minVal, maxVal, -90, 90);

  x = RAD_TO_DEG * (atan2(-yAng, -zAng) + PI);
  y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI);
  z = RAD_TO_DEG * (atan2(-yAng, -xAng) + PI);

  if (SetAngle > x) {
    digitalWrite(KillSw_pin, HIGH);
  }

  else {
    digitalWrite(KillSw_pin, LOW);
  }

}

I assumed the problem was the sensor type

I understood that, and told you that the problem is not the sensor. The problem is the physics of motion, which the code you posted does not take into account.

You need to use 3D fusion filter software and include the gyro contribution to get anywhere. I suggest the Jeff Rowberg DMP library.

I saw that library when I did my search, but I have to say it's too confusing to a newbie like me.
What to take and what to use...
Seems like very powerful solution, and this is why I was asking what is the simplest solution exist. Is there anything else?

No, there is nothing simple about what you want to do.

However, you can buy an AHRS (Attitude and Heading Reference System). The cheapest one is the BNO055, but it is not very accurate. The more you spend, the higher the performance, up to airplane cockpit level ($10K-50K).

Thank you!

Basically, that was the answer I was looking for. In the mean time, I digged into the Jeff Rowberg libs and made it work, but get some wired readings as 90 degree (actual) been read as 75 degree only...

For the test unit im building, the Adafruit sensor seems just what I need.

Thanks again for your time!