Introduction: Mechanical Smart Mask

About: Im into all things mechanical with a touch of art and creativity. Just a piece of scrap metal fused with a spark of electricity in the binary world of computers.

This project is the design of a smart mechanical mask that can close or open autonomously. I got the idea to make this during the pandemic and I made two prototypes of which the second and final one is shown on the cover image. It works fairly simple. The outer shields of the mask are moveable and when someone comes near within a certain distant from the mask it closes and alternately opens up when no one is in the proximity. To achieve this I used a Proximity Sensor and a Passive Infrared Sensor (PIR Sensor) where the proximity comes into action once a moving body is detected. In addition to this three push buttons are used on the left side of the mask. A button to activate auto mode and deactivate and the other two for opening and closing the mask. In addition to this the outer moveable shields house a filtering cloth embedded inside a Humidity Sensor which can detect when the filtering cloth (material) is wet. LEDs are places on the front of the shield to indicate the condition of the filtering material ( red, yellow and green indicating wetness from highest to lowest respectively). The moveable shield use lead screws on either side to move them to their respective positions. The mask is controlled with an Arduino Nano as it is small in size and has the necessary amount of GPIO pins required for this project. The two prototypes are very similar in design and the working principle for both of them are the same. The main difference is the sensors that I have used.

The first prototype uses a an HC_SR04 Ultrasonic Proximity Sensor where as in the final prototype I used a TF-LUNA Lidar Lidar Proximity Sensor which is far better in accuracy at measuring the distances compared to the first one. Both Masks were designed using Fusion360 and 3D printed using PLA filament. I will attach the STL files for the final design to this article. I should note that the main challenge I found in this project is to design the structure as light as possible and ergonomically pleasing since it is to be worn. On that note its also important to mention that a 5V small cooling fan is enclosed on the front of the shield which activates when the mask is in closed position. This would allow for some cooling. Having said that I will try to document this as best I can and welcome any questions from the readers.

Supplies

The supplies are easy to find and not very expensive except for the Lidar sensor which cost around 23 USD and most hobbyist will be familiar with them.

Prototype I

  • 1 Proximity Sensor - HCSR-04 Sensor
  • 1 Passive Infrared Sensor - Generic PIR Sensor
  • 2 Linear Actuators - Stroke Length of 55 mm Lead Screw with a 340 rated RPM 6V drive DC Motor.
  • 1 Humidity Sensor - DHT-11 Sensor
  • 4 Linear Bearings (8x15x24 - Inner Diameter x Outer Diameter x Length)
  • 3 LEDs (red, green, yellow)
  • 7.4 V Lithium Polymer (Lipo) Battery
  • 3 Push Buttons
  • Sponge like material to line the inner areas of the mask touching the nose and face.
  • 3D printer with PLA filament
  • 4 Lever with roller type Omron limit switches
  • Adjustable straps going behind and over the head to hold the mask in place.
  • Any type of filtering material (I used a small cut out of cloth)
  • Arduino Nano Microcontroller
  • 2.5 mm screws and nuts
  • Super Glue
  • 12V (DC)/250V(AC) ON/OFF Power Switch
  • L298N DC Motor Driver

Prototype II

Prototype II basically used similar supplies with the major change in replacing the HCSR-4 with the TF-LUNA Lidar sensor. I also changed the DHT-11 humidity sensor to DHT-22 and the lead screw motor driver from to a TB6612FNG DC Motor Driver as it sis more compact in size has has pretty much the same capability. Apart from those a 5V cooling fan was used in the final design.

The following steps of this article will briefly explain the components used in this project and their working principle.

Step 1: Arduino Nano

The Arduino Nano microcontroller is the heart of the control system and was used in both prototype designs of the face mask. The microcontroller is based on the ATmega328 microchip. The ATmega328 is a high-performance microchip comes with 32 KB ISP flash memory with read-while-write capabilities and 1KB EEPROM. The Arduino Nano is small and breadboard friendly which is useful in testing phases of different components with the microcontroller. It can be easily powered up via the mini-B USB (Universal Serial Bus) port or the V-IN pin or the 5V pin accessible on the microcontroller board. The mini-B USB port can be connected to a computer via a cable. 


1.1 Technical Specifications of Arduino Nano

  • Microcontroller: ATmega328
  • Architecture: AVR
  • Operating Voltage: 5 V
  • Flash Memory: 32KB (2KB used by bootloader)
  • SRAM: 2KB
  • Clock Speed: 16 MHz
  • Analog I/O Pins: 8
  • EEPROM: 1KB
  • DC Current per I/O Pin: 40 mA
  • Input Voltage: 7-12 V
  • Digital I/O Pins: 22
  • PWM Output: 6
  • Power Consumption: 19mA
  • PCB size: 18x45 mm
  • Weight: 7g

Step 2: Passive Infrared Sensor (PIR Sensor)

Passive Infrared Sensors are used to detect human motion within the sensor’s field of range. They are small, inexpensive and easy to use and are commonly found in many applications. They are referred to as PIR, Pyroelectric or IR motion sensors. The sensor in a motion detector is split into two halves. Since everything emits some low levels of infrared radiation, the hotter something is the more radiation it emits. The sensor detects motion by measuring the levels of radiation on each half and then if one half sees more radiation than the other, the two halves are wired so that the output will change to a high signal or a low signal.


2.1 Working Principle of PIR Sensor

PIR sensors consume very little power and are pretty rugged. They also have a wide lens range which can be interfaced easily with components such as microcontrollers. The lens is fixed to a certain sweep distance and can sometimes be set off by other infrared emitting animals such as house pets. Passive Infrared Radiation (PIR) sensors detect the change in infrared radiation of warm-blooded moving object in its detection range. As mentioned before the PIR sensor has two slots (halves) made of special material that is sensitive to IR. When the sensor is idle, both slots detect the same amount of IR. This can be the ambient amount of IR emitted from outdoors or any uniform area exposed to the field of view of the lens. When a warm body like a human or animal passes, the first slot detects a change in IR and then registers when it leaves the first slot and enter second slot. This difference or rather change in IR allows it to detect any motion.


2.2 Technical Specifications of PIR Sensor

The IR sensor is housed in a sealed metal can so that it can block off any variations in noise, temperature and humidity. The lens of the PIR sensor can affect its breadth, range, sensing pattern very easily. The Fresnel lens condenses light, providing a larger range of IR to the sensor. The lens is then split into sections so that each section is small Fresnel lens so that a scattering effect can be produced for sensing of both slots(halves) of the PIR sensor.

  • Input Voltage: 3.5 V - 5 V
  • Working Current: < 20 mA
  • Working Temperature: -20 - 85 degrees Celsius
  • Output Voltage: High - 3V, Low - 0V
  • Output Delay Time (At High signal): 2.3 - 3 minutes
  • Detection Angle: 100 degrees
  • Output Indicator Light: High Electrical Level Light
  • Output Pin Limited Current: 1 mA
  • Output Interface: Digital
  • Module Size: 30x23 mm
  • Module Weight: 4g
  • Pin Definitions: (S)Signal, (+)VCC, (-)GND


2.3 Connecting the PIR Sensor

