RAK12033 WisBlock 6-Axis Accelerometer Sensor Module Quick Start Guide
Prerequisite
-
Assemble the RAK12033 with a WisBlock Base and WisBlock Core by following the RAK12033 Installation Guide.
-
Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
-
USB Cable
Initial Test of the RAK12033 WisBlock Module
-
This guide uses the RAK4631 WisBlock Core to demonstrate the configuration process. You can also use the RAK11200 or RAK11310 as the WisBlock Core.
-
When using the RAK11200, configure the BOOT0 pin correctly before uploading the source code. Otherwise, the upload may fail. For detailed instructions, refer to the RAK11200 Quick Start Guide.
-
Install the RAKwireless Arduino BSP for WisBlock by using the
package_rakwireless_index.jsonboard installation package, the WisBlock Core should now be available on the Arduino IDE. -
You need to select the WisBlock Core you have.
Figure 1: Selecting RAK4631 as WisBlock Core- Next, copy the following sample code into your Arduino IDE:
Click to view the code
/**
@file RAK12033_6_Axis_BasicReadings_IIM_42652.ino
@author rakwireless.com
@brief Get IIM-42652 sensor data and output data on the serial port.
@version 0.1
@date 2021-12-28
@copyright Copyright (c) 2021
**/
#include "RAK12033-IIM42652.h"
IIM42652 IMU;
void setup()
{
time_t timeout = millis();
// Initialize Serial for debug output.
Serial.begin(115200);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
Serial.println("RAK12033 Basic Reading example.");
Wire.begin();
if (IMU.begin() == false)
{
while (1)
{
Serial.println("IIM-42652 is not connected.");
delay(5000);
}
}
}
void loop()
{
IIM42652_axis_t accel_data;
IIM42652_axis_t gyro_data;
float temp;
float acc_x ,acc_y ,acc_z;
float gyro_x,gyro_y,gyro_z;
IMU.ex_idle();
IMU.accelerometer_enable();
IMU.gyroscope_enable();
IMU.temperature_enable();
delay(100);
IMU.get_accel_data(&accel_data );
IMU.get_gyro_data(&gyro_data );
IMU.get_temperature(&temp );
/*
* ±16 g : 2048 LSB/g
* ±8 g : 4096 LSB/g
* ±4 g : 8192 LSB/g
* ±2 g : 16384 LSB/g
*/
acc_x = (float)accel_data.x / 2048;
acc_y = (float)accel_data.y / 2048;
acc_z = (float)accel_data.z / 2048;
Serial.print("Accel X: ");
Serial.print(acc_x);
Serial.print("[g] Y: ");
Serial.print(acc_y);
Serial.print("[g] Z: ");
Serial.print(acc_z);
Serial.println("[g]");
/*
* ±2000 º/s : 16.4 LSB/(º/s)
* ±1000 º/s : 32.8 LSB/(º/s)
* ±500 º/s : 65.5 LSB/(º/s)
* ±250 º/s : 131 LSB/(º/s)
* ±125 º/s : 262 LSB/(º/s)
* ±62.5 º/s : 524.3 LSB/(º/s)
* ±31.25 º/s : 1048.6 LSB/(º/s)
* ±15.625 º/s : 2097.2 LSB/(º/s)
*/
gyro_x = (float)gyro_data.x / 16.4;
gyro_y = (float)gyro_data.y / 16.4;
gyro_z = (float)gyro_data.z / 16.4;
Serial.print("Gyro X:");
Serial.print(gyro_x);
Serial.print("º/s Y: ");
Serial.print(gyro_y);
Serial.print("º/s Z: ");
Serial.print(gyro_z);
Serial.println("º/s");
Serial.print("Temper : ");
Serial.print(temp);
Serial.println("[ºC]");
IMU.accelerometer_disable();
IMU.gyroscope_disable();
IMU.temperature_disable();
IMU.idle();
delay(2000);
}
If you experience any error in compiling the example sketch, check the updated code for your WisBlock Core Module that can be found on the RAK12033 WisBlock Example Code Repository and this sample code in Github will work on all WisBlock Core.
- Once the example code is open, install the RAK12033-IIM42652 library.
Figure 1: Installing RAK12033 sensor library- After successful installation of the library, you can now select the right serial port and upload the code.
Figure 1: Selecting the correct serial port
Figure 1: Uploading the RAK12033 example code- When you have successfully uploaded the example sketch, open the serial monitor of the Arduino IDE to see the sensor's reading logs. If you see the logs, then your RAK12033 is communicating with the WisBlock core properly.
Figure 1: RAK12033 6-Axis Accelerometer Sensor Module Data Logs