user67324: I have an Arduino Nano 33 IoT and I want to get the angle of it using the built-in gyro but I can't seem to find any example code that does this.
The default gyro and accelerometer example code doesn't help. Is it even possible to do this?

user61722: You wil have to calculate the angles. Some trigonometry is required, and for the gyroscopes, also some integration. You can read about it here, and in many other places.
You will get the best results if you combine the data from the gyroscopes and the accelerometers using a complementary filter, a Kalman filter, or an other algorithm. These are also easily googled.
There is some example code for the LSM6DS3 IMU on the Nano 33 IoT here on Github.

user71307: You are supposed to use a filter library on top of the output of the gyro as well as the accelerometer data (both is used!) to get angles ... https://www.arduinolibraries.info/libraries/madgwick
Here is a working example that prints the pitch of the sensor from +90 to -90 degrees:
//#include <SPI.h>
//#include <Wire.h>  
#include <Arduino_LSM6DS3.h>
#include <MadgwickAHRS.h>
#include <Math.h>

float pitchFilteredOld;
Madgwick filter;
const float sensorRate = 104.00;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  if(!IMU.begin())  {
    Serial.println("Failed to initialize IMU!");
    while (1);
  }
  filter.begin(sensorRate);
  Serial.println("Setup complete!");
}  
void loop() {
  float xAcc, yAcc, zAcc;
  float xGyro, yGyro, zGyro;
  float roll, pitch, heading;
  if(IMU.accelerationAvailable() && IMU.gyroscopeAvailable()){
    IMU.readAcceleration(xAcc, yAcc, zAcc);
    IMU.readGyroscope(xGyro, yGyro, zGyro); 
    filter.updateIMU(xGyro, yGyro, zGyro, xAcc, yAcc, zAcc);
    pitch = filter.getPitch();
    float pitchFiltered = 0.1 * pitch + 0.9 * pitchFilteredOld; // low pass filter
    Serial.println("pitch: " + String(pitchFiltered));
    pitchFilteredOld = pitchFiltered;
  }
}


67324: <p>I have an Arduino Nano 33 IoT and I want to get the angle of it using the built-in gyro but I can't seem to find any example code that does this.</p>
<p>The default gyro and accelerometer example code doesn't help. Is it even possible to do this?</p>
 61722: <p>You wil have to calculate the angles. Some trigonometry is required, and for the gyroscopes, also some integration. You can read about it <a href="http://www.starlino.com/imu_guide.html" rel="nofollow noreferrer">here</a>, and in many other places.</p>
<p>You will get the best results if you combine the data from the gyroscopes and the accelerometers using a <em>complementary filter</em>, a <em>Kalman filter</em>, or an other algorithm. These are also easily googled.</p>
<p>There is some example code for the LSM6DS3 IMU on the Nano 33 IoT <a href="https://github.com/owennewo/Arduino_LSM6DS3/blob/master/examples/RollPitchYaw/RollPitchYaw.ino" rel="nofollow noreferrer">here</a> on Github.</p>
 71307: <p>You are supposed to use a filter library on top of the output of the gyro as well as the accelerometer data (both is used!) to get angles ... <a href="https://www.arduinolibraries.info/libraries/madgwick" rel="nofollow noreferrer">https://www.arduinolibraries.info/libraries/madgwick</a></p>
<p>Here is a working example that prints the pitch of the sensor from +90 to -90 degrees:</p>
<pre><code>//#include &lt;SPI.h&gt;
//#include &lt;Wire.h&gt;  
#include &lt;Arduino_LSM6DS3.h&gt;
#include &lt;MadgwickAHRS.h&gt;
#include &lt;Math.h&gt;

float pitchFilteredOld;
Madgwick filter;
const float sensorRate = 104.00;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  if(!IMU.begin())  {
    Serial.println(&quot;Failed to initialize IMU!&quot;);
    while (1);
  }
  filter.begin(sensorRate);
  Serial.println(&quot;Setup complete!&quot;);
}  
void loop() {
  float xAcc, yAcc, zAcc;
  float xGyro, yGyro, zGyro;
  float roll, pitch, heading;
  if(IMU.accelerationAvailable() &amp;&amp; IMU.gyroscopeAvailable()){
    IMU.readAcceleration(xAcc, yAcc, zAcc);
    IMU.readGyroscope(xGyro, yGyro, zGyro); 
    filter.updateIMU(xGyro, yGyro, zGyro, xAcc, yAcc, zAcc);
    pitch = filter.getPitch();
    float pitchFiltered = 0.1 * pitch + 0.9 * pitchFilteredOld; // low pass filter
    Serial.println(&quot;pitch: &quot; + String(pitchFiltered));
    pitchFilteredOld = pitchFiltered;
  }
}
</code></pre>