The PIR sensor has three pins namely the positive voltage pin (+), the ground pin (-) and the signal pin (S). The positive voltage pin is connected to the positive terminal of a 5V supply and the ground pin is connected to the negative terminal of the 5V supply. The onboard voltage regulator regulates the voltage so that it can produce 3V for a high signal and 0V for a low signal. Once wired up the signal pin can be read to determine if there is motion. If a motion is detected then the signal pin goes high and if no motion is detected (idle state) then the signal pin is set to low.

Step 3: Humidity Sensor

In this project there are basically two types of humidity sensors used for measuring the moisture level of the filtration element in the face mask. The first prototype uses DHT-11 sensor and the second prototype uses DHT-22 temperature and humidity sensor. They both have their advantages and disadvantages but generally DHT-22 is known to produce better measurements with a wider range.


3.1 Working Principle of the Humidity Sensors

The DHT-11 module features a humidity and temperature complex with a calibrated digital signal output which means DHT-11 sensor module is a combined module for sensing humidity and temperature which gives a calibrated digital output signal. It consists of a humidity sensing component and a NTC temperature sensor also known as a thermistor and an IC on the back of the sensor. The humidity sensing component has two electrodes with moisture holding substrate between them. When the humidity changes, the conductivity of the substrate changes which is dependent on the resistance between the electrodes. This change is resistance is measured and processed by the IC to give readings that can then be interpreted by a microcontroller. As for the thermistor it is a variable resistor made with sintering of semi conductive materials such as ceramics or polymers so minute changes in temperature would in turn produce large resistance changes. The DHT-22 is a low-cost digital humidity and temperature sensor. It utilizes a capacitor-based humidity sensor combined with a temperature sensor component to measure the surrounding air. The output of the sensor is a digital signal that is transferred to the appropriate digital pin. This sensor is perfect and accurate with working in a broad range if humidity and temperature. There are readily available libraries for accessing the relevant data and interpreting them to get useful information about the humidity and temperature.  


3.2 Technical Specifications of DHT-11 and DHT-22 Sensors

DHT-11

  • Very low cost
  • 3V – 5V operating voltage
  • 2.5 mA max current
  • 20%–80% humidity readings with 5% accuracy
  • 00C-500C temperature readings with ±20C accuracy
  • No more than 1 Hz sampling rate
  • Body size 15.5mm x 12mm x 5.5mm

DHT-22

  • Low cost
  • 3V – 5V operating voltage
  • 2.5 mA max current
  • 0%–100% humidity readings with 2-5% accuracy
  • -400C-800C temperature readings with ±0.50C accuracy
  • No more than 0.5 Hz sampling rate
  • Body size 15.1mm x 25mm x 7.7mm


3.3 Connecting the Humidity Sensors (DHT-11 and DHT-22)

Both DHT-11 and DHT-22 humidity sensor modules have three pins namely the VCC pin, Data pin and the GND pin. The DHT-22 sensor has a wide temperature and humidity measurement range and is able to transmit the output signal through the cable up to 2 meters so it is suitable to be placed anywhere. A 0.33 µF buffer capacitor must be added between VCC and GND pins if the cable is longer than 2 meters. They can be easily connected to a microcontroller to analyse the data. There are several libraries that help to interface with these modules to get the required humidity and temperature values with the data from the sensor. These sensors come as a module which integrates a filtering capacitor and pull-up resistor.

-         VCC Pin: Connected to the positive 5V of the power supply.

-         GND Pin: Connected to the negative terminal of the 5V power supply.

-         Data Pin: Connected to a digital pin to receive the humidity and temperature data.


Step 4: HC-SR04 Ultrasonic Proximity Sensor

HC-SR04 is the ultrasonic proximity sensor used in the first prototype for measuring the distance an object is from the person wearing the face mask. It is a low cost widely available sensor that has accuracy of up to about 3 mm. It can be used in applications where distances in the range of 2 cm to 400 cm. They are easy to interface with a microcontroller and very popular amongst many general applications that require proximity measurements. As the name implies it uses ultrasonic pulses to measure the distance based on the time the pulses receive back. It can be powered up with a regulated 5V power supply.

Some of the drawbacks of the ultrasonic sensor include the inaccuracy in the measurements due to variations in pressure, temperature and humidity in the air, objects with sharp edges may not give a good echo, a blind zone of a few centimeters (i.e., 3cm or less) if the object is too close to the sensor, not functional is vacuum space, and finally contributions to attenuations of an ultrasound sensor may imply: Absorption, Reflection, Scattering, Refraction, Diffraction, Interference and Divergence


4.1 Technical Specifications of HCSR-04 Ultrasonic Sensor

  • Working Voltage: 5V
  • Working Current: 15 mA
  • Working Frequency: 40 kHz
  • Maximum Range: 400 cm
  • Minimum Range: 2 cm
  • Measuring Angle: 15 Degrees
  • Dimensions: 45x20x15 mm


4.2 Connecting HCSR-04 Sensor


The HC-SR04 is small and easy to interface with any microcontroller. Since it operates on 5V it can be directly connected to a microcontroller such as the Arduino Nano. The four pins of the sensor are VCC pin, GND pin, TRIG pin and ECHO pin.

VCC – The positive terminal of the 5V power supply is connected to this pin.

GND – The negative terminal of the 5V power supply is connected to this pin.

TRIG (Trigger) – This pin is used to trigger the ultrasonic sound pulses.

ECHO – This pin produces a pulse when the reflected signal is received.

Step 5: TF-LUNA Lidar Proximity Sensor

TF-LUNA is a proximity sensor based on LIDAR technology. It works on the TOF (Time of Flight) principle and is widely used in many applications due its precision and high frame-rate range detection. This module is used in the latter prototype for triggering the face mask to open or close depending on the proximity of a person. It is compact in size, consumes very little power and is light weight. It supports two interfaces for communication namely UART and IIC also known as I2C.


5.1 Working Principle of TF-LUNA Lidar Sensor

The TF-LUNA emits modulation waves of near infrared rays on a periodic basis. These rays are reflected back upon contact with an object in its measurement range. It obtains the time of flight by measuring the round-trip phase difference and then calculates the relative distance between the LIDAR and the detected object. It has built in algorithms to suit various application fields and scenarios.

The Standard Deviation (STD) using 100 Hz output rate in correlation with the signal strength and the distance from the object is shown below. These values are subject to change depending on the environment.

Signal Strength (Amps) / STD

  • 100 / 3cm
  • 200 / 3cm
  • 400 / 2cm
  • 1000 / 1cm
  • >2000 / 0.5cm


The correlation between Distance and STD is shown below.

Distance / STD

  • 200cm / 0.5cm
  • 400cm / 1cm
  • 600cm / 1.5cm
  • 800cm / 2cm


The LIDAR sensor emits near infrared rays and measure the phase difference between the emitting ray and the reflected ray to calculate the distance using the principle of TOF. Although it is hard to get an accurate distance between transparent objects like water or glass, its produces reasonably accurate distance readings between moving objects and stationary objects in real time.


