Probe an input device(s)'s analog levels and digital signals.
Document your work on the group work page and reflect on your individual page what you learned
Individual Assignment:
Measure something: add a sensor to a microcontroller board that you have designed and read it.
Have you answered these questions?
Linked to the group assignment page ✅
Documented what you learned from interfacing an input device(s) to your microcontroller and optionally, how the physical property relates to the measured results. ✅
Documented your design and fabrication process or linked to the board you made in a previous assignment. ✅
Explained the programming process(es) you used. ✅
Explained any problems you encountered and how you fixed them. ✅
Included original design files and source code. ✅
Included a ‘hero shot’ of your board. ✅
Group Assignment
Probe an input device(s)'s analog levels and digital signals.
Document your work on the group work page and reflect on your individual page what you learned
In this group assignment, we joined a group of colleagues from the academy to use an oscilloscope to demonstrate the signals generated by some electronic devices, observing and comparing the analog and digital signals generated by the sensors. This allowed us to discuss adjustments, optimize our implementations, and identify similarities and differences in the results.
The instructors, Ulises and Roberto, showed us the function of electronics by testing input devices. The class was very clear and dynamic. I'm sharing the link so you can access this training. This class helps you understand the basic concepts of electronics and the tests that can be performed.
Reflections
During the process of making the board as an exercise, it was not complicated, but I had to do some tests before working the milling process with the real board, the movement tests, the displacement, as well as the calibration of the X,Y,Z axes were essential to ensure the displacement of the axes with precision and thus obtain better results for the manufacturing of our PCB.
The PCB manufacturing process with PCBWay is quite simple and automated, ideal for both prototypes and mass production. You just need to have the file ready in the software being used for the design, in our case kiCAD, and then generate a manufacturing file called Gerber. This file is then uploaded to the PCBway website where you can enter various data such as the number of layers, dimensions, PCB thickness, among others. I think it's a good option, but production using our own CNC PCB machines is even better.
Individual Assignment
Measure something: add a sensor to a microcontroller board that you have designed and read it.
This week's topic is measuring input devices. For this, we attended a class taught by instructors Ulises and Roberto. This class was quite dynamic, as several measuring instruments, such as a multimeter, were used. Performing these measurements will help us understand several key concepts useful for the task.
After showing the electronic components that make up the board, the PBC board editor is shown in the Kid Cat software.
We performed several simulations using Wokwi, an online electronics and embedded systems simulator that allows you to develop and test projects with microcontrollers such as Arduino, ESP32, STM32, and Raspberry Pi Pico, among others. Below are some exercises we developed with Instructor Ulises.
Exercise 1 using Wokwi simulator
In this exercise we learned how to use code in MicroPython, using the Wokwi online simulator to blink an LED.
This is the code I used:
from machine import Pin
from time import sleep
print("Hello, Fab Academy 2025!")
pinLed = Pin(3, Pin.OUT)
while True:
#pinled.toggle()
pinLed.value(0)
print("Apagado")
sleep(1.0)
pinLed.value(1)
print("Encendido")
sleep(1.0)
Exercise 2
For this exercise, we add a push button to the circuit shown in exercise 1, which controls the LED turning on and off.
This is the code I used:
from machine import Pin
from time import sleep
print("Hello, Fab Academy 2025!")
pinLed = Pin(3, Pin.OUT)
pinBut = Pin(26, Pin.IN)
while True:
print(pinBut.value())
pinLed.value(pinBut.value())
sleep(0.5)
Exercise 3:
For this exercise, we worked with the XIAO ESP32-C3 microcontroller and the MPU6050, a sensor that combines a 3-axis accelerometer and gyroscope in a single chip. It is used to measure acceleration, angular velocity, and 6-degree-of-freedom motion. The MPU6050 communicates via the I2C interface.
This is the code I used:
#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
// Variables para inclinación
float anguloX, anguloY;
unsigned long tiempoPrev;
float dt;
void setup() {
Serial.begin(115200);
Wire.begin();
mpu.initialize();
if (mpu.testConnection()) {
Serial.println("MPU6050 conectado correctamente");
} else {
Serial.println("Error al conectar MPU6050");
while (1);
}
// Calibración inicial (dejar el sensor quieto 3 segundos)
Serial.println("Calibrando... No muevas el sensor");
delay(3000);
tiempoPrev = millis();
}
void loop() {
// Leer datos del giroscopio y acelerómetro
int16_t ax, ay, az, gx, gy, gz;
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
// Calcular intervalos de tiempo
dt = (millis() - tiempoPrev) / 1000.0;
tiempoPrev = millis();
// Convertir a valores útiles
float aceleracionX = ax / 16384.0; // Escala ±2g
float aceleracionY = ay / 16384.0;
float giroX = gx / 131.0; // Escala ±250°/s
float giroY = gy / 131.0;
// Calcular ángulos de inclinación (filtro complementario)
anguloX = 0.98 * (anguloX + giroX * dt) + 0.02 * atan2(aceleracionY, sqrt(aceleracionX * aceleracionX + az / 16384.0 * az / 16384.0)) * 180 / PI;
anguloY = 0.98 * (anguloY + giroY * dt) + 0.02 * atan2(aceleracionX, sqrt(aceleracionY * aceleracionY + az / 16384.0 * az / 16384.0)) * 180 / PI;
// Mostrar resultados en Serial
Serial.print("Inclinación X: "); Serial.print(anguloX); Serial.print("° | ");
Serial.print("Y: "); Serial.print(anguloY); Serial.println("°");
Serial.print("Giro X: "); Serial.print(giroX); Serial.print("°/s | ");
Serial.print("Y: "); Serial.print(giroY); Serial.println("°/s");
Serial.println("---------------------");
delay(200); // Ajusta este delay para mayor/menor frecuencia de lectura
}
Sensor Measurement with DHT11
The DHT11 sensor combines temperature and humidity in a compact design. It measures temperatures from 0°C to 50°C with an accuracy of ±2°C and relative humidities from 20% to 90% with an accuracy of ±5%. Thanks to its low sampling rate, the sensor only provides new readings every two seconds, making it ideal for long-term measurements. The DHT11 is easy to integrate into microcontroller platforms such as Arduino and Raspberry Pi and requires no additional calibration thanks to its factory calibration. Its robust design and reliability make it the ideal choice for continuous monitoring projects such as greenhouses, HVAC systems, and warehouse monitoring.
DHT11 Sensor Specifications
Temperature range: 0°C to 50°C ±2°C
Humidity range: 20% to 90% RH ±5%
Operating voltage: 3.3V to 5.5V
Digital output signal
Sampling rate: 1 reading every second
Low power consumption
4-pin single row package
Compact size and easy to use
Objective
Measure temperature and humidity using the DHT11 sensor connected to a microcontroller board (XIAO ESP32-C3).
Materials
DHT11 Sensor
XIAO ESP32-C3 or Arduino Uno
USB cable
Arduino IDE
Connections
DHT11 Pin
Microcontroller Pin
VCC
3.3V or 5V
DATA
GPIO 2
GND
GND
Arduino Code
// Bit‑banging DHT11 without external library
const int DHpin = 2; // Use GPIO2 (adjust if needed)
byte dat[5]; // [hum_int, hum_dec, temp_int, temp_dec, checksum]
void setup() {
Serial.begin(115200);
pinMode(DHpin, OUTPUT);
digitalWrite(DHpin, HIGH); // Bus idle high
}
byte read_data() {
byte result = 0;
for (int i = 0; i < 8; i++) {
while (digitalRead(DHpin) == LOW);
delayMicroseconds(30);
if (digitalRead(DHpin) == HIGH)
result |= (1 << (7 - i)); // MSB first
while (digitalRead(DHpin) == HIGH);
}
return result;
}
void start_test() {
digitalWrite(DHpin, LOW);
delay(20); // >18ms for DHT11
digitalWrite(DHpin, HIGH);
delayMicroseconds(40);
pinMode(DHpin, INPUT);
while (digitalRead(DHpin) == HIGH);
delayMicroseconds(80);
for (int i = 0; i < 5; i++)
dat[i] = read_data();
pinMode(DHpin, OUTPUT);
digitalWrite(DHpin, HIGH);
}
void loop() {
start_test();
byte checksum = dat[0] + dat[1] + dat[2] + dat[3];
if (dat[4] != checksum) {
Serial.println("Error de checksum!");
delay(2000);
return;
}
Serial.print("Humedad: ");
Serial.print(dat[0]);
Serial.print(".");
Serial.print(dat[1]);
Serial.println("%");
Serial.print("Temperatura: ");
Serial.print(dat[2]);
Serial.print(".");
Serial.print(dat[3]);
Serial.println("°C");
delay(2000);
}
Results
Use the Serial Monitor to view live data:
Temperature in °C
Humidity in %
This demonstration shows how the DHT11 sensor measures temperature and humidity. The sensor sends data to a microcontroller through a digital signal, and the results are displayed in real time using a serial monitor or graphical plot.
Impact Sensor KY-031
The KY-031 module is better known as the Impact Sensor. This sensor is capable of detecting impacts that it or a surface attached to it may receive.
It operates as a normally open contact, sending a logic "1" through its signal terminal the instant it receives physical contact.
KY-031 Impact Sensor Specifications
Operating voltage: 3.3V to 5V
Digital output
Output type: High when idle, Low when impact detected
Built-in LM393 voltage comparator
Adjustable sensitivity via onboard potentiometer
Mounting hole for easy installation
3-pin interface: VCC, GND, and D0 (signal)
Compact and easy to integrate into projects
Objective
Measure the digital signals generated by the Impact Sensor KY-031 when it detects a shock or vibration, and display the data on the serial monitor or Serial Plotter.
Required Materials
KY-031 Impact Sensor Module
ESP32-C3 XIAO
USB cable for uploading code
Computer with Arduino IDE installed
Connections
KY-031 Pin
Microcontroller Pin
VCC
3.3V or 5V
GND
GND
DO (Digital Output)
GPIO 2
This is the code I used:
const int Shock = 2; // KY-031 en GPIO2
int val; // Variable para leer el sensor
void setup() {
pinMode(Shock, INPUT);
Serial.begin(115200);
}
void loop() {
val = digitalRead(Shock);
if(val == HIGH) {
Serial.println("GOLPE REAL");
delay(100);
}
else {
Serial.println("sin golpe");
delay(100);
}
}
in In this video you can see that the sensor emits a digital signal: HIGH when it does not detect an impact and LOW when it detects a blow