Introduction
During the Input Devices week, I learned how different sensors work and how they provide input data to a microcontroller. Input devices allow an embedded system to detect changes in its surroundings, such as light, temperature, sound, motion, water level, and distance. I gained an understanding of the difference between analog and digital signals, where analog signals vary continuously while digital signals have only two states: HIGH and LOW.
As part of this assignment, I tested various sensors, including the IR sensor, Ultrasonic sensor, Sound sensor, Float sensor, PIR sensor, DHT11, and DHT22, using the Speed XIAO ESP32-C3 and ESP32 development boards. I monitored and analyzed the sensor outputs using the Serial Monitor and Serial Plotter in the Arduino IDE. Additionally, I learned how to observe and measure sensor signals with an oscilloscope, which helped me better understand the behavior and characteristics of different input devices.
Input Devices
An input device is a hardware component that provides data or signals to a computer or microcontroller, allowing it to detect changes in the surrounding environment. These devices sense physical parameters such as light, temperature, sound, distance, or motion and convert them into electrical signals that the microcontroller can process. Based on the received input, the microcontroller performs the required operation or controls the connected output devices.
What is sensor?
A sensor is an electronic device that detects or measures changes in the surrounding environment and converts them into electrical signals. It can sense physical parameters such as light, temperature, sound, distance, motion, or humidity and send this information to a computer or microcontroller. The microcontroller processes the received data and performs the required operation.
Types of sensors:-

Sensors Explored During This Week
During this week, a variety of input sensors were introduced to understand how different physical parameters can be detected and processed in embedded systems. We studied the working principle, internal structure, datasheets, and applications of each sensor. Some of these sensors were also practically interfaced with Arduino, while others were studied to understand their functionality and real-world use cases.
The following sensors were explored during this week:
1. DHT11 Temperature and Humidity Sensor
The DHT11 is a digital sensor used to measure temperature and humidity. It is commonly used in weather stations, home automation, and environmental monitoring projects.

DHT11 Sensor
2. DHT22 Temperature and Humidity Sensor
The DHT22 is an advanced version of the DHT11, offering higher accuracy and a wider measurement range. It is suitable for applications requiring precise environmental monitoring.

DHT22 Sensor
3. Sound Sensor
A Sound Sensor detects sound waves using a built-in microphone and converts them into electrical signals. It is commonly used in clap switches, sound monitoring, and security systems.

Sound Sensor
4. IR (Infrared) Sensor
An IR Sensor detects nearby objects using infrared light. It consists of an IR transmitter and receiver and is widely used in obstacle detection, object sensing, and automation projects.

IR Sensor
5. PIR Motion Sensor
A PIR Sensor detects human or animal movement by sensing changes in infrared radiation. It is commonly used in security systems and automatic lighting.

PIR Sensor
6. Ultrasonic Sensor
The Ultrasonic Sensor measures the distance between the sensor and an object using ultrasonic sound waves. It is widely used in obstacle detection and distance measurement applications.

Ultrasonic Sensor
7. RFID RC522 Module
The RFID RC522 module reads RFID cards and tags using radio frequency communication. It is commonly used in attendance systems and access control applications.

RFID RC522 Module
8. MQ2 Gas Sensor
The MQ2 Sensor detects combustible gases and smoke in the surrounding environment. It is commonly used in gas leakage detection and fire safety systems.

MQ2 Gas Sensor
9. MQ7 Carbon Monoxide Sensor
The MQ7 Sensor is specifically designed to detect Carbon Monoxide (CO) gas. It is widely used in air quality monitoring and industrial safety applications.

MQ7 Sensor
10. LDR (Light Dependent Resistor)
An LDR is a light-sensitive sensor whose resistance changes according to the intensity of light falling on its surface. It is commonly used in automatic lighting systems and light-controlled devices.

LDR Sensor
11. Soil Moisture Sensor
The Soil Moisture Sensor measures the moisture content present in soil. It is widely used in smart irrigation and agricultural monitoring systems.

Soil Moisture Sensor
12. Rain Sensor
The Rain Sensor detects the presence of water or rainfall by sensing changes in conductivity on its detection plate. It is commonly used in weather monitoring systems.