5.2 Technical Specifications of TF_LUNA Lidar Sensor

  • Operating Range: 0.2m - 8m (90% reflectivity)
  • Accuracy: +/- 6cm @ 0.2m - 3m / +-2% @ 3m - 8m
  • Distance Resolution: 1 cm
  • Frame Rate: 100 Hz
  • Ambient Light Immunity: 70 Klux
  • Operating temperature: -10 degrees - 60 degrees Celcius
  • Light Source: VCSEL
  • Central Wavelength: 850 nm
  • FOV (Field of View): 2 degrees
  • Supply Voltage: <= 5 V
  • Average Current: <= 70 mA
  • Power Consumption: <= 0.35 W
  • Peak Current: 150 mA
  • Communication Interface: UART/ IIC
  • Dimensions: 35 x 21.25 x 13.5 mm (LxWxH)


5.3 Connecting the TF_LUNA Lidar Sensor

The TF-LUNA LIDAR sensor has 6 pins out of which two of them are for powering the sensor. Since it has two options of interfacing, the pins 2 and 3 are dedicated for RX and SDA and TX and SCL pins respectively.

For interfacing with UART the serial communication protocol is defined as 8 data bits, 1 stop bit with no parity check with a default baud rate of 115200 bps. For this project the UART interface for communication with the TF-LUNA was used.


The TF-LUNA provides the following output data.

  • Distance (Dist.): Default in centimeters
  • Signal Strength (Amp): Distance value is unreliable when receiving signal is exceeded (Amp = 0xFFFF) or too low (Amp < 100 as 14)
  • Chip Temperature (Temp): Celsius Degree = Temp/8-2560C

Step 6: SS-5GL2 Omron Limit Switch

Limit switches constitute a class of input-output devices that change operating state in a reaction to the crossing of a threshold value of their input. They can be used as indicators, control devices, or commonly both. As indicators, limit switches provide logic outputs (true or false) depending on the level of their input. As control devices, limit switches provide the simplest form of feedback: discreet on/off states in response to input. Limit switches are used as control devices in this project and the normally open terminals of the SS-5GL2 Omron limit switch are connected in the circuit so that the limit switch will be triggered in a closed position when a threshold input value is reached. There are four limit switches used in the final prototype and they are used in restricting travel of the component fixed to the actuator beyond the defined length when in the process of opening and closing the mask.


6.1 Technical Specifications of SS-5GL2 Omron Limit Switch

  • Terminals: Normally Open (NO), Normally Closed (NC) and Common (C)
  • Current Rating: 5A
  • Actuator Type: Roller
  • Operating Force: 0.49N
  • Release Force: 0.06N
  • Operating Temperature: -250C – 850C

Step 7: Lead Screw Linear Actuators

Linear actuators are, as the name suggest, mechanical devices that use energy to develop force and motion in a linear manner as opposed to rotational motion in with motors. This type of actuator offers several advantages including a simple design with minimum moving parts. They are self contained and can perform tasks that require relatively good speeds with identical behavior extending and retracting their mover.

One of the main functions of the face mask design is for it to be able to open and close upon trigger by either the user or a sensor. In order to achieve this motion both sides of the face mask covering the nose and mouth area of the user needs to be moveable and has to be attached to the main frame of the mask by integrating a linear actuator. This concept of design was chosen for its simplicity in achieving the desired result and after giving much consideration into the limitations and restrictions that might pose using other alternatives. 

The linear actuator used for the opening and closing motion of the face mask comprises of a 6V DC motor which rotates the threaded output shaft lead screw. This is a compact and light weight linear actuator which is suitable for use in the face mask. It has an integrated M4x55mm threaded rod as output shaft which serves the purpose of the linear actuator. The speed reduction metal gears ensure a longer service life allowing higher torques and less noise.


7.1 Technical Specifications of the Linear Actuator

  • Working Motor Voltage: 6 V 
  • Motor Speed without load: 400 RPM
  • Motor Current consumption without load: 0.04 A
  • Motor Speed at rated load: 340 RPM
  • Motor Current consumption at rated load: 0.07 A
  • Motor Torque at rated load: 0.17 Kg.cm
  • Motor Stalling Torque: 1.40 Kg.cm
  • Motor Stalling current: 0.2 A
  • Lead Screw length: 55 mm
  • Lead screw diameter: M4

Step 8: L298N DC Motor Driver

The L298N Motor Driver is configured to drive two DC motors in bi-direction. This configuration is also known as the H-Bridge configuration. An H-Bridge (or sometimes called full bridge) is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards. This module allows the control of two DC motors by manipulating the speed and the direction of rotation. The speed is controlled by pulse width modulation (PWM) and the direction of rotation is controlled by using and H-Bridge configuration.


8.1 Working Principle of the L298N Motor Driver

  • Controlling the Speed

The speed can be controlled by varying the input voltage. This can be done by sending a PWM signal with varying Duty Cycles for different speeds. The average voltage is proportional to the width of the pulses known as Duty Cycle. The higher the duty cycle the higher the speed and the lower the duty cycle the lower the speed.

  • Controlling the direction of rotation

The direction of rotation of the motor can be controlled by reversing the polarity of the input voltage. In order to accomplish this an H-Bridge is used. It consists of four switches with the motor at the centre. By closing two specific switches allow the change polarity of the input voltage thus changing the spinning direction of the motor. H-bridge uses transistor as switches so that fast switching can be achieved with the required digital input.


8.2 Technical Specifications of the L298N Motor Driver

  • Double H-Bridge Drive Chip: L298N
  •  Logical Voltage: 5V
  • Drive Voltage: 5V – 35V
  • Logical Current: 0-36mA
  • Drive Current: 2A (Max single bridge)
  • Maximum Power: 25W
  • Dimensions: 43mm x 43mm x 26mm


8.3 Connecting the L298N Motor Driver

The L298N can be connected to a microcontroller to control the speed and rotation direction of two bidirectional motors. It has four pins for controlling the direction of spin of the two DC motors and another pin for each motor which controls by reading the PWM signal to control speed.

  • Direction Control Pins

These pins control the switches of the H-Bridge circuit inside the L298N IC. It has two direction control pins for each channel (motor). The IN1 and IN2 Pins controls the rotation direction of Motor A and IN3 and IN4 control the rotation direction of Motor B. The direction can be controlled by sending a “high” (5V) or “low” (0V) to these pins.

  • Speed Control Pins

The ENA allows control of the speed for Motor A and ENB allows control of the speed for Motor B. By sending a PWM signal to these pins can vary the voltage to the output hence allow control of the speed of the motor.

Step 9: TB6612FNG DC Motor Driver

The TB6612FNG is also a DC motor driver that provides the same functionality as the L298N driver but is compact in size compared to it. The dual motor driver drives both motors which allows acceleration in forward or backward direction. In addition to this the TB6612FNG also allows short braking of the motor before reversing direction of rotation. The motor driver controls the current flow to the two motors. It can control up to two DC motors at a constant current of 1.2A (3.2A peak). Two input signals (IN1 and IN2) can be used to control the motor in one if the four function modes, that is: CW (Clockwise), CCW (Counter Clockwise), short-brake, and stop. This module is used in the second and final prototype of the face mask as it is smaller in size and weight and provides the same functionality. Although the input voltage limit of this module (2.2V – 13.5V) is smaller compared to the L298N module (5V – 35V) it is well within the range for this application as the linear actuator motor voltage rating is 6V.


