W09 -Input Devices

Assignment items

Group assignment


Individual assignment

Tools

The process

Group assignment


Musaed AlKout is the one who had the full process documneted in details, I will cover some highlights in my page.


01: input device's analog levels



02: Pprobe an input device's digital signals


New file in Photoshop

01 |

Tools used for drawing

02|

raster image zoom in

03|

!
  • Feedback:
  • Challenge:

Individual assignment:


01: Add a sensor to a microcontroller board that you have designed and read it


New file in Photoshop

01 | I used MPU 6050 GY-512 which is also part of my final project. I leaned all the information I needed from from Wokwi and strated virtual simulation as I was a way from the lab and wanted to utilise my time to strat this assignemnet.

Tools used for drawing

02| I build the curcit connecting the MPU to the ES32 C3

raster image zoom in

03| from Gemeni Ai I got some guidline on the process to continue

raster image zoom in

04| I added these libraries

raster image zoom in

05| and I included


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

Adafruit_MPU6050 mpu;

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

  // Define I2C pins for ESP32-C3 (SDA=8, SCL=9)
  Wire.setPins(8, 9); 

  if (!mpu.begin()) {
    Serial.println("Failed to find MPU6050 chip");
    while (1) { delay(10); }
  }

  Serial.println("MPU6050 Found!");
  
  // Set sensor ranges (optional)
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);

  delay(100);
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  /* Print out the values */
  Serial.print("Accel X: "); Serial.print(a.acceleration.x);
  Serial.print(", Y: "); Serial.print(a.acceleration.y);
  Serial.print(", Z: "); Serial.print(a.acceleration.z);
  Serial.println(" m/s^2");

  delay(500);
}
					

raster image zoom in

06| I strated teh simulation and strated to see the readings and changed the value

raster image zoom in

07| Then I opened my Kicad file on Schematics Editor and to added the GY-512 as a sinsor and made the connection folowing theis workflow: Look for part → not available → search on SnaPeda → download Symbole&footprint → opne Kicad → Import the library → add the new part → connected pins → mark other pins as "no connect" → run ERC

raster image zoom in

08| Then I updated the PCB Editor and placed the new input sensor

raster image zoom in

09| I tried to place it next to the microcontroller so that my full design fits on a 30mm copper tap which I have access to cut for the curcit.

raster image zoom in

10| for a better cutting results, I made the routs 2mm wide and made sure their is enough space between them to avoid short curcits

raster image zoom in

11| From Kicad, I ploted the PCD as SVG → imported it to Adobe Illustrator → trasformed it to shape → select all shapes → create a union → export as SVG → imported to Cutting Studio → cut the curcit on copper tap.

raster image zoom in

12| This is how the curcit looks after cutting

raster image zoom in

13| here, I connected the MPU to the ESP32 using breadboard

raster image zoom in

12| I use arduion IED to program the ESP32 C3 and I made sure I have the library selected

raster image zoom in

13| I added wchih was used in the. simulation in step 5


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

Adafruit_MPU6050 mpu;

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

  // Define I2C pins for ESP32-C3 (SDA=8, SCL=9)
  Wire.setPins(8, 9); 

  if (!mpu.begin()) {
    Serial.println("Failed to find MPU6050 chip");
    while (1) { delay(10); }
  }

  Serial.println("MPU6050 Found!");
  
  // Set sensor ranges (optional)
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);

  delay(100);
}

void loop() {
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  /* Print out the values */
  Serial.print("Accel X: "); Serial.print(a.acceleration.x);
  Serial.print(", Y: "); Serial.print(a.acceleration.y);
  Serial.print(", Z: "); Serial.print(a.acceleration.z);
  Serial.println(" m/s^2");

  delay(500);
}
					

raster image zoom in

14| I connected the USB to the ESP to start download the program

raster image zoom in

15| I had to rest the microcontroller by pressing the button

raster image zoom in

16| This is the button I pressed, and after few minutes I got the following reading on the IDE

raster image zoom in

17| the readings of x,y, z axies as well as the acceleration of change, to make a better visual, I needed to plot these values to a chart

raster image zoom in

18| For that , I had to add plotting command to my code and I used Gemeni to redefine the code to


// --- SERIAL PLOTTER FORMAT ---
// Format: "Label:Value,Label:Value,Label:Value"
  
  Serial.print("AccelX:"); Serial.print(a.acceleration.x);
  Serial.print(",");
  Serial.print("AccelY:"); Serial.print(a.acceleration.y);
  Serial.print(",");
  Serial.print("AccelZ:"); Serial.print(a.acceleration.z);
					

raster image zoom in

19| After redownloading the new program to the microcontroller, I when to Tool → Serial Plotter

raster image zoom in

20| and I strated to get the readings from the sensor in the graph

raster image zoom in

20|

Now I know what Reco ment by having supper powers ^_^
  • Feedback:I am very confirtable with the workflow i'm following, ther might be easier steps but I guess this is more of a spiral development with lower risk of errors "simulation → Schematics design → PCB design → breadboard unit build→ testing → Cutting PCB → Soldering → final testing → completing"
  • Challenge:I cannot be in the lab all the time so the virtual simulation and the finlizing the work on the laptop until I reach the lab is both helpfull and uncertain as it all depends on my search and hypothesis and might lead me to repeat all the work again