Final project

In week 9 and 10, the aim was to finish the final project including three main topics:
1. 3D-Design
2. Embedded programming including the inputs and outputs.
3. Laser cutting or CNC (Computer Numerical Controller).

Project description

During the last week of FabLab, the final project idea was changed to a minimized smart LED room prototype in collaboration with Zubaida. As for the project tasks, I did the programming for the input switches to activate the outputs, which were a Curtains motor, an LED, and a screen. An additional essential feature of a smart LED room is Wi-Fi support. Therefore, the equipment is activated using Wi-Fi.

Project design

The project design will present a small preview of a room that shows both input and output equipment, as per the requirements of the final project. For my part, I created a remote controller for controlling the room equipment using the programmed inputs.

Design procedure

The first step for constructing the design, a drawing of the programming equipment, was placed in a layout and divided into two parts: the top for the buttons and the potentiometer and the bottom for placing the microcontroller and the tilt switch, as shown below.


After drawing the prototype of the controller on the cardboard, it was designed on Fusion for creating the top and bottom of the controller using the laser cutter.


Next, the inputs were connected to the microcontroller then will be programmed as mentioned later on.


Note: The magnetic switch was neglected due to the requirement of a magnet to activate it. Therefore, the controller design is considered to be user-friendly.

Programming inputs

Input equipment will be used to activate the output equipment of the small LED room using Wi-Fi. Before initializing the Wi-Fi, the inputs will be programmed using the XIAO-ESP32-C3 microcontroller because it supports Wi-Fi. The equipment used for the inputs is a rotary angle sensor (potentiometer), a tilt switch, a magnetic switch, and dual buttons. In addition, an explanation of all the codes will be added for better understanding of all the programming processes.


Note: For faster testing methods, the serial monitor was used to ensure that the coding steps are correct, and the equipment was usable.

Equipment used for programming

Three main tools were used for the programming procedure are as following:

XIAO-ESP32-C3

alt text


With the ESP32-C3 chip, which combines Wi-Fi and Bluetooth Low Energy (BLE) capabilities, the XIAO ESP32-C3 is a small and potent microcontroller board made for Internet of Things applications. This board is perfect for applications with limited space because of its compact form factor, which measures only 23.5 x 17.5 mm. Among its many features are 15 GPIO pins, an inbuilt LED, a USB-C port for convenient powering and programming, and compatibility for multiple communication protocols like SPI, UART, and I2C. Both novice and seasoned developers can use the XIAO ESP32-C3 because of its low-power CPU, which enables energy-efficient operation, and support for the Arduino IDE, which makes programming simple. Because of its adaptability and networking features, it can be used for a variety of purposes, from wearable technology to smart home devices.

Grove Shield for XIAO with battery management chip

alt text


The Grove Shield for XIAO is an extension board that offers a range of interfaces and connectivity choices to improve the XIAO microcontroller’s performance. Users can connect a rechargeable lithium battery for portable applications thanks to its battery management chip, which enables effective power control. Several Grove connectors on the shield make it simple to integrate a variety of Grove modules, including sensors, displays, and actuators, without requiring intricate cabling. It also provides I2C, UART, and PWM interfaces, which greatly increases the XIAO’s adaptability for a range of applications. It is the perfect option for IoT application development and prototyping because of its small size, which guarantees compatibility with the XIAO form factor while preserving a simple and intuitive configuration.

USB-Type C

alt text The symmetrical connector standard known as USB Type-C makes connecting devices easier. It is appropriate for charging laptops and cellphones because it supports data transfer, power delivery, and video output. With 100 watts of power and 10 Gbps data transfer speeds, it’s suitable for high-performance applications. It is a popular option for modern electronic devices and accessories because it is interoperable with protocols like DisplayPort and HDMI.

Rotary angle sensor (Potentiometer)

alt text A potentiometer, sometimes referred to as a rotary angle sensor, is a variable resistor used in electrical and electronic circuits to determine the angular position of a control knob or rotating shaft. It is made up of a sliding contact (wiper) that travels along the resistive track and a resistive element. The wiper’s position can be changed by moving the knob or shaft, which also modifies the resistance between the wiper and end terminals. This adjustment can regulate brightness, speed, and volume. A Grove Rotary Angle Sensor is a potentiometer module that works with Grove connections in the Grove system, making integration simple and requiring no complicated wiring.


Code for Potentiometer was used below for testing:


const int potPin = 0; // Pin where the potentiometer is connected

void setup() {
  Serial.begin(115200); // Initialize Serial Monitor
}

void loop() {
  int potValue = analogRead(potPin); // Read the potentiometer value (0-1023)

  Serial.print("Potentiometer Value: ");
  Serial.println(potValue); // Print the value to the Serial Monitor

  delay(500); // Delay for readability
}