9.1Technical Specifications of the TB6612FNG Motor Driver

  • Double H-Bridge Drive Chip: TB6612FNG
  • Motor Channels: 2
  • Output Current: 1.2A (average), 3.2A (peak)
  • Standby Control pin to save power
  • Control Modes: Clockwise, Anti-Clockwise, Short brake, Stop Motor
  • Built-in thermal shutdown circuit and low voltage detection circuit
  • Filtering capacitors on both supply lines
  • Dimensions: 20.32mm x 20.32mm


9.2Connecting the TB6612FNG Motor Driver

There are three types of connecting pins on the Motor Driver board namely for power, input and output. The complete function and description of the pins are detailed below.

Pin Function Description

  • VM - (Motor Voltage) The power for the motors(2.2 to 13.5V)
  • VCC - (Logic Voltage) Voltage to power the chip and communications (2.7 to 5V)
  • GND - (Ground) Common Ground for both motor and logic voltage
  • STBY - (Standby) Active 'high' for it to work
  • AIN1/BIN1 - (Input1/channels(A,B)) Input for Direction of motor
  • AIN2/BIN2 - (Input2/channels(A,B)) Input for Direction of motor
  • PWMA/PWMB - (PWM input(A,B)) Input to control Speed of motor
  • A01/B01 - (Output1/channels(A,B)) Output to connect to motor
  • A02/B02 - (Output2/channels(A,B)) Output to connect to motor


In order to control the motors, the specific logic states have to be communicated to the motor driver module from the microcontroller for it to send the instructions to the specific motors. The logic states of the pins on the motor driver for each individual operation is shown below.

  • [in1/HIGH, in2/HIGH, out1/LOW, out2/LOW] - COUNTER CLOCKWISE
  • [in1/LOW, in2/HIGH, out1/LOW, out2/HIGH] - SHORT BRAKE
  • [in1/HIGH, in2/LOW, out1/HIGH, out2/LOW] - CLOCKWISE
  • [in1/HIGH, in2/LOW, out1/LOW, out2/LOW] - SHORT BRAKE
  • [in1/LOW, in2/LOW, out1/OFF, out2/OFF] - STOP

Step 10: Design of Prototype I

The design of the first prototype influenced a lot on the dimensions of the components used in addition to factors such as ergonomics and functionality. Furthermore, the components that compose the face mask needed to be placed in a balanced manner so that once the face mask is worn the wearer would experience minimum discomfort. The mask is designed so that it can be worn and kept in place by two straps with one going over the head and another going behind the head. This would give sufficient support and force to keep a tight fit to face. In addition to this rubber padding material is used around the ear holes on the left and right plates of the mask for comfort.

The mask was created in one size as a prototype several measurements of the head and face were required to proceed in the design of the prototype using CAD software. After coming up with a sketch of how the mask would look like, the next step was to identify the individual parts that would comprise the full assembly. Single rigid parts were designed as one whole part unless there were no limitations posed on the manufacturing front. The two main pieces that held the linear actuators for the movement of the face shield was designed initially as it formed the base for building on the other parts that were to be assembled in the future.

After designing the left and right plates, they were joined as one piece with the required distance between them for accommodating the face of the user. Two pieces are used at the nose and chin sections to join the two plates and bolted together after applying a coat of glue for added bonding strength. The bottom plate that goes under the two side plates also allow for extra rigidity of the mask and is bolted to the left and right plates. For holding the strap that goes over the head an addition part is used as a strap holder on top of both the left and right plates and bolted with M2.5 Hex bolts. Just below the left ear hole the main control push buttons holder is placed and is mounted on top of the linear actuator motor driver case.

Once the mask structural frame was assembled with all the parts giving it a rigid form, the next step was to design the support structures and holders for fixing the sensors. The HCSR-04 proximity sensor is mounted on the chin Attachment piece with an added support structure and fitted to the HCSR-04 sensor fixture. The PIR sensor is mounted on top of the HCSR-04 sensor fixture. This arrangement was convenient to route all the wiring from the sensors to the microcontroller placed on the underside of the bottom plate. The DHT-11 humidity sensor is placed on the top side of the bottom plate. The main power switch is located at the back of the battery compartment and is easily able to access when wearing the mask. A strip of three white LED is used as an indication of power up and are housed in a pocket below the HCSR-04 sensor fixture.

The linear actuator assemblies that move both the left and right shields to enable the opening and closing of the mask were fixed on the outer side of the left and right plates. The moveable shields on the other hand are placed inside the mask which are bolted to the structure which houses the rotating nut of the lead screw in the linear actuator. This meant that the shield would open and close from the inside of the mask while the linear actuator does the work from the outside. The linear actuator with the lead screw and the motor are housed inside a motor case and it is fixed to the outer side of left and right plates. Two guide rails are used on each linear actuator for stability in movement using linear bearings to allow motion in a linear manner. The linear actuators are mounted in an inclined configuration on either side of the face mask allowing motion along that plane. This meant that the horizontal component of the movement was actually the distance required for closing or opening the mask and the vertical component was of no use but this arrangement was chosen since fewer compromises had to be made to allow for weight and space limitations of the overall design of the mask and for a more ergonomic design.

The nut which goes through the lead screw of the linear actuator is housed in the linear bearing holder which moves with constrained movement provided by the guide rails. On top of the bearing holder are two button pushers arranged opposite to each other. The purpose of the button pushers is to activate the limit push buttons when the desired linear distance is achieved by the linear actuator. The limit push buttons are housed in the slots on either side of the motor case. The right limit push button is placed in a housing structure which was designed separately for ease of adjusting the distance during assembly. The lead screw through hole has a small clearance and provides lateral support and stability to counter any unnecessary movements during rotation of the lead screw. The moveable shield which is housed inside the mask is attached to the bearing holder via another structure and are bolted together. This allows the movement of the bearing holder to move the shield.

The motor case and the guide rail holders are fixed to the outer side of both left and right plates of the mask. The wires from the motors in the linear actuator are guided to the motor driver by lining them and gluing them to the inner walls of the left and right plates. The microcontroller is housed underneath the bottom plate along with the electrical components after mounting them on a clear 55mm x 60mm perf board. 

Step 11: Working Principle of Prototype I

Regarding the functionality of the mask, there are two options a person can choose. The mask can be operated manually by a push button to open and close when required or in auto mode. There are three push buttons placed on the left plate of the mask of which one button allows the user to select auto mode or manual mode. The other two buttons are active only when it is in manual mode. In manual mode the two buttons allow for the mask to open or close. 

The PIR sensor and HCSR-04 sensor mounted on the chin attachment of the mask allows to detect if a person is in front within a predefined distance. Once triggered in auto mode it allows automated opening and closing of the mask when a person is within the proximity. The Arduino Nano microcontroller receives the data sent from both these sensors and sends back a signal to the L298N motor driver. The motor driver then enables the motor in the linear actuator to either rotate clockwise or anticlockwise based on the data received from the microcontroller. Once the linear actuator is in motion, the Arduino Nano waits to receive a signal from the any of the limit push buttons to stop the linear actuator. This process is looped until the auto mode is switched off by manually pressing the auto button. The DHT-11 humidity sensor receives moisture data regarding the filtering element and sends the data to the Arduino Nano. Based on the moisture levels, the microcontroller either sends a signal to light up the green LED (No to low moisture level), yellow LED (Moderate moisture level) or red LED (High moisture level). 


