Balance sensor?

What type of sensor would I need to tell a humanoid robot it is slightly leaning in a direction to prevent it from losing it's balance?

Something that would say you are leaning 30 degrees towards your left, any other ideas too are welcome.

Thanks in advance

You can figure out tilt with a 3-axis accelerometer IF the robot isn't moving (accelerating). If the robot isn't stationary, then you need gyros as well as accelerometers.

IMO, this is the sensor to get. I filters the data from accelerometer, gyros and magnetometer and give you a heading and roll and pitch angles. It's a really cool sensor.

There are less expensive options. I2Cdevlib has some great code to use with inexpensive IMU type sensors but these are much more complicated than the BNO055 sensor's code.

That looks like it's exactly what I need, but...how would I hook that up to an Arduino or a home computer?

So far I only know how to read analog voltages from micro controllers.

kolleamm:
That looks like it's exactly what I need, but...how would I hook that up to an Arduino or a home computer?

So far I only know how to read analog voltages from micro controllers.

Adafruit provides a nice tutorial.

You can ask questions here when you get stuck.

Will do thanks a lot