Magnetic switch

A magnetic switch, sometimes referred to as a reed switch or magnetic contact switch, is a sensor that determines whether a magnetic field is present or not. It is made up of a magnet and a reed switch that regulate the contacts’ opening and closing. The reed switch closes when a magnet approaches it because the contacts are drawn in by the magnetic field. On the other hand, the contacts separate and the switch opens when the magnet travels away. Numerous electrical projects, including home automation, industrial applications, and security systems, benefit from the use of magnetic switches. A Grove Magnetic Switch is a module made to work with the Grove system, making connections easier and enabling magnetic sensing for a variety of applications.


Code for the tilt switch with an explanation is shown below.


#define MAGNECTIC_SWITCH 8
//#define LED 13//the on board LED of the Arduino or Seeeduino

void setup()
{
    pinsInit();
  Serial.begin(9600);
}

void loop() 
{
    if(isNearMagnet())//if the magnetic switch is near the magnet?
    {
        Serial.println("on");
    }
    else
    {
        Serial.println("off");
    }
}
void pinsInit()
{
    pinMode(MAGNECTIC_SWITCH, INPUT);
    //pinMode(LED,OUTPUT);
}

/*If the magnetic switch is near the magnet, it will return ture, */
/*otherwise it will return false                                */
boolean isNearMagnet()
{
    int sensorValue = digitalRead(MAGNECTIC_SWITCH);
    if(sensorValue == HIGH)//if the sensor value is HIGH?
    {
        return true;//yes,return ture
    }
    else
    {
        return false;//no,return false
    }
}

Tilt switch

Tilt switches are sensors that use an object’s angle of inclination to determine its orientation. They can be pendulum, rolling ball, or mercury switches, among other types. The fundamental idea behind the switch is a conductive metal mass or ball enclosed in a contact-equipped housing. The ball moves and forms an electrical circuit when tilted past a specific angle, which causes electronic circuits to act. Applications such as consumer electronics, robotics, automotive systems, and safety equipment frequently use tilt switches. By incorporating tilt sensing capabilities into electronic projects, the Grove Tilt Switch module simplifies the process of connecting to other modules without requiring complex soldering or wiring.


Code for the tilt switch with explanation is shown below.


void setup()
{

    pinMode(9, INPUT);
  Serial.begin(115200); 
}

void loop()
{

    if (digitalRead(9)==HIGH)
    {
       Serial.println("high");
    }

    else
    {
        Serial.println("low");
    }

}

dual buttons

In electronic circuits or devices, dual buttons are two alternative push buttons or sensory switches that enable users to enter two different commands or messages. Because of their autonomous operation, pressing one button has no effect on the other. Applications with two separate inputs, such control panels or user interfaces, frequently use dual buttons. A Grove Dual Button module is a part of the Grove system that combines two haptic push buttons into one unit, making connections simple and requiring no complicated wiring or welding. This makes it possible for developers and electronics enthusiasts to swiftly include dual button input features into their projects. Code for the tilt switch with explanation is shown below.


const int switch1Pin = 2; // Pin where Switch 1 is connected
const int switch2Pin = 3; // Pin where Switch 2 is connected

void setup() {
  Serial.begin(115200);               // Initialize Serial Monitor
  pinMode(switch1Pin, INPUT_PULLUP); // Set Switch 1 pin as input with internal pull-up
  pinMode(switch2Pin, INPUT_PULLUP); // Set Switch 2 pin as input with internal pull-up
}

void loop() {
  int switch1State = digitalRead(switch1Pin); // Read the state of Switch 1
  int switch2State = digitalRead(switch2Pin); // Read the state of Switch 2

  // Check the state of Switch 1
  if (switch1State == LOW) {
    Serial.println("Switch 1: PRESSED"); // Switch 1 is pressed
  } else {
    Serial.println("Switch 1: RELEASED"); // Switch 1 is released
  }

  // Check the state of Switch 2
  if (switch2State == LOW) {
    Serial.println("Switch 2: PRESSED"); // Switch 2 is pressed
  } else {
    Serial.println("Switch 2: RELEASED"); // Switch 2 is released
  }

  delay(500); // Delay for readability
}

Cutting process for the design room

The smart room was designed by Zubaida and the used method for the cutting procedure was the laser cutter.


alt text


Note: the design’s press fit was not strong enough to stabilize the walls, so some glue was used for additional support.

Final design of the controller

After the cutting and programming are completed, the controller is ready to go, as it is connected to Wi-Fi and easy to use for new people who are invested in the Internet of Things (IoT).