Rain Sensor
13. Flame Sensor
The Flame Sensor detects fire by sensing infrared radiation emitted by flames. It is commonly used in fire detection and safety systems.

Flame Sensor
14. Float Sensor
The Float Sensor detects the level of water or other liquids using a floating mechanism. It is commonly used in water tanks and automatic level control systems.

Individual Assignment
During this week’s individual assignment, I performed hands-on interfacing of different input sensors with an Arduino Uno and XIAO ESP32-C3 to understand their working principles and practical applications. Each sensor was connected according to its circuit diagram, programmed using the Arduino IDE, and tested to verify its functionality. Depending on the sensor, the output was observed through the Serial Monitor or by controlling output devices such as LEDs and buzzers.
This practical exercise helped me understand how different input devices communicate with a microcontroller, how sensor data is processed, and how appropriate actions can be performed based on the received input signals.
The following sensors were successfully interfaced and tested during this assignment:
- DHT11 Temperature and Humidity Sensor
- DHT22 Temperature and Humidity Sensor
- IR Sensor
- Sound Sensor
- PIR Motion Sensor
- Ultrasonic Sensor
- MQ2 Gas Sensor
- Float Sensor
Sensors Used with Arduino Uno
DHT11 Temperature and Humidity Sensor
The DHT11 is a digital temperature and humidity sensor designed for basic environmental monitoring applications. It uses a capacitive humidity sensor and an NTC thermistor to measure humidity and temperature and provides calibrated digital output. The sensor measures temperatures from 0°C to 50°C and humidity from 20% to 90% RH, making it suitable for Arduino, ESP32, weather stations, and smart home projects.
Hardware components we used:-
- Arduino Uno
- DHT 11 temperature sensor
- Connecting wires
Pin description:-
- VCC: Supplies power to the DHT11 sensor. Connect this pin to 3.3 V or 5 V.
- DATA: Transfers temperature and humidity data to the microcontroller using a single-wire digital communication protocol.
- NC (Not Connected): This pin is not used and should be left unconnected.
- GND: Connects the sensor to the ground (GND) of the microcontroller to complete the circuit.


DHT22 Temperature and Humidity Sensor
The DHT22 (AM2302) is a digital temperature and humidity sensor that provides accurate and reliable measurements. It uses a capacitive humidity sensor and a thermistor to measure humidity and temperature. The sensor operates over a temperature range of −40°C to 80°C and a humidity range of 0–100% RH, making it suitable for weather stations, smart homes, and environmental monitoring applications.
Hardware components we used:-
- Arduino Uno
- DHT 22 temperature sensor
- Connecting wires
Pin description:-
- VCC: Supplies power to the DHT22 sensor. Connect this pin to 3.3 V or 5 V.
- DATA: Transfers temperature and humidity data to the microcontroller using a single-wire digital communication protocol.
- NC : This pin is not used and should be left unconnected.
- GND: Connects the sensor to the ground (GND) of the microcontroller to complete the circuit.


IR sensor
The IR (Infrared) sensor is an electronic sensor used to detect objects or obstacles using infrared light. It consists of an IR LED that emits infrared light and a photodiode or phototransistor that receives the reflected light. When an object is detected, the sensor generates an output signal. It is commonly used in obstacle detection, line-following robots, and automation systems.
Hardware components we used:-
- Arduino Uno
- IR Sensor
- Connecting wires
Pin description:-
- VCC: Supplies power to the IR sensor module. Connect this pin to 3.3 V or 5 V.
- GND: Connects the sensor to the ground (GND) of the microcontroller to complete the circuit.
- OUT: Sends a digital HIGH or LOW signal to the microcontroller depending on whether an object is detected.


Sensors Used with Seeed Studio XIAO ESP32-C3
Float Sensor
The Float Sensor is a water level detection sensor used to identify the presence or absence of water at a specific level. It works using a floating mechanism that moves according to the water level and changes the electrical state of the internal switch.


