Week 11: Input Devices

Input Devices

Assignment activities:

Group assignment:

Probe an input device's analog levels and digital signals

Individual assignment:

Measure something: add a sensor to a microcontroller board that you have designed and read It

I.Group Assignment:

Probe an input device's analog levels and digital signals

If you want to explore the group Assignment Click Here

In group assignment we probe a moisture sensor as the input device and measure its output voltage using a multimeter and visualize the signal on an oscilloscope

Gather the necessary equipment:
  • Moisture sensor
  • Multimeter with voltage measurement capability
  • Oscilloscope
  • Connecting wires
  • results of this activities
  • Determine the desired output voltage range and choose appropriate resistor values for the voltage divider.
  • Connect one end of the first resistor to the VCC pin of the moisture sensor.
  • Connect the other end of the first resistor to the OUT pin of the moisture sensor.
  • Connect the junction between the first resistor and the OUT pin to one end of the second resistor.
  • Connect the other end of the second resistor to the ground (GND) reference.
  • Downloded Templete

    Downloded Templete

    II.Individual assignment:

    In this Assignment we will use DHT11 Sensor for measuring Temperature and Humidity.

    1. DHT11 Temperature and Umidity Sensor

    The DHT11 is a digital temperature and humidity sensor that uses a capacitive humidity sensor and a thermistor to measure the surrounding air. It provides reliable readings of temperature ranging from 0 to 50°C with an accuracy of ±2°C and relative humidity ranging from 20 to 80% RH with an accuracy of ±5%. The sensor is connected via a single-wire serial interface and can be easily interfaced with most microcontrollers. Click Here for Reference

    Downloded Templete

    1. Datasheet for DHT11 Temperature and Umidity Sensor

        2. Operating voltage: 3V to 5.5V DC
        2. Current Consumption: 2.5mA max
        3. Humidity measurement range: 20% to 90% RH
        4. Temperature measurement range: 0°C to 50°C
        5. Accuracy: ±5% RH, ±2°C
        6. Sampling rate: once every 2 seconds

      Downloded Templete

      2. Pin Description for DHT11 Temperature and Umidity Sensor

        2. Pin 1: VCC: Power supply (3.3V to 5.5V)
        2. Pin 2: Data: Serial data output
        3. Pin 3: NC: Not connected
        4. Pin 4: GND: Ground

      Downloded Templete

      3. Timing Diagram for DHT11 Temperature and Umidity Sensor

      The sensor transmits data by encoding it in 40 bits with a specific timing sequence. The following is the timing diagram for the DHT11 sensor, Note: Each bit is transmitted as a 50us low followed by either a 26-28us high (0) or a 70us high (1).

      Downloded Templete

      By using a microcontroller board that you have designed in Week 9 Output_Devices We use DHT11 Temperature and Umidity Sensor as Input Device for measuring Temperature and Humidity and we use also ESP23 Microcontroller, ESP23 Datasheet

      Here is Schematic Used

      Downloded Templete

      Here is PCB Used

      Downloded Templete

      Here is our PCB after Milling

      Downloded Templete

      Here is our PCB after soldering Componments

      Downloded Templete

      Here we have connected our Input Sensor to the microcontroller Board

      Downloded Templete

      Here are the code we run with Arduino for Input Device

      Here we Install DHT 11 Sensor libraries in Arduino for able to run our output Device

      Downloded Templete

                                 
                                  #include "DHT.h"
                                  #define DHTPIN 21
                                  #define DHTTYPE DHT11
                                  
                                  DHT dht(DHTPIN, DHTTYPE);
                                  
                                  void setup() {
                                    Serial.begin(9600);
                                    dht.begin(); // initialize the sensor
                                  }
                                  
                                  void loop() {
                                    // wait a few seconds between measurements.
                                    delay(2000);
                                  
                                    // read humidity
                                    float humi  = dht.readHumidity();
                                    // read temperature as Celsius
                                    float tempC = dht.readTemperature();
                                    // read temperature as Fahrenheit
                                    float tempF = dht.readTemperature(true);
                                  
                                    // check if any reads failed
                                    if (isnan(humi) || isnan(tempC) || isnan(tempF)) {
                                      Serial.println("Failed to read from DHT sensor!");
                                    } else {
                                      Serial.print("Humidity: ");
                                      Serial.print(humi);
                                      Serial.print("%");
                                  
                                      Serial.print("  |  "); 
                                  
                                      Serial.print("Temperature: ");
                                      Serial.print(tempC);
                                      Serial.print("°C ~ ");
                                      Serial.print(tempF);
                                      Serial.println("°F");
                                    }
                                  }
                                  
                                 
                                 

      Downloded Templete

      Downloded Templete

      For found my final results of input device watch the following Video

      If you want to learn about my code, kindly click here