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. Light and sound
B. Temperature and humidity
C. Motion and speed
D. Distance and pressure

2 Which DHT11 pin sends sensor readings to the NodeMCU?

Programming NodeMCU for DHT11 Easy
A. Ground pin
B. Data pin
C. Reset pin
D. Power 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.readLight()
B. dht.readHumidity()
C. dht.readDistance()
D. dht.readPressure()

5 What does an ultrasonic sensor commonly measure?

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

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. Reset pin
B. Power pin
C. Trigger pin
D. Echo pin

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

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

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

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

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

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

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. Treat it as a digital output state
C. Convert it using the sensor formula
D. Send it directly to the reset pin

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

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

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 a power supply
B. As a serial transmitter
C. As an output
D. As an input

15 Which sensor generally provides better measurement accuracy?

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

16 Which sensor generally supports a wider temperature measurement range?

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

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

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

18 What does an LDR sensor detect?

programming LDR sensor Easy
A. Light intensity
B. Sound intensity
C. Object distance
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 measure relative humidity
B. To produce a measurable voltage
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. Convert the value with String()
B. Set the DHT pin to OUTPUT
C. Multiply the value by 100
D. Check the value with isnan()

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(D4, INPUT);
C. DHT dht(A0, OUTPUT);
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. Call dht.begin() after every reading
B. Change the data pin to analog mode
C. Increase the interval to about 2 seconds
D. Decrease the interval to about 10 ms

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 briefly, LOW for , then HIGH
D. HIGH for 1 second, then LOW continuously

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 convert echo data into analog data
B. To stabilize the ultrasonic frequency
C. To reduce the 5 V echo level
D. To increase the trigger pulse duration

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

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

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. Replace analogRead() with digitalRead()
B. Average several consecutive ADC readings
C. Restart the NodeMCU after each reading
D. Alternate A0 between input and output

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) == HIGH)
C. if (digitalRead(irPin) == LOW)
D. if (digitalWrite(irPin) == LOW)

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. Count only on the inactive-to-active transition
C. Reset the counter whenever input is inactive
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 requires no data pin
B. DHT22, because it has a wider range
C. DHT11, because it samples more slowly
D. DHT11, because it uses an analog output

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 cheaper; DHT22 is more accurate
B. DHT11 reads subzero; DHT22 reads digital only
C. DHT11 has wider range; DHT22 is cheaper
D. DHT11 is more accurate; DHT22 is analog

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 increases because the LDR resistance decreases
B. It decreases 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. Change A0 to a digital output
B. Use one threshold with no delay
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 == 820)
B. if (ldrValue >= 1023)
C. if (ldrValue > 700)
D. if (ldrValue < 300)

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 50 ms interval and repeat the failed request immediately
B. Use a 500 ms interval and remove the pull-up resistor
C. Use a 2-second interval and validate the returned value
D. Use a 100 ms interval and increase serial speed

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 digital output driven permanently high
B. Configure the GPIO as a digital bidirectional data pin
C. Configure the GPIO as a PWM output at 50 percent duty cycle
D. Configure the GPIO as an analog input with averaging

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. Replace every failed reading with the previous value
B. Treat a zero reading as maximum humidity
C. Use an explicit validity flag before applying the reading
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. Use a pull-down resistor and measure the trigger voltage
B. Connect Echo to A0 and calculate distance from ADC counts
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. 16.7 cm
B. 49.9 cm
C. 198.9 cm
D. 99.6 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 both sensors continuously at a higher frequency
C. Average simultaneous readings without changing timing
D. Trigger sensors sequentially with acoustic settling time

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. Convert the unsigned duration to a larger integer type
B. Multiply the duration by the measured supply voltage
C. Use a longer trigger pulse for every measurement
D. Return an invalid marker when the Echo timeout expires

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. Configure the digital pin mode to extend the ADC range
B. Add suitable scaling and calibrate the conversion equation
C. Read the ADC directly and divide the result by three
D. Increase the sensor output using a series resistor

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. Use the rawest reading and increase loop frequency
B. Ignore all readings that differ from the previous one
C. Apply filtered readings with hysteresis around the setpoint
D. Round every reading down before comparing it

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. Enable PWM so the output contains more detection information
B. Use analogRead instead of reading the digital output
C. Invert the sensor supply and keep the software unchanged
D. Interpret LOW as detection and document the polarity

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. Use debouncing or consecutive-sample confirmation
B. Increase the serial baud rate during each transition
C. Replace digital sampling with a fixed delay of one minute
D. Use the first transition and ignore all later states

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. Capture signal timing with interrupts or a nonblocking decoder
B. Poll the receiver only after the frame transmission ends
C. Read the receiver through the ultrasonic Echo pin
D. Increase the delay so complete frames arrive together

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. DHT22, because it does not require timing restrictions
B. DHT11, because its protocol supports faster continuous sampling
C. DHT11, because lower resolution improves measurement stability
D. DHT22, because it offers finer resolution and a wider range

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. Only the DHT22 will fail because it has lower humidity resolution
B. Only the DHT11 will fail because the DHT22 has no interval limit
C. Both will work if the serial monitor is set above 115200 baud
D. Both may produce failures because their minimum intervals are longer

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 remains fixed because an LDR is digital
B. The ADC reading increases because the divider output rises
C. The ADC reading becomes negative because the divider reverses polarity
D. The ADC reading decreases because the LDR resistance falls

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. Increase the threshold whenever the light level changes
B. Replace every ADC value with the maximum possible count
C. Use a longer digital pulse on the LDR output
D. Use a ratio-based threshold or a regulated ADC reference

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. Change the LDR divider to a digital output pin
D. Use maximum averaging and a delay of several minutes

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. Maintain a filtered baseline and compare raw samples to it
B. Use only the minimum ADC value collected since startup
C. Apply a long moving average and discard all raw samples
D. Report only the instantaneous ADC value to both functions