Arduino UNO with MPU-6050 Sensor Array and Multiplexer Control Circuit
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit in question is designed around an Arduino UNO microcontroller, which serves as the central processing unit. The circuit includes multiple MPU-6050 sensors, which are 6-axis motion tracking devices that combine a 3-axis gyroscope and a 3-axis accelerometer. The circuit also features an HCF4052BE analog multiplexer/demultiplexer for signal routing, resistors for current limiting and voltage division, NPN transistors for switching, and LEDs for visual indication. The Arduino UNO is programmed to interface with the sensors and communicate with external devices via Bluetooth and Wi-Fi using software serial communication.
Component List
Microcontroller
- Arduino UNO: A microcontroller board based on the ATmega328P, with a variety of digital and analog I/O pins.
Sensors
- MPU-6050: A 6-axis motion tracking device that combines a 3-axis gyroscope and a 3-axis accelerometer.
Multiplexer
- HCF4052BE ANALOG MULTIPLEXER/DEMULTIPLEXER: A dual 4-channel analog multiplexer/demultiplexer used for signal routing.
Resistors
- 200 Ohm Resistors: Used for current limiting and voltage division in the circuit.
- 1k Ohm Resistor: Used for current limiting and voltage division in the circuit.
Transistors
- NPN Transistor (CBE): A bipolar junction transistor used for switching applications.
LEDs
- LED (Red): A red light-emitting diode used for visual indication.
- LED (Green): A green light-emitting diode used for visual indication.
Comments
- Comment: Textual annotations used for notes or explanations within the circuit design (not physical components).
Wiring Details
Arduino UNO
- 5V pin connected to VDD of HCF4052BE and VCC of MPU-6050 sensors.
- GND pin connected to GND of MPU-6050 sensors and common ground for the circuit.
- SCL pin connected to Y COMMON of HCF4052BE.
- SDA pin connected to X COMMON of HCF4052BE.
- Digital pins D8, D9, and D12 connected to resistors.
MPU-6050 Sensors
- SCL and SDA pins connected to the HCF4052BE for I2C communication.
- VCC pins connected to 5V supply through a 1k Ohm resistor.
- GND pins connected to the common ground.
HCF4052BE ANALOG MULTIPLEXER/DEMULTIPLEXER
- Y0, Y3, X0, and X3 pins connected to SCL and SDA of MPU-6050 sensors for multiplexing I2C signals.
- VDD pin connected to 5V supply through a 1k Ohm resistor.
- Y COMMON and X COMMON pins connected to SCL and SDA of Arduino UNO for I2C communication.
- INH and VSS pins connected to the collector of the NPN transistor and common ground, respectively.
- B pin connected to the emitter of the NPN transistor.
Resistors
- 200 Ohm resistors connected to LEDs and digital pins of Arduino UNO.
- 1k Ohm resistor connected to VDD of HCF4052BE and VCC of MPU-6050 sensors.
NPN Transistor (CBE)
- Collector connected to INH and VSS of HCF4052BE.
- Base connected to a 200 Ohm resistor.
- Emitter connected to B pin of HCF4052BE and a 1k Ohm resistor.
LEDs
- Anode of red LED connected to the collector of the NPN transistor.
- Cathode of red LED connected to a 200 Ohm resistor.
- Anode of green LED connected to the collector of the NPN transistor.
- Cathode of green LED connected to a 200 Ohm resistor.
Documented Code
#include <Wire.h>
#include <Adafruit_MPR121.h>
#include <Adafruit_ADXL345_U.h>
#include <MPU6050.h>
#include <SoftwareSerial.h>
// Initialize Sensors
Adafruit_MPR121 capSensor = Adafruit_MPR121();
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
MPU6050 mpu;
// Pins for Bluetooth and Wi-Fi modules
const int BT_TX = 10; // Arduino TX to HC-05 RX
const int BT_RX = 11; // Arduino RX to HC-05 TX
const int WIFI_TX = 8; // Arduino TX to ESP8266 RX
const int WIFI_RX = 9; // Arduino RX to ESP8266 TX
// SoftwareSerial for Bluetooth and Wi-Fi modules
SoftwareSerial BTSerial(BT_TX, BT_RX);
SoftwareSerial WifiSerial(WIFI_TX, WIFI_RX);
// Microphone Pin
const int micPin = A0;
void setup() {
Serial.begin(9600);
// Initialize Bluetooth and Wi-Fi serial communication
BTSerial.begin(9600);
WifiSerial.begin(9600);
// Initialize MPR121 capacitive sensor
if (!capSensor.begin(0x5A)) {
Serial.println("MPR121 not found, check wiring?");
while (1);
}
// Initialize ADXL345 accelerometer
if (!accel.begin()) {
Serial.println("ADXL345 not found, check wiring?");
while (1);
}
// Initialize MPU6050 gyroscope
Wire.begin();
mpu.initialize();
if (!mpu.testConnection()) {
Serial.println("MPU6050 not found, check wiring?");
while (1);
}
// Setup microphone pin
pinMode(micPin, INPUT);
}
void loop() {
// Read capacitive sensor
uint16_t touch = capSensor.touched();
for (uint8_t i = 0; i < 12; i++) {
if (touch & (1 << i)) {
Serial.print("Capacitive Sensor "); Serial.print(i); Serial.println(" touched");
BTSerial.print("Sensor "); BTSerial.print(i); BTSerial.println(" touched");
}
}
// Read accelerometer data
sensors_event_t event;
accel.getEvent(&event);
Serial.print("Accel X: "); Serial.print(event.acceleration.x);
Serial.print(" Y: "); Serial.print(event.acceleration.y);
Serial.print(" Z: "); Serial.println(event.acceleration.z);
// Read gyroscope data
int16_t gx, gy, gz;
mpu.getRotation(&gx, &gy, &gz);
Serial.print("Gyro X: "); Serial.print(gx);
Serial.print(" Y: "); Serial.print(gy);
Serial.print(" Z: "); Serial.println(gz);
// Read microphone
int micValue = analogRead(micPin);
Serial.print("Mic Value: "); Serial.println(micValue);
// Transmit data via Bluetooth and Wi-Fi
BTSerial.print("Accel X: "); BTSerial.print(event.acceleration.x);
BTSerial.print(" Y: "); BTSerial.print(event.acceleration.y);
BTSerial.print(" Z: "); BTSerial.println(event.acceleration.z);
WifiSerial.print("Gyro X: "); WifiSerial.print(gx);
WifiSerial.print(" Y: "); WifiSerial.print(gy);
WifiSerial.print(" Z: "); WifiSerial.println(gz);
// Small delay
delay(500);
}
This code is designed to run on the Arduino UNO microcontroller. It initializes and reads data from capacitive, accelerometer, and gyroscope sensors, and transmits the data via Bluetooth and Wi-Fi using software serial communication. It also includes a microphone input for additional data acquisition.