Here is the code i used
int floatPin = 2;int ledPin = 8;void setup() { pinMode(floatPin, INPUT_PULLUP); pinMode(ledPin, OUTPUT); Serial.begin(9600);}void loop() { int sensorState = digitalRead(floatPin); if (sensorState == LOW) { digitalWrite(ledPin, HIGH); Serial.println("Water Level High - led ON"); } else { digitalWrite(ledPin, LOW); Serial.println("Water Level Low - led OFF"); } delay(500);}
The Float Sensor successfully detected changes in water level and triggered the buzzer when the water reached the set level. The status was also displayed on the Serial Monitor, demonstrating how water level monitoring and alert systems can be implemented using sensors.
Ultrasonic Sensor
The Ultrasonic Sensor is used to measure the distance between the sensor and an object. It works by transmitting ultrasonic sound waves and measuring the time taken for the reflected waves to return to the sensor. Based on this time, the distance is calculated and displayed.


Here is the code i used
#define TRIG_PIN 3
#define ECHO_PIN 4
#define LED_PIN 8
long duration;
float distance;
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.println("Ultrasonic Sensor Test Started");
}
void loop() {
// Send ultrasonic pulse
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Read echo time
duration = pulseIn(ECHO_PIN, HIGH);
// Calculate distance in cm
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// LED control
if (distance < 10) {
digitalWrite(LED_PIN, HIGH);
Serial.println("Object Detected - LED ON");
}
else {
digitalWrite(LED_PIN, LOW);
Serial.println("No Object - LED OFF");
}
delay(500);
}
PIR Motion Sensor
The PIR (Passive Infrared) sensor is an electronic device used to detect motion by sensing changes in infrared radiation emitted by humans and animals. It is widely used in security systems, automatic lighting, and various motion detection applications. The sensor continuously monitors the infrared energy present in its surroundings. When a person or object moves within its detection range, the sensor detects the change in infrared radiation and produces an output signal that can be processed by a microcontroller.

Here is the code i used
const int pirPin = D2;const int LED_Pin = D3;void setup() { pinMode(pirPin, INPUT); pinMode(LED_Pin, OUTPUT); Serial.begin(115200);}void loop() { int motion = digitalRead(pirPin); if (motion == HIGH) { digitalWrite(LED_Pin, HIGH); Serial.println("Motion Detected"); } else { digitalWrite(LED_Pin, LOW); Serial.println("No Motion"); } delay(500);}
The PIR motion sensor successfully detected movement and controlled the LED based on the presence of motion within its detection range. The Serial Monitor displayed “Motion Detected” when movement was detected and “No Motion” when no activity was present. This experiment demonstrated the use of the Seeed Studio XIAO ESP32-C3 microcontroller for motion detection, alert systems, and security-based applications.
Sound Sensor
The sound sensor is an electronic device used to detect sound waves using a built-in microphone. It converts sound signals into electrical signals, which can be processed by a microcontroller to perform specific actions based on sound input. It is commonly used in sound-activated switches, security systems, voice-controlled devices, and automation projects.


Here is the code i used
const int soundPin = D2;const int LED_Pin = D3;void setup() { pinMode(soundPin, INPUT); pinMode(LED_Pin, OUTPUT); Serial.begin(115200);}void loop() { int soundState = digitalRead(soundPin); if (soundState == HIGH) { digitalWrite(LED_Pin, ON); Serial.println("Sound Detected"); } else { digitalWrite(LED_Pin, OFF); Serial.println("No Sound Detected"); } delay(200);}
The sound sensor successfully detected claps and loud sounds. When sound was detected, the buzzer turned ON and the Serial Monitor displayed “Sound Detected”; otherwise, it displayed “No Sound Detected”. This experiment demonstrated the use of the Seeed Studio XIAO ESP32-C3 for sound-based alert and automation systems.
MQ2 Gas Sensor
The MQ2 Gas Sensor is used to detect combustible gases and smoke in the environment. It can sense gases such as LPG, methane, propane, hydrogen, and smoke, making it useful for gas leakage detection and safety systems. The sensor measures changes in gas concentration and converts them into electrical signals that can be processed by a microcontroller.


