An input device is a part that provides information, data or control signals to a system, in this case a
microcontroller. For this week I will be using a sensor as an input for my XIAO RP2040 PCB.
Here you can find the Group Site
The sensors are input devices that provides an output with relation of a physical quantity.
Device that converts signals from one energy domain to electrical.
There are a lot of different sensors depending on the application you want.
Like the sensor it's going to be on the tip of the index finger and I don't want to use dupont cables I will make a simple PCB with cupper tape as in
week 4. The board will only have the 4 input/output pads to connect the MPU with the XIAO. It is important to have this part flexible to start
making test of how the circuit will be mounted and start thinking about the mecanism to let slide the circuit.
First we add 8 pads in Kicad and name them as 5V, GND, SCL and SDA for both cases, then we can go to the PCB where we arrange them like we want to be. In
this case my finger is 100mm ling and the sensor has to be aligned to my finger for comodity.
First we have to install different libraries for using it.
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
MPU6050 sensor;
int16_t ax, ay, az;
int16_t gx, gy, gz;
void setup() {
Serial.begin(9600);
Wire.begin();
sensor.initialize();
if (sensor.testConnection())
Serial.println("Sensor initialized successfully");
else
Serial.println("Error initializing the sensor");
}
void loop() {
sensor.getAcceleration(&ax, &ay, &az);
sensor.getRotation(&gx, &gy, &gz);
Serial.print("a[x y z] g[x y z]:\t");
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.println(gz);
delay(1000);
}
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
MPU6050 sensor;
int16_t ax, ay, az; // Variables to store accelerometer data
int16_t gx, gy, gz; // Variables to store gyroscope data
void setup() {
Serial.begin(9600);
// Initialize serial communication
Wire.begin();
// Initialize I2C communication
sensor.initialize();
// Initialize MPU6050 sensor
if (sensor.testConnection())
// Check if the sensor is connected
Serial.println("Sensor initialized successfully");
// Print message if sensor is connected
else
Serial.println("Error initializing the sensor");
// Print error message if sensor is not connected
}
sensor.getAcceleration(&ax, &ay, &az);
// Read accelerometer data
sensor.getRotation(&gx, &gy, &gz);
// Read gyroscope data
Serial.print("a[x y z] g[x y z]:\t");
// Print header for data
Serial.print(ax); Serial.print("\t");
// Print accelerometer data along x-axis
Serial.print(ay); Serial.print("\t");
// Print accelerometer data along y-axis
Serial.print(az); Serial.print("\t");
// Print accelerometer data along z-axis
Serial.print(gx); Serial.print("\t");
// Print gyroscope data along x-axis
Serial.print(gy); Serial.print("\t");
// Print gyroscope data along y-axis
Serial.println(gz);
// Print gyroscope data along z-axis
delay(1000); // Delay for 1 second
First
After getting the sensor in one finger I realized I need a way to hold it to the knuckle for prevent of moving, also
I need a rail or something in the glove to prevent horizontal movements as well as a bridge that let the pcb slide when the
finger moves because it changes it's lenght.
Second
The lectures of the sensor aren't very precise when I don't move my hand it start changing it's value. So I found another sensor
that can help me with this problem because it has a 9 DoF, it add a 3 axis magnometer to prevent moving when holding it still, the
BNO08x.
Also for detecting if the other fingers are flex or straight I used flex sensors. I attach them to my finger using
tubular mesh.
For my final project I need to reed the value from these different sensors, so lets make it, first the PCB: