Unit 2: Input devices with NodeMCU - Practice Quiz

ECE237 — Architecting Smart Iot Devices 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which two environmental quantities are measured by a DHT11 sensor?

Programming NodeMCU for DHT11 Easy
A. Distance and pressure
B. Motion and speed
C. Light and sound
D. Temperature and humidity

2 Which DHT11 pin sends sensor readings to the NodeMCU?

Programming NodeMCU for DHT11 Easy
A. Ground pin
B. Power pin
C. Reset pin
D. Data pin

3 Which Arduino function is commonly used to start a DHT sensor object?

Programming NodeMCU for DHT11 Easy
A. dht.begin()
B. dht.stop()
C. dht.reset()
D. dht.close()

4 Which function commonly reads relative humidity from a DHT library?

Programming NodeMCU for DHT11 Easy
A. dht.readHumidity()
B. dht.readLight()
C. dht.readPressure()
D. dht.readDistance()

5 What does an ultrasonic sensor commonly measure?

Programming NodeMCU for Ultrasonic sensor Easy
A. Humidity
B. Brightness
C. Distance
D. Temperature

6 Which ultrasonic sensor pin is used to send the sound pulse?

Programming NodeMCU for Ultrasonic sensor Easy
A. Supply pin
B. Ground pin
C. Trigger pin
D. Echo pin

7 Which ultrasonic sensor pin returns a pulse whose duration represents distance?

Programming NodeMCU for Ultrasonic sensor Easy
A. Echo pin
B. Power pin
C. Trigger pin
D. Reset pin

8 Why is the sound travel distance divided by 2 when calculating object distance?

Programming NodeMCU for Ultrasonic sensor Easy
A. The sensor sends two separate trigger pulses
B. The NodeMCU reads two analog voltage values
C. The echo pin operates at twice the speed
D. The sound travels to the object and back

9 Which NodeMCU pin is typically used to read an analog temperature sensor?

programming temperature sensor Easy
A. A0
B. RST
C. TX
D. D0

10 Which Arduino function reads a value from an analog temperature sensor?

programming temperature sensor Easy
A. delay()
B. analogRead()
C. digitalWrite()
D. pinMode()

11 What must usually be done to an analog temperature sensor's ADC reading to obtain temperature?

programming temperature sensor Easy
A. Use it as a Wi-Fi password
B. Convert it using the sensor formula
C. Send it directly to the reset pin
D. Treat it as a digital output state

12 What is a common use of an IR sensor connected to a NodeMCU?

programming ir sensor Easy
A. Storing program code
B. Detecting nearby objects
C. Producing ultrasonic waves
D. Measuring air humidity

13 Which Arduino function commonly reads the digital output of an IR sensor?

programming ir sensor Easy
A. WiFi.disconnect()
B. digitalRead()
C. Serial.begin()
D. analogWrite()

14 How should a NodeMCU pin connected to an IR sensor's digital output normally be configured?

programming ir sensor Easy
A. As an output
B. As a serial transmitter
C. As a power supply
D. As an input

15 Which sensor generally provides better measurement accuracy?

Compare DHT11 and DHT22 Easy
A. DHT11
B. DHT22
C. Neither measures accurately
D. Both are always identical

16 Which sensor generally supports a wider temperature measurement range?

Compare DHT11 and DHT22 Easy
A. Both have the same range
B. Neither measures temperature
C. DHT11
D. DHT22

17 Which sensor is generally less expensive for basic temperature and humidity projects?

Compare DHT11 and DHT22 Easy
A. Neither is sold separately
B. DHT22
C. DHT11
D. Both always cost the same

18 What does an LDR sensor detect?

programming LDR sensor Easy
A. Object distance
B. Sound intensity
C. Light intensity
D. Air pressure

19 How does an LDR's resistance normally change when light intensity increases?

programming LDR sensor Easy
A. It increases
B. It becomes infinite
C. It decreases
D. It remains fixed

20 Why is an LDR commonly connected in a voltage-divider circuit?

programming LDR sensor Easy
A. To produce a measurable voltage
B. To measure relative humidity
C. To generate an ultrasonic pulse
D. To transmit data over Wi-Fi

21 A NodeMCU repeatedly receives NaN from dht.readTemperature(). What should the program do before using the returned value?

Programming NodeMCU for DHT11 Medium
A. Check the value with isnan()
B. Set the DHT pin to OUTPUT
C. Convert the value with String()
D. Multiply the value by 100

22 A DHT11 is connected to NodeMCU pin D4. Which initialization is appropriate when using a common DHT sensor library?

Programming NodeMCU for DHT11 Medium
A. DHT dht(A0, DHT22);
B. DHT dht(A0, OUTPUT);
C. DHT dht(D4, INPUT);
D. DHT dht(D4, DHT11);

23 A program reads a DHT11 every 100 ms and frequently reports invalid values. Which change is most appropriate?

Programming NodeMCU for DHT11 Medium
A. Decrease the interval to about 10 ms
B. Increase the interval to about 2 seconds
C. Change the data pin to analog mode
D. Call dht.begin() after every reading

24 A NodeMCU must activate a fan when the DHT11 temperature exceeds , but only when the reading is valid. Which condition is appropriate?

Programming NodeMCU for DHT11 Medium
A. if (!isnan(t) || t < 30)
B. if (!isnan(t) && t > 30)
C. if (isnan(t) && t > 30)
D. if (isnan(t) || t == 30)

25 An HC-SR04 reports a round-trip echo time of . Using , what distance should the NodeMCU calculate?

Programming NodeMCU for Ultrasonic sensor Medium
A. Approximately
B. Approximately
C. Approximately
D. Approximately

26 Which pulse sequence should the NodeMCU apply to the HC-SR04 trigger pin to begin a measurement?

Programming NodeMCU for Ultrasonic sensor Medium
A. LOW for 1 second, then HIGH continuously
B. LOW briefly, HIGH for , then LOW
C. HIGH for 1 second, then LOW continuously
D. HIGH briefly, LOW for , then HIGH

27 Why is a voltage divider commonly placed between the HC-SR04 echo pin and an ESP8266 NodeMCU input?

Programming NodeMCU for Ultrasonic sensor Medium
A. To stabilize the ultrasonic frequency
B. To convert echo data into analog data
C. To increase the trigger pulse duration
D. To reduce the 5 V echo level

28 What is the main benefit of adding a timeout to pulseIn(echoPin, HIGH, timeout)?

Programming NodeMCU for Ultrasonic sensor Medium
A. It increases the sensor's maximum range
B. It converts the result directly to centimeters
C. It prevents indefinite waiting for an echo
D. It removes the need for a trigger pulse

29 An LM35 produces per degree Celsius. If its measured output is , what temperature should the NodeMCU report?

programming temperature sensor Medium
A.
B.
C.
D.

30 A temperature sensor connected to A0 produces noticeably fluctuating values. Which software technique can provide a steadier displayed temperature?

programming temperature sensor Medium
A. Alternate A0 between input and output
B. Average several consecutive ADC readings
C. Replace analogRead() with digitalRead()
D. Restart the NodeMCU after each reading

31 A NodeMCU development board has a documented A0 full-scale voltage of . If analogRead(A0) returns 512 on its 10-bit ADC, what input voltage is approximately present?

programming temperature sensor Medium
A.
B.
C.
D.

32 An active-LOW IR obstacle module outputs LOW when an object is detected. Which condition should control an alarm correctly?

programming ir sensor Medium
A. if (analogRead(irPin) == LOW)
B. if (digitalRead(irPin) == LOW)
C. if (digitalWrite(irPin) == LOW)
D. if (digitalRead(irPin) == HIGH)

33 An IR obstacle sensor causes an event counter to increase many times while one object remains in front of it. Which program change best counts each new detection once?

programming ir sensor Medium
A. Configure the sensor pin as an output
B. Reset the counter whenever input is inactive
C. Count only on the inactive-to-active transition
D. Count continuously while the input is active

34 An IR module's indicator LED responds to an object, but the NodeMCU always reads HIGH. What should be checked first?

programming ir sensor Medium
A. Whether the ADC reference is set to 5 V
B. Whether the module and NodeMCU share ground
C. Whether the Wi-Fi connection is disabled
D. Whether the serial baud rate is increased

35 A greenhouse must measure temperatures below and requires better humidity accuracy. Which sensor is generally more suitable?

Compare DHT11 and DHT22 Medium
A. DHT22, because it has a wider range
B. DHT11, because it uses an analog output
C. DHT11, because it samples more slowly
D. DHT22, because it requires no data pin

36 A program is changed from a DHT11 to a DHT22 while keeping the same data pin. Which code change is normally required?

Compare DHT11 and DHT22 Medium
A. Change the GPIO mode to analog input
B. Convert the data pin into a serial port
C. Change the declared sensor type to DHT22
D. Replace the data wire with two data wires

37 Which design trade-off correctly compares the DHT11 and DHT22?

Compare DHT11 and DHT22 Medium
A. DHT11 is more accurate; DHT22 is analog
B. DHT11 reads subzero; DHT22 reads digital only
C. DHT11 has wider range; DHT22 is cheaper
D. DHT11 is cheaper; DHT22 is more accurate

38 An LDR is connected from 3.3 V to A0, and a fixed resistor is connected from A0 to ground. What generally happens to the ADC reading as light intensity increases?

programming LDR sensor Medium
A. It decreases because the LDR resistance decreases
B. It increases because the LDR resistance decreases
C. It remains fixed because A0 is digital
D. It alternates because the LDR produces pulses

39 A streetlight controlled by an LDR rapidly switches on and off near the threshold. Which programming approach best prevents this behavior?

programming LDR sensor Medium
A. Use one threshold with no delay
B. Change A0 to a digital output
C. Use separate ON and OFF thresholds
D. Set the ADC reading to zero

40 An LDR divider gives readings of 180 in darkness and 820 in bright light. Which condition appropriately turns an LED on when the environment becomes dark?

programming LDR sensor Medium
A. if (ldrValue > 700)
B. if (ldrValue == 820)
C. if (ldrValue < 300)
D. if (ldrValue >= 1023)

41 A NodeMCU reads a DHT11 every 100 ms, but many readings become NaN and the output occasionally freezes. Which change best addresses both problems?

Programming NodeMCU for DHT11 Hard
A. Use a 100 ms interval and increase serial speed
B. Use a 50 ms interval and repeat the failed request immediately
C. Use a 2-second interval and validate the returned value
D. Use a 500 ms interval and remove the pull-up resistor

42 A DHT11 data line is connected to a NodeMCU GPIO configured incorrectly as an analog input. The sensor is powered correctly, but readings fail. What is the most appropriate correction?

Programming NodeMCU for DHT11 Hard
A. Configure the GPIO as a PWM output at 50 percent duty cycle
B. Configure the GPIO as a digital output driven permanently high
C. Configure the GPIO as an analog input with averaging
D. Configure the GPIO as a digital bidirectional data pin

43 A DHT11 system reports a humidity value of 0 after a communication failure, and the control program turns on a humidifier. Which design prevents this unsafe response?

Programming NodeMCU for DHT11 Hard
A. Use an explicit validity flag before applying the reading
B. Treat a zero reading as maximum humidity
C. Replace every failed reading with the previous value
D. Convert the value to an integer before comparison

44 An HC-SR04 is connected to a 3.3 V NodeMCU. Which hardware and software combination is safest for the Echo signal?

Programming NodeMCU for Ultrasonic sensor Hard
A. Connect Echo to A0 and calculate distance from ADC counts
B. Use a pull-down resistor and measure the trigger voltage
C. Connect Echo directly and wait without a timeout
D. Use a voltage divider and a bounded pulse-duration measurement

45 An ultrasonic measurement returns a pulse duration of 5800 microseconds. Assuming a sound speed of , what distance should be reported?

Programming NodeMCU for Ultrasonic sensor Hard
A. 49.9 cm
B. 16.7 cm
C. 99.6 cm
D. 198.9 cm

46 A robot uses two ultrasonic sensors mounted close together and triggers them simultaneously. Measurements are inconsistent even when the robot is stationary. What is the best software correction?

Programming NodeMCU for Ultrasonic sensor Hard
A. Increase the Echo voltage to improve sound reflection
B. Trigger sensors sequentially with acoustic settling time
C. Trigger both sensors continuously at a higher frequency
D. Average simultaneous readings without changing timing

47 A distance function occasionally returns an extremely large value when the target is absent. Which implementation detail most directly prevents this result from being interpreted as a real distance?

Programming NodeMCU for Ultrasonic sensor Hard
A. Multiply the duration by the measured supply voltage
B. Convert the unsigned duration to a larger integer type
C. Return an invalid marker when the Echo timeout expires
D. Use a longer trigger pulse for every measurement

48 A temperature sensor is connected to the ESP8266 ADC, whose input range is 0 to 1.0 V, but the sensor can output up to 3.0 V. What is the correct engineering response?

programming temperature sensor Hard
A. Increase the sensor output using a series resistor
B. Read the ADC directly and divide the result by three
C. Add suitable scaling and calibrate the conversion equation
D. Configure the digital pin mode to extend the ADC range

49 For an LM35 connected to a 10-bit ADC with a 1.0 V reference, which equation converts an ADC count to temperature in degrees Celsius, assuming 10 mV per degree Celsius?

programming temperature sensor Hard
A.
B.
C.
D.

50 A temperature control loop switches a heater rapidly when measurements fluctuate by 0.2 degrees Celsius near the setpoint. Which programming strategy best reduces actuator chatter while preserving responsiveness?

programming temperature sensor Hard
A. Apply filtered readings with hysteresis around the setpoint
B. Use the rawest reading and increase loop frequency
C. Round every reading down before comparing it
D. Ignore all readings that differ from the previous one

51 An IR obstacle module has an active-low digital output. The program currently treats HIGH as obstacle detected, causing the actuator logic to invert. What is the correct fix?

programming ir sensor Hard
A. Interpret LOW as detection and document the polarity
B. Enable PWM so the output contains more detection information
C. Use analogRead instead of reading the digital output
D. Invert the sensor supply and keep the software unchanged

52 An IR sensor output rapidly alternates between detected and clear when an object is near its threshold. Which algorithm is most suitable for stable event detection?

programming ir sensor Hard
A. Increase the serial baud rate during each transition
B. Replace digital sampling with a fixed delay of one minute
C. Use the first transition and ignore all later states
D. Use debouncing or consecutive-sample confirmation

53 An IR receiver is used to decode a remote-control protocol, but decoding fails whenever the main loop performs a long blocking delay. Which redesign is most appropriate?

programming ir sensor Hard
A. Poll the receiver only after the frame transmission ends
B. Capture signal timing with interrupts or a nonblocking decoder
C. Increase the delay so complete frames arrive together
D. Read the receiver through the ultrasonic Echo pin

54 A project requires temperature resolution near 0.1 degrees Celsius and humidity measurements below 20 percent relative humidity. Which sensor choice is technically better?

Compare DHT11 and DHT22 Hard
A. DHT11, because its protocol supports faster continuous sampling
B. DHT22, because it offers finer resolution and a wider range
C. DHT22, because it does not require timing restrictions
D. DHT11, because lower resolution improves measurement stability

55 A DHT11 library is used with a DHT22, and the program reports implausible but checksum-valid values. Which cause is most likely?

Compare DHT11 and DHT22 Hard
A. The sensor type parameter uses the wrong data decoding format
B. The NodeMCU ADC reference is too low for the sensor
C. The DHT22 requires an analog rather than digital GPIO
D. The humidity value must be calculated from the supply current

56 A data logger samples both a DHT11 and a DHT22 every 250 ms. Which statement best predicts the resulting behavior?

Compare DHT11 and DHT22 Hard
A. Both may produce failures because their minimum intervals are longer
B. Only the DHT22 will fail because it has lower humidity resolution
C. Only the DHT11 will fail because the DHT22 has no interval limit
D. Both will work if the serial monitor is set above 115200 baud

57 An LDR and a fixed resistor form a divider connected to A0. The LDR is placed between 3.3 V and the ADC input, and its resistance decreases in bright light. What happens to the ADC reading as light increases?

programming LDR sensor Hard
A. The ADC reading becomes negative because the divider reverses polarity
B. The ADC reading decreases because the LDR resistance falls
C. The ADC reading increases because the divider output rises
D. The ADC reading remains fixed because an LDR is digital

58 An LDR threshold works in the laboratory but fails after deployment because the NodeMCU supply voltage varies. Which software or hardware improvement gives the most robust light classification?

programming LDR sensor Hard
A. Replace every ADC value with the maximum possible count
B. Use a longer digital pulse on the LDR output
C. Use a ratio-based threshold or a regulated ADC reference
D. Increase the threshold whenever the light level changes

59 An LDR reading is noisy because the sensor wire runs beside a relay cable. Which combination best improves the measurement without hiding genuine light changes?

programming LDR sensor Hard
A. Increase the ADC input voltage beyond its rated limit
B. Use short shielded wiring, averaging, and a modest low-pass filter
C. Use maximum averaging and a delay of several minutes
D. Change the LDR divider to a digital output pin

60 A NodeMCU LDR application must detect a sudden light interruption while also reporting a stable ambient level. Which architecture best satisfies both requirements?

programming LDR sensor Hard
A. Use only the minimum ADC value collected since startup
B. Maintain a filtered baseline and compare raw samples to it
C. Report only the instantaneous ADC value to both functions
D. Apply a long moving average and discard all raw samples