Step 12: Component Wiring of Prototype I

A 7.4V Lithium Polymer Battery supplies the power to the L298N Motor Driver Module. The ground wire of the battery is connected via an ON/OFF switch which can directly cut off the power to the face mask when switched off. The L298N Module can provide a regulated 5V supply after powering up with the 7.4V. This regulated 5V is used to power the Arduino Nano microcontroller and the rest of the components are powered from the Arduino Nano’s regulated 5V power pin.

The two motors (Motor A and Motor B) of both linear actuators are connected to the motor outputs (OUT1, OUT2, OUT3, OUT4) and the inputs of the motor driver (IN1, IN2, IN3, IN4) are connected to the Arduino Nano. These input signals from the microcontroller determine which direction the motors should rotate. The ENA (Speed control of Motor A) pin and ENB (Speed control of Motor B) are directly connected to the 5V pins onboard the L298N module so that they run on maximum speed. For this application speed control is not used but rather set in a constant maximum.

The DHT-11 humidity sensory has three pins of which the VCC pin is connected to the 5V pin of the Arduino Nano and the GND pin is connected to the common ground. The signal pin is connected to the Analog pin 4 (A4) of the Arduino Nano. Once the moisture levels are received from the sensor by the micro controller it sends a high signal to one of the three LEDs to indicate the moisture level in the filtering element of the mask. The positive terminal (anode) of each LED is connected to a 220 Ohm current limiting resistor and then connected to the appropriate pins on the Arduino Nano. The green LED is connected to Digital pin 1 (TX pin) on the Arduino Nano. It should be noted that TX pin can also act as a normal GPIO pin but should be disconnected when a program is being uploaded to the microcontroller since it communicates via the USB by serial connection to the Arduino Nano. The red LED is connected to Digital pin 0 (RX pin) and behaves the same as the TX pin and can be also used as a GPIO pin. The yellow LED is connected to Analog pin A0 of the Arduino Nano. The negative terminal (cathode) of each LED is connected to the common ground.

The HC-SR04 proximity sensor has four pins of which the Echo pin is connected to Digital pin 11 and the Trig pin is connected to Digital pin 12 of the Arduino Nano. The other two pins are the power pins of which VCC is connected to the 5V pin of the Arduino Nano and the GND pin is connected to the common ground. The PIR sensor has three pins namely the power pins and the signal pin. The VCC pin is connected to 5V pin in the Arduino Nano and the GND pin is connected to the common ground. The signal pin is connected to Digital pin 6 of the Arduino Nano.

There are in total seven push buttons used in this prototype. Four of them are used as limit switches to trigger when the mask has reached its maximum and minimum points when opening and closing. The other buttons are namely the auto/manual selection button, open shield, and close shield buttons. The Button Pushers attached on top of the Bearing Holder pushes the limit buttons on the left and right side as the Bearing Holder moves to the extreme limit positions. Once any limit button is pressed the linear actuator stops and depending on the limit button pressed further action is taken. Out of the four limit buttons two buttons are for the left shield of the mask and the other two for the right shield of the mask. As for the wiring, each limit button has two terminals. When a button is pressed the circuit between the two terminals are a closed circuit but when it is not pushed it is an open circuit. One of the terminals in the button is connected to the 5V pin of the Arduino Nano and the other pin is connected to in parallel to the common ground via a 1000 Ohm resistor and to the assigned input pin on the Arduino Nano. The reason to connect via a 1000 Ohm drop down resistor is to avoid fluctuating signal from a floating pin of the Arduino Nano when it is an open circuit and avoid short circuit when the circuit is closed. The limit buttons are connected to Digital pins 2, 3, 4, and 5 of the Arduino Nano and the other three control buttons are connected to Analog pins 1, 2, and 3 of the Arduino Nano.

Step 13: Programming and Component Interface of Prototype I

Since this is the first prototype of this project the individual component interface programming code will be discussed in this section. However, in the coming sections of this article the second and final prototype (Prototype II) program code will be discussed as one whole program with all the components working together. The microcontroller is the processor that communicates with all the components. The Arduino Nano microcontroller has many GPIO pins and several communication interfaces built-in to achieve this feature. Once the necessary electric connections are made physically the Arduino IDE allows to program the Arduino Nano via a computer. The Arduino IDE is similar to the C++ programming language although not all features may be used depending on the working environment. The programming environment has two main functions – setup function and loop function. The “setup function” initializes the GPIO pins and any Serial communication modes and runs only at the beginning of the program and only once. The “loop function” however is run repeatedly and this where the main bulk of the code is placed to loop indefinitely until powered off. Before any of these functions generally any libraries or modules that are used in the code are included up top with any global variables if any are used. Interfacing with components is made easy with libraries specifically made to interface with them. Some of these external libraries allow to interface with components bypassing the many detail programming aspects and to getting the real output required with as minimum number of lines of code. One such library is used in the communicating with the DHT-11 humidity sensor. 

For ease of reading I will try to describe my code by referring to the line numbers of the code in the pictures. I am sorry that I had not commented in the code which I know would have made this process easier for you to read. Later on in this article I will comment in the code for clarity. Line 1 includes the DHT library. Line 3 creates a DHT object known as DHT11 and line 4 assigns pin A4 to the DHT pin. Lines 7, 8 and 9 assign pins for the LEDs followed by the setup function which defines the states of the LED pins. In this case they are used as output pins.

The “loop function” begins reading the data from the humidity object created before. Line 18 stores the data in a variable known as “humidity” which is of integer type. Once we have the data if statements are used to check if the humidity is within a certain range and the corresponding LED is given a high signal to light up and the other LEDs a low signal to turn off. This will give necessary indication light for when the moisture of the filtering element is within a certain level. This process is looped every 500 milliseconds. Interfacing with the PIR sensor is similar but does not require the need for an external library.  

The PIR sensor receive a “high” signal when motion is detected. In the “setup” function, Serial communication is started at a baud rate of 9600 bps. After defining the PIR sensor pin, the pin is read using the “digitalRead” function and using an if statement checked if it is in a “high” or “low” state and the appropriate message printed to the Serial Monitor.

The HC-SR04 proximity sensor like the PIR sensor does not use any external libraries to communicate with the Arduino Nano. For the sensor to generate the 8-cycle sonic burst the Trig pin should be set on “high” for 10 microseconds. The Echo pin will output the time in microseconds of the time it took for the sound wave to travel. The speed of sound is known to be 340 m/s and for instance if the distance between the object and the sensor is 20 cm the sound wave would need to travel about 588 microseconds. Once the time it took for the sound wave to travel is known using the pulseIn() function, the distance can be calculated by multiplying the time and the speed of sound. It should be noted that this value is divided by 2 since the time it takes for the sound wave is the time it travels to the object, bounce back and return which means its twice the distance.