Here is the code i used
#define MQ2_PIN 3
#define LED_PIN 8
int gasValue;
int threshold = 1500;
void setup() {
Serial.begin(115200);
pinMode(MQ2_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.println("MQ2 Gas Sensor Test Started");
}
void loop() {
gasValue = analogRead(MQ2_PIN);
Serial.print("Gas Sensor Value: ");
Serial.println(gasValue);
if (gasValue > threshold) {
digitalWrite(LED_PIN, HIGH);
Serial.println("Status: Gas Detected - LED ON");
}
else {
digitalWrite(LED_PIN, LOW);
Serial.println("Status: No Gas Detected - LED OFF");
}
Serial.println("------------------------");
delay(1000);
}
Analog and Digital Signals
Electronic sensors communicate with microcontrollers by generating electrical signals. These signals are mainly divided into two types: analog signals and digital signals. Understanding the difference between these signals is important because sensors provide different types of outputs, which are processed by the microcontroller to perform specific tasks.
Analog signal
An analog signal is an electrical signal that changes continuously over time and can have an infinite number of values within a given range. It is commonly used to represent real-world physical quantities such as temperature, light intensity, sound, pressure, and humidity. Since analog signals vary smoothly, they provide more detailed information than digital signals.
Digital signal
A digital signal is a type of electrical signal that has only two possible states: HIGH (1) and LOW (0). Unlike an analog signal, it does not vary continuously. Digital signals are widely used in computers and microcontrollers because they are easy to process, reliable, and less affected by electrical noise.

Difference Between Analog and Digital Signals
| Analog Signal | Digital Signal |
|---|---|
| Continuous signal | Discrete signal |
| Has infinite values within a range | Has only two states (HIGH or LOW) |
| Output changes smoothly | Output changes instantly |
| Read using Analog Pins (ADC) | Read using Digital Pins |
| Example: LDR, MQ2, Soil Moisture | Example: PIR, RFID, Float Sensor |
Group assignment
As part of this week’s group assignment, we learned to use an oscilloscope for observing and analyzing electrical signals. The objective of this activity was to understand the operation of an oscilloscope and visualize digital signals generated by electronic circuits. This practical session helped us understand the importance of oscilloscopes in testing, debugging, and analyzing electronic systems.
What is an Oscilloscope?
An Oscilloscope is an electronic measuring instrument used to display electrical signals in the form of waveforms. It helps us observe changes in voltage over time and analyze the behavior of electronic circuits. Oscilloscopes are widely used in electronics laboratories for testing, troubleshooting, measuring signals, and verifying the performance of electronic systems.

During the group assignment, we connected an LED circuit to an oscilloscope to observe its digital output signal. When the LED switched ON and OFF, the oscilloscope displayed the corresponding waveform, helping us understand the transition between LOW (0V) and HIGH voltage levels in digital signals. We also learned how to connect the oscilloscope probe correctly, adjust the time scale, voltage scale, and trigger settings to obtain a stable and clear waveform for accurate analysis.

The oscilloscope successfully displayed the digital waveform generated by the LED circuit. When the LED was turned ON, the waveform reached the HIGH state, and when the LED was turned OFF, it changed to the LOW state. By observing these signal transitions, we gained a better understanding of digital signal behavior and learned how oscilloscopes help visualize electronic signals in real time.
Conclusion
This group assignment provided practical experience in using an oscilloscope to analyze digital signals. It helped us understand waveform visualization, signal measurement, and oscilloscope operation. The knowledge gained from this activity will be useful for testing, debugging, and developing future embedded systems and electronic circuits.
Week Summary
This week focused on understanding input devices, sensors, and signal processing in embedded systems. I learned how sensors convert physical changes from the environment into electrical signals that can be processed by microcontrollers. I explored the working principles, internal structures, and applications of different sensors such as DHT11, DHT22, Sound Sensor, PIR Motion Sensor, Ultrasonic Sensor, RFID RC522, MQ2 Gas Sensor, and Float Sensor. These sensors were interfaced with Arduino Uno and Seeed Studio XIAO ESP32-C3 and tested using Arduino IDE, Serial Monitor, LEDs, and buzzers. I also learned about analog and digital signals and how microcontrollers process sensor outputs. In the group assignment, we used an oscilloscope to observe digital waveforms and understand signal transitions. This practical experience improved my knowledge of sensor interfacing, signal analysis, and embedded system development.