Create a simple seismograph with BMI160 6-DOF

Using the BMI160 6-DOF (Degrees of Freedom) Accelerometer and Gyroscope Module is a much better option than a microphone for a DIY seismograph! The BMI160 has a 3-axis accelerometer and a 3-axis gyroscope, which allows it to detect minute changes in acceleration and orientation. With the ESP8266, you can create a simple seismograph that measures and logs tremors, vibrations, and even tilt changes with this setup.

Advantages of Using the BMI160

  1. High Sensitivity to Small Movements: It’s designed to detect subtle changes in acceleration and orientation, making it suitable for measuring vibrations.
  2. 6 DOF (Degrees of Freedom): With both accelerometer and gyroscope, it provides more comprehensive data than a microphone, allowing you to capture vibrations on three axes (X, Y, and Z).
  3. Low Power Consumption: The BMI160 is energy-efficient, which makes it ideal for continuous monitoring applications like a seismograph.

What You’ll Need

  1. ESP8266 (like NodeMCU or ESP-01)
  2. BMI160 6 DOF IMU Module
  3. Breadboard and Jumper Wires
  4. Optional: LED, Buzzer, or OLED display for alerts or real-time data

Step-by-Step Guide

1. Connecting the BMI160 to the ESP8266

The BMI160 typically uses I2C or SPI for communication. I2C is simpler, so we’ll go with that.

  • Connect VCC on the BMI160 to 3.3V on the ESP8266.
  • Connect GND on the BMI160 to GND on the ESP8266.
  • Connect SDA on the BMI160 to D2 on the ESP8266 (GPIO4).
  • Connect SCL on the BMI160 to D1 on the ESP8266 (GPIO5).

2. Installing Required Libraries

To use the BMI160, you can use the Adafruit BMI160 library in the Arduino IDE. Install this via the Library Manager:

  1. Go to Sketch > Include Library > Manage Libraries…
  2. Search for Adafruit BMI160 and install it.

3. Code for Reading Accelerometer Data

Here’s a basic example of code to read the accelerometer values (acceleration in X, Y, Z axes) from the BMI160, which can then be used to detect vibrations:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMI160.h>

Adafruit_BMI160 bmi160;

void setup() {
  Serial.begin(115200);

  // Initialize the BMI160 sensor
  if (!bmi160.begin(BMI160_I2C_ADDR, &Wire)) {
    Serial.println("Could not find a valid BMI160 sensor, check wiring!");
    while (1);
  }

  bmi160.setAccelRange(BMI160_ACCELRANGE_2G);  // Set range to 2G for more sensitivity
}

void loop() {
  // Get accelerometer readings
  sensors_event_t accelEvent;
  bmi160.getEvent(&accelEvent, NULL, NULL);

  float accelX = accelEvent.acceleration.x;  // Acceleration in X-axis
  float accelY = accelEvent.acceleration.y;  // Acceleration in Y-axis
  float accelZ = accelEvent.acceleration.z;  // Acceleration in Z-axis

  Serial.print("X: "); Serial.print(accelX); Serial.print(" m/s² ");
  Serial.print("Y: "); Serial.print(accelY); Serial.print(" m/s² ");
  Serial.print("Z: "); Serial.print(accelZ); Serial.println(" m/s²");

  // Threshold-based vibration detection
  float threshold = 0.1;  // Adjust threshold based on sensitivity
  if (abs(accelX) > threshold || abs(accelY) > threshold || abs(accelZ) > threshold) {
    Serial.println("Vibration Detected!");
  }

  delay(50);  // Adjust sampling frequency as needed
}

Explanation of the Code

  • Initialize the BMI160: This checks the connection with the BMI160 and sets the accelerometer range (2G is the most sensitive, suitable for small vibrations).
  • Read Acceleration: Reads acceleration in each axis (X, Y, Z). The values are in m/s² (meters per second squared).
  • Threshold Detection: If any of the acceleration values exceed a set threshold (0.1 m/s² in this example), it logs a “Vibration Detected!” message. You can adjust this threshold based on your environment to avoid false positives.

4. Optional: Data Logging or Real-Time Visualization

  • Logging Data: You can send the data over Wi-Fi (e.g., to a server or cloud service) for long-term monitoring.
  • OLED Display: If you add a small OLED display, you can view real-time data on-site.
  • Alerts: Connect an LED or buzzer to trigger whenever a vibration is detected.

5. Fine-Tuning the Sensitivity

You may need to experiment with:

  • Accelerometer Range: Setting it to 2G gives more sensitivity to small vibrations, while 4G or 8G can capture more intense movements.
  • Sampling Frequency: Increasing the sampling rate (by reducing delay() in loop()) allows for detecting fast, short vibrations.

Limitations and Notes

  • Vibration Resolution: The BMI160 has good resolution, but it’s not as sensitive as professional seismometers. However, it should be able to pick up noticeable tremors and vibrations.
  • Noise Filtering: You can filter noise using a moving average or low-pass filter in code to reduce background noise and focus on specific vibrations.

Conclusion

This setup with the BMI160 and ESP8266 should give you a basic yet effective vibration-sensing system that behaves similarly to a simple seismograph. It can detect various vibrations and small movements and can be enhanced with Wi-Fi logging for remote monitoring.