after defining the Trig and Echo pins and declaring two global variables known as duration and distance the Trig Pin is set “low” for 2 microseconds before sending out the burst of 8-cyce sonic pulses. The Trig pin is then set on “high” state for 10 microseconds for generating the ultrasound wave. Using the “pulseIn” function, the time it takes for the wave to return back is obtained. The “pulseIn” function has two parameters of which the first one is the pin it will read and the second is the state whether it is a “high” or “low”. The “pulseIn” function will wait for the pin to go “high” to start timing caused by the bounced back wave and then wait for it to go “low” when the sound wave has ended which also will stop the timing. The distance output on the Serial Monitor will be in centimeters.


Step 14: Design of Prototype II

The design process of Prototype II was mostly modifications and adjustments to the first prototype. Therefore, most of the heavy lifting was done during the design of the first one. Nevertheless, the final prototype has incorporated some major changes in design for it to function more effectively. For one thing, the mask allows more fit to face as it is an essential requirement under the guidelines of WHO to prevent the spread of COVID 19. The front area of the side plates has structures on the top inside the mask. These structures are used to fix the flexible rubber element which takes on the shape of the face and nose area when the mask is worn giving it a much better fit to face and improving the overall comfort aspect of wearing the mask. Another major design modification has to be the shields which opens and closes are on the outside of the mask as opposed to the first prototype which has them inside. In the final prototype the linear actuator is fixed on the inside and the shields are on the outside of the mask. This seemed more effective in covering the face area compared to the first prototype. 

The left and right plates of Prototype II are the very similar to the first prototype. One of the main modifications brought is the addition of the upper strap holder to the frame in this design. This allowed more strength and rigidity considering it is 3D printed as one piece together with the side plates. Another such modification is the control buttons. Since the buttons used in this design are easier to press as it is bigger in size, the placement had to be made by adjusting the side plate of the face mask. The buttons are placed in slots designed on the left plate of the mask. From an ergonomic perspective it is much easier to access the buttons and press with the current design. The side plates of the first prototype have the strap through cut-outs at the back of the plate, but this prototype has a modification that has a hinged end piece with the cut-outs made in it for the strap that goes behind the head. This is clearly more ergonomic in terms of achieving a better grip on the head when strapped on as it would turn to take the shape of the back of the head who is wearing the mask. The earholes have a groove around them to fit the soft sponge more precisely for better comfort.  

Both left and right shields are attached by the Nose Attachment Piece and the Bottom Plate. They are secured in place with bolts and glue. The Nose Attachment Piece has the housing area for the TF-LUNA proximity sensor at the center. This position allows for better reading of data from the sensor in most orientations as it is in line with the nose and mouth area. The front of the Bottom Plate houses the PIR sensor and it is also aligned in a central position. The Nose clip on the top of the Nose Attachment provides a grip on the nose for better stability of the mask when worn. Each side plate has areas that protrude which house the motors of the linear actuators on either side. The Guide rails run on the top and bottom of the linear actuator parallel to the lead screw of the linear actuator. The guide rails are fixed by placing them in a constrained position by running them through holes and a cover is fixed to restrict its movement in the parallel direction when the linear actuator is active.

The underside of the Bottom Plate houses the battery compartment and the microcontroller with the main PCB. The TB6612FNG Motor Driver, the Arduino Nano and the Logic Level Convertor are all soldered onto to the assigned slots of the PCB. All the electronic wires from the sensors and the motors and directed to the microcontroller though a cut-out in the Bottom Plate from inside of the mask. This allows for better management of wires in order to avoid any accidental loose connections when handling the mask. The power switch is fixed right below the PIR sensor which can be easily accessible.

The linear actuator assemblies of this prototype are fixed on the inner side of the left and right plates. The moveable shields are on the outside. The motor which drives the lead screw is housed in the side plates itself removing the need for an additional part to fix the motor. This also gives more stability when the motor rotates the lead screw of the linear actuator. The end of the lead screw is fitted to the Motor End Stop sub assembly. The Motor End Stop sub assembly consists of an M4 nut fitted into a cut-out on one side of a cylindrical block. The end of the lead screw goes in this nut and is fixed so that when the lead screw rotates this sub assembly rotates as well. The other end of the cylindrical block has a hole where an aluminum hollow shaft piece is pushed in with some amount of the shaft left protruding out. The shaft is glued into place in the cylindrical block so that when the lead screw rotates the whole sub assembly rotates. The protruding part of the shaft of the Motor End Stop sub assembly goes into the bearing bracket which houses a bearing and is bolted to the opposite end of the motor on the side plate.  

The Guide Rails of the linear actuator assembly are aluminum hollow rods that goes through brackets with holes which are part of the side plates. The holes are sealed off with caps on the outer sides and filled with plastic filament on the inside to restrict any parallel movement of the Guide Rails when the linear actuator is active.

The base of the moveable structure of the linear actuator has the nut fixed inside and moves when the lead screw rotates. It has holes for fixing linear bearings that move the structure along the Guide Rails. This structure goes through the cut-outs on the side plates and are bolted to the shied which actually open and close the mask. The linear actuator is mounted in a wall mount configuration and the shield is designed so that when it moves it covers the parts that are exposed to the surrounding. The motor of the linear actuator is kept in place by a cover piece that screws onto the inner side.

The Left Moveable Shield houses the cooling and air regulating fan and the two indicative LEDs (red and green LEDs) for indicating the user of the moisture levels in the filtering element.  

The Easy access cut-out is used for maintenance and easy access to the indicating LEDs and the cooling fan. It is covered up with a panel that screws on top. The Right Moveable Shield houses the humidity sensor and the filtering element. It has cut-outs where the filtering element is placed for air to pass though the filter. The filtering element is held in place with the help of magnets and the magnets can be pushed to release the filtering element when replacing it.

Both shields house an inner and outer limit switch holder which attached the limit switches. These switched are triggered by Switch Pushers which are fixed to the outer side of the left and right plates of the mask. They are fixed precisely so that when the actuator moves the left and right shields and reaches the limits they are pushed and a “high” signal sent to the microcontroller.

As mentioned before the bottom side of the Base plate houses all the electronics and the battery compartment. It also has the main power switch holder which sits right below the PIR sensor. The battery compartment is part of the Base plate and covered off with the Battery Case Cover. The Power Connector beside the Battery Compartment connects the battery terminals to the main PCB with 1.5mm copper wires. The electrical wires coming from the sensors and right motor of the Linear Actuator are guided through the Wire Guide. The main PCB is bolted to the bottom side of Bottom Plate with the Outer and Inner Support structures. The secondary PCB support structure is fixed to the bottom side of the Bottom Plate and holds the TB6612FNG Motor Driver and the Logic Level Convertor PCBs. The Logic Level Convertor converts the 5V logic from the microcontroller to 3.3V logic which is required by the TF-LUNA module and vice versa. An Electronic Panel is used to cover the electronics with the use of the Electronic Support Bracket.


Step 15: Seeed Studio Fusion PCBA Service

In order to make compact circuit design and less messy wiring it is always to good to incorporate a PCB to your project. Seeed Studio Fusion PCBA Service , available at Seeed Fusion PCB Assembly - fast turnkey pcba service from 7 working days, offers comprehensive PCB manufacturing, prototype PCB assembly, and more. Their services cover everything from PCB fabrication, parts sourcing, assembly, to testing, ensuring top-notch quality throughout the process. Furthermore, once you've gauged market interest and validated your prototype, Seeed Propagate Service can assist you in bringing your product to market with expert guidance and a well-established network of connections.

