Group Assignment:

  • send a message between two projects
  • Document your work to the group work page and reflect on your individual page what you learned

Individual Assignment:

  • design, build and connect wired or wireless node(s) with network or bus addresses and a local input and/or output devices
Have you answered these questions?
Linked to the group assignment page ✅
Documented your project and what you have learned from implementing networking and/or communication protocols.✅
Explained the programming process(es) you used. ✅
Ensured and documented that your addressing for boards works. ✅
Outlined problems and how you fixed them.✅
Included design files (or linked to where they are located if you are using a board you have designed and fabricated earlier) and original source code.✅
Included a ‘hero shot’ of your network and/or communications setup.✅

Group assignment

  • send a message between two projects
  • Document your work on the group work page and reflect on your individual page what you learned
  • Group Training

    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.

    Individual assignment

    • design, build and connect wired or wireless node(s) with network or bus addresses and a local input and/or output devices

    We started week 11, and our instructor, Ulises, gave us a masterclass on embedded networks and communications. In the video, he offers a detailed explanation of the MQTT protocol, programming for sensor and module operation, the roles of publishers and subscribers, and how to manage the Arduino IDE development environment.

    Link to watch the video.

    MQTT

    MQTT (Message Queuing Telemetry Transport) is a messaging protocol for restricted low-bandwidth networks and extremely high-latency IoT devices. Since Message Queuing Telemetry Transport is specialized for low-bandwidth, high-latency environments, it is an ideal protocol for machine-to-machine (M2M) communication. online simulator to blink an LED.MQTT consists of several layers within networking and communication. Networks enable the interconnection of devices in various configurations, facilitating communication between them. Communication protocols operate at different layers of the OSI model. The transport layer, such as TCP (Transmission Control Protocol), is responsible for ensuring the reliable transmission of data between devices. Meanwhile, the network layer, such as IP (Internet Protocol), handles packet addressing across the network.

    MQTT operates in the application layer, which is a higher layer in the OSI model. This means that MQTT relies on transport protocols like TCP for message transmission between devices. Within the communication protocols, MQTT uses a broker, which is a central server that facilitates communication between devices such as sensors, controllers, and users.

    1. Download MQTT

    The first thing I do is go to the website MQTT and click on the "Download" button.

    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)
    

    This is the code I used:

    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.

    
    #include 
    #include 
    													
    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
    }
    												

    connection diagram:

    📊 DHT11 Sensor Technical Specifications
    Sensor type Digital temperature and humidity
    Temperature range 0 – 50 °C
    Temperature accuracy ±2 °C
    Humidity range 20% – 90% HR
    Humidity accuracy ±5% HR
    Operating voltage 3.3V – 5V
    Current consumption Max. 2.5 mA reading
    Sampling frequency 1 Hz (1 reading per second)
    Data output Digital single thread
    Dimensions 15.5 mm x 12 mm x 5.5 mm (typical module)

    DHT11 Temperature and Humidity Sensor KY-015

    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.

    This is the code I used:

    
    const int DHpin = 2;  // Usa GPIO2 (ajústalo según tu conexión)
    byte dat[5];          // Almacena datos [hum_ent, hum_dec, temp_ent, temp_dec, checksum]
    
    void setup() {
      Serial.begin(115200);
      pinMode(DHpin, OUTPUT);
      digitalWrite(DHpin, HIGH);  // Inicia el bus en alto
    }
    
    byte read_data() {
      byte result = 0;
      for (int i = 0; i < 8; i++) {
        while (digitalRead(DHpin) == LOW);  // Espera hasta que el pin esté alto
        delayMicroseconds(30);              // Duración crítica para distinguir 0/1
        
        if (digitalRead(DHpin) == HIGH)     // Si sigue alto después de 30us, es un 1
          result |= (1 << (7 - i));         // Almacena el bit (MSB first)
        
        while (digitalRead(DHpin) == HIGH); // Espera a que termine el bit
      }
      return result;
    }
    
    void start_test() {
      // 1. Envía señal de inicio
      digitalWrite(DHpin, LOW);
      delay(20);                      // >18ms para DHT11 (no 30ms para evitar timeouts)
      digitalWrite(DHpin, HIGH);
      delayMicroseconds(40);          // Espera respuesta
      
      // 2. Configura el pin como entrada y espera respuesta
      pinMode(DHpin, INPUT);
      while (digitalRead(DHpin) == HIGH);  // Espera a que DHT11 ponga LOW
      delayMicroseconds(80);               // LOW durante 80us (respuesta)
      
      // 3. Lee los 40 bits de datos (5 bytes)
      for (int i = 0; i < 5; i++) 
        dat[i] = read_data();
      
      // 4. Finaliza la comunicación
      pinMode(DHpin, OUTPUT);
      digitalWrite(DHpin, HIGH);
    }
    
    void loop() {
      start_test();
      
      // Verifica checksum
      byte checksum = dat[0] + dat[1] + dat[2] + dat[3];
      if (dat[4] != checksum) {
        Serial.println("Error de checksum!");
        return;
      }
      
      // Imprime datos
      Serial.print("Humedad: ");
      Serial.print(dat[0]);  // Parte entera humedad
      Serial.print(".");
      Serial.print(dat[1]);  // Parte decimal humedad
      Serial.println("%");
      
      Serial.print("Temperatura: ");
      Serial.print(dat[2]);  // Parte entera temperatura
      Serial.print(".");
      Serial.print(dat[3]);  // Parte decimal temperatura
      Serial.println("°C");
      
      delay(2000);  // Espera 2 segundos entre lecturas
    }
    											
    📋 KY-031 Knock Sensor Module Specifications
    Module name KY-031 Knock Sensor
    Sensor type Vibration / impact sensor (spring-based)
    Operating voltage 3.3V – 5V DC
    Output type Digital (High/Low signal)
    Interface 3 pins (Signal, VCC, GND)
    Output signal High when idle, Low when vibration detected
    Sensitivity Adjustable with onboard potentiometer
    Dimensions 27mm x 14mm x 8mm (approx.)
    Applications Vibration detection, impact sensing, alarms

    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.

    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