WorksheetsESP32 MicroPython Quiz
Total questions: 12
Worksheet time: 6mins
What will happen if we write sensor.temperature() before calling sensor.measure()?
It will give the last stored value
It will crash the code
It will read the new temperature
It will return random values
Why do we use Pin(5, Pin.OUT) in the LED project?
To declare a variable
To set GPIO 5 as a data pin
To configure GPIO 5 to control a device like an LED
To read data from a sensor
In the line from (time import sleep), what does sleep actually do?
Puts the ESP32 to deep sleep mode
Pauses the program for a short time
Makes the ESP32 restart
Turns off GPIO pins
What is the main reason for using (while True:) in MicroPython code on ESP32?
To check if a sensor is connected
To run the code only once
To create a loop that repeats the task continuously
To save battery power
What is the primary role of try...except in the DHT11 code block?
To shorten the program
To retry a command
To handle errors gracefully and prevent the program from crashing
To measure temperature automatically
Why is a 2-second delay used after reading DHT11 sensor values?
The sensor sends data slowly
To allow the sensor to cool down
To match the LED blink pattern
To give the sensor time to stabilize before next reading
What is the difference between Pin.OUT and Pin.IN in the Pin() class?
Pin.OUT is used for sensors, Pin.IN for motors
Pin.OUT sends signals out, Pin.IN receives signals in
Both are the same
Pin.OUT works with LEDs only
What does the following code do? led = Pin(5, Pin.OUT) led.on() sleep(1) led.off()
Turns LED on and off quickly
Turns LED on for 1 second, then off
Turns LED off immediately
Causes an error due to missing loop
Why is it wrong to write sensor = dht.DHT11(4) without wrapping 4 in Pin()?
It saves memory
DHT11 sensors don’t use digital pins
The constructor requires a Pin object, not an integer
It makes the code shorter
What output will you see if you remove the sleep() calls in a blinking LED program?
LED will blink more slowly
LED will stay ON permanently
LED will blink too fast to see properly
The ESP32 will shut down
You are using both an LED and a sensor on the ESP32. How do you prevent them from interfering with each other?
Connect both to the same pin
Use different GPIO pins and control each one separately in code
Add a battery to the sensor
Turn one off when the other is on
What happens if the ESP32 is not flashed with MicroPython before uploading code?
The code runs faster
The code is ignored — nothing runs
Thonny automatically converts it to C
The LED blinks by default