Step 16: Structural Analysis of Prototype II

The structural analysis of the frame of Prototype II was done using ANSYS Workbench. This analysis allowed to identify the maximum deformation points and stress points on the design once certain amounts of loads were applied to it. It is useful to identify this before manufacture in order to save time and maximize the productivity in terms of identifying flaws and design errors. I won't go into details on how to setup the model in Ansys in this article but if anyone is interested feel free to send me a message.


Step 17: Working Principle of Prototype II

Prototype II works similar to that of Prototype I except for the fact that some components are replaced with others to achieve better functionality. The linear actuator is also the same type used in Prototype I but are fixed on the inside of the mask. The main control buttons also serve the same functions as Prototype I but are replaced with bigger and easy to press buttons. They are fitted into the slots that are on the left plate of the mask and the wires are routed through the holes to the underside of the Bottom Plate. The limit buttons used in Prototype I are just simple push buttons and they are replaced by limit switches in Prototype II. 

The TF-LUNA proximity sensor is mounted in the Nose Attachment which joins the two side plates of the mask. The TF-LUNA communicates using the UART protocol to the Arduino Nano to transmit data. Since there is no requirement for the sensor to receive any data, only transmission of data from the sensor to the microcontroller happens. It used the principle of Time of Flight (TOF) to get the distance between an object. A modulated wave of infrared light is emitted from the light source and received by the photosensor and the difference in phase angle and time it took to reach is used to calculate the distance using specific algorithms. The PIR sensor is similar to the one used in Prototype I and the limit switches also function in the same way with some modifications brought to the position of them in the design. Prototype II uses a DHT-22 Humidity sensor to measure the moisture and has two indicative LEDs (red and green) to indicate the moisture levels in the filtering element.  

The microcontroller receives data from the TF-LUNA (Proximity Sensor) and the Passive Infrared Sensor (PIR Sensor) and send the appropriate signal to the TB6612FNG Motor Drivers to either rotate the motors of the linear actuator clockwise, anticlockwise or halt. If any of the limit switches are pushed while opening or closing of the shields, a signal is sent to the microcontroller to indicate it has reached its limit of movement while closing or opening of the shield. Based on the feedback from the limit switches the motor is rotated. The DHT-22 humidity sensor also sends humidity data to the microcontroller and the appropriate indicative LED is lit to indicate the moisture levels in the filtering element to know if it should be replaced. The microcontroller turns on the cooling fan whenever the shields are in a closed position and turns off the fan when the shields are in an open position. This is done with a BD681 Bipolar Junction Transistor. The control buttons also have back LEDs which can be controlled. These LEDs are turned on whenever the manual mode is active and the back LEDs are turned off when it is auto mode. This too is controlled using a BD681 BJT transistor.


Step 18: Component Wiring of Prototype II

The wiring of the limit switches and the PIR Sensor of Prototype II are similar to that of Prototype I with the exception of the type of limit switches used. This prototype uses a much more compact 7.4V Li-ion battery to power all the components including the microcontroller. Unlike the Prototype I, the microcontroller is powered using a regulated 5V supplied by an AMS1117CD-5.0 voltage regulator. This voltage regulator also supplies power to the back LEDs of the control buttons. The input for the voltage regulator is drawn from the 7.4V battery. The rest of the components are powered using 5V drawn from the microcontroller. The output terminal of the voltage regulator is connected in parallel to a 22-microfarad capacitor and the input connected in parallel to a 10-microfarad capacitor for stability during operation.

The motors terminals of the linear actuators are connected to the TB6612FNG motor driver which then communicates with the microcontroller. The motor driver has an additional pin for keeping it in standby mode. When supplied with a 5V “high” signal the it is active and 0V “low” signal keeps it inactive. Similar to the ENA and ENB in the L298N motor driver, the TB6612FNG has PWMA and PWMB pins to control the speed of the motor. In this case these two pins are set to maximum of 5V so that is rotates at maximum always. The ground pin of the motor driver is connected to the common ground of the whole circuit. The VM pin is supplied with the positive voltage for the motor which is 7.4V and the VCC pin is supplied with logic voltage of 5V from the microcontroller. The pins AIN1 and AIN2 are inputs for Motor A and BIN1 and BIN2 are inputs for Motor B. The pins AO1 and AO2 are outputs are Motor A and BO1 and BO2 are outputs for Motor B. A logic level convertor is used to convert the 5V signals from the microcontroller to 3.3V which is acceptable by the TF-LUNA module. Hence all communication relayed from the microcontroller passes though the logic level convertor before reaching the TF-LUNA proximity sensor. The Logic Level Convertor is wired by connecting the 5V supply from the Arduino Nano to the High Voltage input and connecting the common ground. The Low Voltage input of the Logic Level Convertor is connected to 3.3V of Arduino Nano. This ensures that the remaining terminals on the high voltage side are always 5 V and the corresponding Low voltage side always have 3.3 V. There are in total 12 pins on the Logic Level Convertor. Two rows of 6 pins of which one row contains all the high voltage inputs and outputs and the other row contains all the low voltage inputs and outputs. There are four separate data channels of which each is capable of shifting data to and from the high and low voltages.  These pins are labelled HV1, LV1, HV2, LV2, HV3, LV3, HV4, and LV4. It is not necessary to use all the channels and the usage depends on the application it is used for. Unused pins can be left floating. For this project HV3, LV3, HV4 and LV4 are used. Below shows the connections between the Arduino Nano and the Logic Level Convertor.

  • HV4 – Arduino Nano pin 2
  • LV4 – TF-LUNA Transmit pin (TXD)
  • HV3 – Arduino Nano pin 3
  • LV3 – TF-LUNA Receive pin (RXD)

The Arduino connections are described below.

  • TF-LUNA TXD: Arduino Pin 2 via logic level convertor
  • TF-LUNA RXD: Arduino Pin 3 via logic level convertor
  • Left Motor Input1/ Motor A: Arduino Pin 4
  • Left Motor Input2/ Motor A: Arduino Pin 5
  • Right Motor Input1/ Motor B: Arduino Pin 6
  • Right Motor Input2/Motor B: Arduino Pin 7
  • Left Motor Outer Limit Switch: Arduino Pin 8
  • Left Motor Inner Limit Switch: Arduino Pin 9
  • Right Motor Outer Limit Switch: Arduino Pin 10
  • Right Motor Inner Limit Switch: Arduino Pin 11
  • Control Button (Right): Arduino Pin 12
  • Control Button (Left): Arduino Pin 13
  • Auto/Manual switching Button: Arduino Pin A0
  • PIR Sensor Signal: Arduino Pin A1
  • DHT-22 Signal: Arduino Pin A2
  • Motor Driver Standby: Arduino Pin A3
  • Cooling/ Air regulating Fan: Arduino Pin A4
  • LEDs on the back of the control buttons: Arduino Pin A5
  • Humidity Red Indicating LED: Arduino Pin 1
  • Humidity Green Indicating LED: Arduino Pin 0


