The circuit in question is designed to interface a SparkFun Pro Micro microcontroller with a BMI160 6DOF sensor and two 24LC512 EEPROM chips. It is powered by a Polymer Lithium Ion Battery with a capacity of 850mAh. The Pro Micro is responsible for processing data from the BMI160 sensor and communicating with the EEPROM chips via I2C protocol. The battery provides the necessary power to the microcontroller and other components. The circuit is likely intended for applications requiring motion tracking and data storage capabilities.
RAW
connected to the positive terminal of the Polymer Lithium Ion BatteryGND
connected to the ground plane of the circuitD2
(SDA) and D3
(SCL) connected to the I2C bus for communication with EEPROMs and BMI160 sensorD7
connected to the INT1
pin of the BMI160 sensor for interrupt-driven eventsA0
, A1
, A2
connected to the ground plane for address selection (assuming address grounding)Vss
connected to the ground planeVcc
connected to the positive voltage railWP
connected to the ground plane (write protection disabled)SCL
and SDA
connected to the I2C busGND
connected to the ground planeVIN
connected to the positive voltage railSDA
and SCL
connected to the I2C busINT1
connected to D7
on the SparkFun Pro Micro for interruptsVCC
connected to the RAW
pin of the SparkFun Pro MicroGND
connected to the ground plane of the circuit#include <BMI160Gen.h>
// Requires https://github.com/hanyazou/BMI160-Arduino
const int bmi160_i2c_addr = 0x69;
const int bmi160_interrupt_pin = 7;
bool running = false;
int RXLED = 17;
unsigned long miPoll, miPrint = 1000;
int16_t absx, absy, absz;
int ax, ay, az;
//int gx, gy, gz;
#define runEvery(t) for (static typeof(t) _lasttime; \
(typeof(t))((typeof(t))millis() - _lasttime) > (t); \
_lasttime += (t))
void bmi160_intr(void)
{
running = !running;
if(running) {
digitalWrite(RXLED, LOW); // RX LED on!
TXLED1; //TX LED ON Macro
} else {
digitalWrite(RXLED, HIGH); // RX LED on!
TXLED0;
}
}
void setup() {
Serial.begin(9600);
while (!Serial);
// initialize device
BMI160.begin(BMI160GenClass::I2C_MODE, bmi160_i2c_addr, bmi160_interrupt_pin);
BMI160.attachInterrupt(bmi160_intr);
BMI160.setIntDoubleTapEnabled(true);
BMI160.autoCalibrateGyroOffset();
BMI160.autoCalibrateXAccelOffset(0);
BMI160.autoCalibrateYAccelOffset(0);
BMI160.autoCalibrateZAccelOffset(1);
BMI160.setGyroOffsetEnabled(true);
BMI160.setAccelOffsetEnabled(true);
miPoll = 1000/BMI160.getAccelerometerRate();
digitalWrite(RXLED, HIGH);
TXLED0;
}
void loop() {
if (running) {
runEvery(miPoll) {
BMI160.readGyro(ax, ay, az);
absx = absx + ax;
absy = absy + ay;
absz = absz + az;
}
runEvery(miPrint) {
Serial.print(absx); Serial.print("\t");
Serial.print(absy); Serial.print("\t");
Serial.println(absz);
}
}
}
This code is designed to run on the SparkFun Pro Micro microcontroller. It initializes the BMI160 sensor, sets up interrupt handling for motion detection, and periodically reads gyroscopic data, outputting the accumulated values over the serial connection. The LED indicators are used to signal the running state of the device.