Miguel Montiel Vega
Published

Integration of the RAK12033 Sensor into the Laboratory Monit

Add real-time vibration & motion detection to your lab with the RAK12033 6-axis sensor, improving safety and monitoring.

IntermediateWork in progress6 hours11
Integration of the RAK12033 Sensor into the Laboratory Monit

Things used in this project

Hardware components

rak12033
×1

Software apps and online services

Arduino IDE
Arduino IDE
The Things Stack
The Things Industries The Things Stack

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Code

Integration of the RAK12033 Sensor into the Laboratory Monitoring System

C/C++
#include <IIM42652.h>
IIM42652 iim;  // 6-axis sensor

float accel_x = 0.0, accel_y = 0.0, accel_z = 0.0;
float gyro_x = 0.0, gyro_y = 0.0, gyro_z = 0.0;
if (!iim.begin()) {
    Serial.println("IIM-42652 not found. Check connections.");
    while (1);
}
Serial.println("IIM-42652 initialized successfully.");
iim.readSensor();

// Accelerometer
accel_x = iim.getAccelX();
accel_y = iim.getAccelY();
accel_z = iim.getAccelZ();

// Gyroscope
gyro_x = iim.getGyroX();
gyro_y = iim.getGyroY();
gyro_z = iim.getGyroZ();

// Print to serial monitor (for debugging)
Serial.printf("Accel X: %.2f, Y: %.2f, Z: %.2f\n", accel_x, accel_y, accel_z);
Serial.printf("Gyro X: %.2f, Y: %.2f, Z: %.2f\n", gyro_x, gyro_y, gyro_z);
int16_t accZ_int = (int16_t)(accel_z * 1000); // multiply by 1000 to keep 3 decimal places
payload[payload_idx++] = (uint8_t)(accZ_int >> 8);
payload[payload_idx++] = (uint8_t)(accZ_int & 0xFF);

int16_t gyroZ_int = (int16_t)(gyro_z * 1000);
payload[payload_idx++] = (uint8_t)(gyroZ_int >> 8);
payload[payload_idx++] = (uint8_t)(gyroZ_int & 0xFF);
// u8g2.setCursor(0, 60); u8g2.printf("AccZ: %.2f", accel_z);

Credits

Miguel Montiel Vega
11 projects • 8 followers
Teacher at Maude Studio & Erasmus+ project member: "Developing Solutions to Sustainability Using IoT" (2022-1-PT01-KA220-VET-000090202)

Comments