For the Prototype II all the connections were made after designing the PCB. Using a PCB allowed for better use of space since every needed to be as compact as possible. The PCB was designed using EasyEDA online platform. The circuit designing tool has a rich library of components which can be integrated into the circuit that is being designed so the PCB can be created accurate to the nearest millimeter. The first step is to design the circuit schematic diagram.


Step 19: Programming and Component Interface of Prototype II

Similar to Prototype I, Prototype II also has the same microcontroller which means that the programming interface used in the Arduino IDE. The basic concepts of how the IDE works has been discussed before and this section will mostly highlight on how individual components used in this prototype are programmed and interfaced using the Arduino Nano microcontroller. In addition to that, the full code containing the interfacing with all component will also be discussed. 

The TF-LUNA proximity sensor module is programmed using the UART communication protocol. It should be noted that the module provides three outputs namely the distance between an object and the sensor, the chip temperature, and the signal strength. For this application only the distance is used as that is the output we are concerned with. The software serial library is used since two normal GPIO pins will be used for the TX and RX pins. The built in TX and RX pins are used for displaying the data on the serial monitor.  Once the data from the sensor is sent, it is stored as an array. This data is then verified and retrieved to calculate the required parameters. The different contents of the array are manipulated to obtain the different parameters. The seconds and third values of the array are added and multiplied by 256 to obtain the distance. The fourth and fifth values of the array are added and multiplied by 256 to obtain the signal strength. Finally, the sixth and seventh values of the array are added and multiplied by 256 to obtain the chip temperature.

To illustrate the standalone use of TF_LUNA module, the code will show how the distance is calculated and an LED is turned on and off depending on the distance an object is to the sensor and the message printed on the Serial monitor in either case if the LED is on or LED is off.


Step 20: End Results

The second prototype in comparison to the first performs better after addressing some of the design flaws in Prototype I and replacement of components with better sensitivity. One of the issues with the HC-SR04 used in the first prototype was that the range of it was limited to 2cm and 400 cm and once in a while it would give off inaccurate reading which are above its upper limit which would freeze the module until the next reading. The only workable way around this was to calculate and average and put in a check to see if the value exceeds the upper limit in the program. This meant more processing had to be done and would sometimes produce undesired results. On the other hand, the TF-LUNA module used in Prototype II has an operating range of 0.2m to 8m and a resolution of 1 cm. The TF-LUNA is more sensitive and the reading are more accurate. While PIR sensor remains same for both prototypes, the DHT-22 humidity sensor used in Prototype II has a wider range of humidity readings with better accuracy up to 2.5% as opposed to DHT-11 which has and accuracy of up to 5%.

For Prototype II, a PCB design was used which allowed for better connections in a compact space. It also ensured size reductions in some components such as the pull-down resistors in the limit switches and control buttons which were of the surface mount type. Most of the components used in Prototype II are smaller in size and weight which made a remarkable difference in the overall design. This leeway in weight and size gave way for a better and rigid design in the second prototype. This rigidity is brought in the form of aluminum hollow tubes used as guide rails for the linear actuators in Prototype II as opposed to 3D printed guide rails in the first prototype. In addition to this, the moveable shields are also bigger in the seconds prototype which were able to cover well the opening once in closed position. For these reasons, the weight of Prototype II exceeds by 30g compared to Prototype I. Prototype I weigh 0.55 kg whereas Prototype II weighs 0.58 kg. There was also a small but noticeable variance in the RPM of the two motors of the linear actuators of both prototypes owing to small imbalances in the overall weight distribution on the two linear actuator assemblies. Although this does not affect the overall functionality of the face mask, it meant that one of the shields opened or closed a bit earlier than the other.

Another upgrade brought in the second design is the use of magnets to hold the filtering element in place. This ensured that it kept a constant touch on the humidity sensors which gave a better reading of the moisture levels in the filtering element. In addition to this the control buttons used Prototype II are bigger in size and easily accessible as opposed to the small push buttons used in Prototype I.

The design of the first prototype had the moveable shields of the mask on the inside of the mask and the left and right linear actuator assemblies were fixed on the outside of the mask to the left and right plates respectively. This actually posed two problems. The first problem was that when the user wore the mask, there was always some possibility of the shields touching the face when they were in motion. This caused some discomfort to the person wearing the mask and also would eventually lead to failure of the linear actuators and the shields if persisted touching continued. The second problem was the difficulty in completely sealing the inside from the outside as there were some challenges in covering the gaps from inside due to limited space. This was a major problem as this depended on the main use of wearing a mask in the first place. By considering this design flaw which lead to two major problems, it was necessary to address this issue in the design of the second prototype. The design of Prototype II has the moveable shields placed on the outside of the mask and the linear actuator assemblies on the inside. Flipping the placement of the linear actuator assemblies and the moveable shields gave more room to work on completely sealing the mask when the shields are in the fully closed position even though there had to be a compromise made in the overall weight and size of the mask as the shields had to be designed a bit bigger which would increase the weight and size. The linear actuator assemblies are placed inside the mask and therefore are also prone to touch the face of the user. To counter this problem a panel is used to cover the linear actuator assemblies to prevent the face from touching any moving parts or the any part of the linear actuator assemblies for that matter.

The L298N motor driver used in the first prototype added a lot of weight and took up considerable amount of space. This was a problem as it increased the overall weight and size of the mask. To counter the problem a much smaller in size and lighter in weight TB6612FNG motor driver is used in the second prototype. Their functions are almost similar with some added functionality such as short-brake in the TB6612FNG. Interfacing with the microcontroller were also very similar for both modules.

The design of the first prototype did not dedicate a special place to fix the DHT-11 humidity sensor. Since the original design of the shields were too small in the first prototype it was difficult to fix a humidity sensor on any of the shields. For this reason, the only option for a place to fix the humidity sensor was the bottom plate inside the mask. The problem with that was the filtering element was bent and shaped to cover the humidity sensor but the area of the filtering element which normally would get wet when the user wears the mask was not touching the sensor. This was a problem as the filtering element had to get really wet to detect high levels of moisture by the DHT-11 sensor and indicate that the filtering element needed to be replaced. In order to counter this problem, the second prototype has the DHT-22 humidity sensor fixed on the inside of the right shield and is fitted in a dedicated slot where the filtering element is kept in constant touch with the sensor with the help of small magnets. This design is more effective as the user would speak and breath directly to the shields and would produce a much better reading of the actual state of the filtering element and test for its wetness.

It can be concluded that after having built the first prototype, gave much insight into developing the second. To further improve the second prototype additional functionality can be added such as adding a real time clock module such as DS3231 to accurately measure the elapsed time between readings of the sensors to activate the linear actuators, but this would also mean that there would be a need for more GPIO pins and would have to replace the current microcontroller with one which has more GPIO pins let alone restrictions in size. With the growing number of compact microcontroller boards and sensors integrated with multiple functions the final prototype can further be enhanced in design and functionality while reducing the overall weight.



Step 21: Mechanical Mask Video

3D Model Files

Arduino Main Code

Hope you liked this build and feel free to share your opinions or any questions you might have. Thanks!

Wear It Contest

Judges Prize in the
Wear It Contest