Skip to main content

Arduino Nano and DHT11 Electronics Workshop

By Fix It Today, 03/09/2026 · 32 min read

A step-by-step Arduino Nano and DHT11 workshop guide: install the IDE, wire the I/O expansion shield, and work through seven steps with copy-and-paste sketches, the Serial Plotter, and a hand-warmth threshold you calibrate yourself.
Arduino Nano and DHT11 Electronics Workshop

Electronics workshop

Arduino Nano and DHT11 workshop

Install Arduino IDE, connect the DHT11, then work through six sketches and a threshold-setting exercise. Read temperature and humidity, plot changes, and use the built-in LED as an indicator.

Start here

What an Arduino is

A small computer that runs one program, from the moment it gets power until you unplug it.

One chip, doing one jobAn Arduino is a microcontroller on a convenient board. The chip is an ATmega328P: a processor, 32 KB of program memory and 2 KB of RAM in one package, with its pins brought straight out to the edge of the board. No operating system, no files, no screen. It runs the one program you gave it, from reset, for as long as it has power.
A sketch is that programYou write it in the Arduino IDE on your laptop and press Upload, and it travels down the USB cable into the chip's flash memory. The sketch remains stored when USB is disconnected. To run without the laptop, the board still needs a suitable power supply. Every sketch has the same two parts: setup(), which runs once at power-up, and loop(), which runs over and over.
Inputs and outputsDigital pins read or write HIGH or LOW. Analog pins read a voltage as a number from 0 to 1023. Six of the digital pins can do PWM, a fast on-off pattern that dims an LED or sets a motor speed. Two pins, D0 and D1, carry the USB serial link you use to see what the board is doing.
Why the Nano, and why a shieldThe Nano is the small Arduino: the same chip as the classic board, a fraction of the size, USB-C on this batch. Its pins are bare header pins, so the kit adds an expansion shield that turns every pin into a three-pin socket a sensor module plugs straight into.

The board

The Arduino Nano

The board in the kit. Small enough to sit in a breadboard, and it plugs straight into the expansion shield.

Real supplier photos of black and blue PCB USB-C ATmega328P/CH340 Nano-compatible boards. Board layout may vary; use the labels on your board. Pin headers are shown unsoldered.

The board: a USB-C Nano

These supplier photos show black and blue USB-C Nano-compatible board variants. Use the labels and documentation for your supplied board to identify its components and reset button.

Nano pin labels

Read the pin labels printed on your supplied board, and verify its pinout against the documentation for that board before wiring. Board layouts vary; do not infer pin positions from a photograph.

Setup

Connecting the Arduino IDE to the Arduino board

Install the software, then plug in the board and pick the right settings.

Step 1: Install Arduino IDE 2
Arduino IDE 2 interface. Karl Soderby and Jacob Hylen, CC BY-SA 3.0.
Step 1

Install Arduino IDE 2

This guide is written for Arduino IDE 2. Install it before you plug the board in.

  1. On Windows, download the 64-bit installer from arduino.cc and run the EXE. On macOS, pick Intel or Apple silicon to match the Mac, open the DMG and drag Arduino IDE into Applications.
  2. The longer walkthrough, with the download page and the driver step, is on the Install Arduino IDE guide.
  3. Open the IDE once before you plug anything in, so the first launch and any firewall prompt are out of the way.
Step 2: Plug the board in and find its port
Arduino IDE 2.3.8 on Windows, screenshot from the workshop laptop.
Step 2

Plug the board in and find its port

The selector beside the Upload button lists the ports the IDE can see. A CH340-based Nano may appear as Unknown, which is normal: pick Select other board and port and choose the Nano yourself in the next step.

  1. Connect the Nano with a USB-C data cable. On Windows a new COM port appears; on macOS it shows up as a dev.usbserial or dev.wchusbserial device.
  2. If the list stays empty, change the cable before you change anything else. That's the most common cause, and the cheapest to rule out.
  3. If the port is missing, identify the USB bridge on your board and install its manufacturer's driver if needed. Some Windows installations already have the required driver.
Step 3: Set Board, Processor and Port
Arduino IDE 2.3.8 on Windows, screenshot from the workshop laptop.
Step 3

Set Board, Processor and Port

Select other board and port opens this dialog. Type nano, tick Arduino Nano, tick the Nano's port and press OK. The board selector then reads Arduino Nano.

  1. In the dialog: type nano in the Boards box, tick Arduino Nano, tick the port that appeared when you plugged the board in, then OK. On Windows the Nano's port is usually marked (USB). Tools > Board > Arduino AVR Boards > Arduino Nano and Tools > Port do the same job.
  2. Tools > Processor > ATmega328P. Use ATmega328P (Old Bootloader) if the board supplier specifies it, or try that option when the cable and port are correct but uploading fails. USB-C and CH340 do not identify which bootloader is installed.
  3. Do not upload anything yet. Fit the Nano to the shield first, in the next section; Blink, sketch 1, is the first upload.
Tools > Processor
Arduino IDE 2.3.8 on Windows, screenshot from the workshop laptop.

Tools > Processor

Processor appears in the Tools menu once Arduino Nano is the selected board. Pick ATmega328P. If uploading fails with a stk500 error while the cable and port are right, pick ATmega328P (Old Bootloader) and upload again.

Upload problems, in the order to check them

The stk500_recv() error means the upload tool did not receive the expected response. Check the selected board, processor and port, then the data cable and anything connected to D0 or D1.
No port in the Tools menu at all is a cable or driver problem. A board can light up on a charge-only cable and still be invisible to the IDE.
Test one board from the workshop batch first and note its working processor setting. Use that setting for matching boards, rather than assuming every USB-C Nano has the same bootloader.

The shield

The I/O expansion shield

The Nano seats into the shield, and every pin comes out again as a three-pin header: ground, voltage, signal. Electrically a header pin is the Nano pin. There is nothing in between, and no protection either.

Power off first

Unplug the USB cable before you seat the Nano on the shield.

Seated one hole out or the wrong way round, the Nano puts 5 V and GND on the wrong pins the moment the cable goes in. Seat it with the cable out, check both rows, then plug it back in.

Fit the Nano to the shield
The Nano I/O expansion shield supplied in the kit, photographed from above for the Voltaat product listing. Column positions measured from the photo; labels added by Fix It Today.

Fit the Nano to the shield

Fifteen pins into each of the two black rows, USB-C at the same end as the DC jack. Seated correctly, the column printed 4 is the Nano pin D4. The four checks under the picture are the ones worth doing before the cable goes in.

Seated: what it should look like

Both rows fully home, board flat, USB-C over the DC-jack end. The shield's yellow columns stay clear on all four sides of the Nano.

The shield from above: where D4 actually is
The Nano I/O expansion shield supplied in the kit, photographed from above for the Voltaat product listing. Column positions measured from the photo; labels added by Fix It Today.

The shield from above: where D4 actually is

Digital columns along the top, numbered 13 down to 0; analog columns A0 to A7 along the bottom. Every column is three pins and on this board they read G, V, S from the top: minus lead to G, plus to V, signal to S. Find the digital column printed 4.

Putting the Nano on the shield

Disconnect power. Align all 30 pins with the socket openings. Check both ends of each row before pressing the board into place.
USB-C socket towards the end of the shield printed for it. Seated backwards, 5 V and GND land on the wrong pins the moment you plug in.
Press on the body of the Nano, evenly, never on the USB socket. It should sit flat with no gap under either header.
Upload Blink to check power and USB communication. Blink does not test every shield connection; check the pin alignment separately.

Sketch 1

Blink, on the shield

The Nano has an LED on D13 already. Upload this with the Nano seated on the shield: if it flashes, the board, the seating, the cable, the driver and the IDE settings are all working.

01_blink.inoArduino C++
1// Nothing wired yet. This proves the IDE can reach the board.
2const uint8_t LED = 13; // the LED already soldered to the Nano
3
4void setup() {
5 pinMode(LED, OUTPUT);
6}
7
8void loop() {
9 digitalWrite(LED, HIGH);
10 delay(120); // <-- change this number and re-upload
11 digitalWrite(LED, LOW);
12 delay(880);
13}

Upload it, then change 120 to 500 and upload again. If the rate changes, the board, the cable, the driver and the IDE settings are all fine.

Upload it: the arrow button
Arduino IDE 2.3.8 on Windows, screenshot from the workshop laptop.

Upload it: the arrow button

Paste the sketch over everything in the editor, then press Upload, the arrow next to the tick. The Output panel reports the sketch size, then Done uploading appears at the bottom right. The tick, Verify, only compiles: useful for checking code with no board plugged in.

What to look for: the L LED

Find the built-in LED on your supplied board, usually labelled L or L13. Blink switches it once a second, so a steady flash means the upload worked.

Line by line

How the Blink sketch works

The sketch sets the LED pin as an output, then switches it on and off.

const uint8_t LED = 13;Give pin 13 a name. uint8_t is a small whole number and const means it never changes. Naming the pin once at the top means the rest of the sketch reads as words, and moving the LED later is a one-line edit.
void setup() and pinMode(LED, OUTPUT);setup() runs once, when the board powers up or resets. The one thing it does here is tell the chip that pin 13 will drive something rather than listen to something. Every pin starts as an input until you say otherwise.
void loop()Everything inside loop() repeats for as long as the board has power. There is no end to reach: the last line runs and the first line starts again.
digitalWrite(LED, HIGH); delay(120);Put 5 V on the pin, which lights the LED, then wait 120 milliseconds doing nothing at all. delay() stops the whole sketch for that long. Fine here, a problem later, when the sketch has to keep watching a sensor.
digitalWrite(LED, LOW); delay(880);Pin to 0 V, LED off, wait 880 ms. 120 plus 880 is one second, so the LED gives one short flash a second. Change 120 to 500 and re-upload: a longer flash is your proof that your edit reached the chip.

The two reset buttons

Locate the reset buttons using the labels and documentation for your supplied Nano and shield. Either restarts the sketch from setup(). Nothing is erased.

The reset button

The small button beside the ICSP header. Pressing it restarts the sketch from setup(). It does not erase anything; the sketch in flash stays exactly as it was.
Opening the Serial Monitor or the Serial Plotter resets the board too, through the USB bridge. That is why the first lines print again every time you open the monitor, and why sketch 4 measures its baseline afresh.
If an upload times out on a board that was working a minute ago, press reset just as 'Uploading...' appears. The full story is on the wiring guide.

Wiring

One module, three pins

The KY-015 carries the DHT11 on a 3-pin header. Signal to D4, + to 5 V, - to GND. On the shield that is one lead into the header column marked 4 in the digital bank.

Power off first

Unplug the USB cable before you plug in the DHT11.

A lead plugged in live can touch the wrong pin for a moment, and 5 V on a signal pin is how a module dies. Unplug, wire, check the letters, then plug the cable back in.

Exactly where the DHT11 goes
The Nano I/O expansion shield supplied in the kit, photographed from above for the Voltaat product listing. Column positions measured from the photo; labels added by Fix It Today.

Exactly where the DHT11 goes

Signal to the column printed 4 in the digital bank. The module takes its power and ground from the V and G rows of that same column, so it is one lead, not three.

The KY-015 module, and which lead is which
KY-015 DHT11 module, Joy-IT product photo.

The KY-015 module, and which lead is which

For the pictured KY-015 module, connect S to Nano D4, the middle pin (+) to 5V and minus to GND. On the kit shield that is S, V and G in the column printed 4. Check your module's labels: three-pin modules do not all use the same pin order. Leave the shield's DC jack unplugged; USB powers everything in this exercise.

Match the letters before you power it
KY-015 photo: Joy-IT. Shield photo: Voltaat, the kit shield. Labels added by Fix It Today.

Match the letters before you power it

The module marks its outer pins S and minus, with + in the middle. The shield marks its rows G, V and S. S goes to S, + to V and minus to G, all in the column printed 4.

Before you power it

Minus lead to G, plus to V, signal to S. Connect ground first.
Look at the letters printed at the ends of the rows on your own shield before you plug in a whole class. G-V-S is what this batch has; other shields are printed S-V-G.
A reversed connection can damage the module. Disconnect power and match the signal, supply and ground labels before reconnecting.
Install the DHT11 library, next, before sketch 2. The sketches will not compile without it.

The library

Add the DHT11 library

The DHT11 speaks its own single-wire protocol, so it needs a library. Install DHT11 by Dhruba Saha, 2.1.0, and nothing else.

The card to look for
Install DHT11 by Dhruba Saha, version 2.1.0.

The card to look for

Sketch > Include Library > Manage Libraries, search DHT11, and this is the one: DHT11 by Dhruba Saha, version 2.1.0. Not the Adafruit library of a similar name, which has a different API.

Where the four examples live
Open File > Examples > DHT11 > ReadTempAndHumidity.

Where the four examples live

Once it is installed, File > Examples > DHT11 lists ReadHumidity, ReadPlot, ReadTempAndHumidity and ReadTemperature. Start with ReadTempAndHumidity; sketch 3 below is ReadPlot with the pin changed.

Installing it

Sketch > Include Library > Manage Libraries, search DHT11, and install DHT11 by Dhruba Saha, version 2.1.0. The card should read 2.1.0 installed when it is done. Every sketch below is written for that library.
There is no second dependency to accept. If the Library Manager offers DHT sensor library by Adafruit instead, that is a different library with a different API, and these sketches will not compile against it.
After installing the library, copy the D4 example below into a new sketch. The library also includes ReadTemperature, ReadHumidity and ReadPlot under File > Examples > DHT11.

The library's own example

File > Examples > DHT11 > ReadTempAndHumidity

Copy this sketch into Arduino IDE and upload it. The sensor pin is already set to D4 to match the wiring in this guide. Open Serial Monitor and select 9600 baud.

ReadTempAndHumidity.inoArduino C++
1/**
2 * DHT11 Sensor Reader
3 * This sketch reads temperature and humidity data from the DHT11 sensor and
4 * prints the values to the serial port. It also handles potential error states
5 * that might occur during reading.
6 *
7 * Author: Dhruba Saha
8 * Version: 2.1.0
9 * License: MIT
10 */
11
12// Include the DHT11 library for interfacing with the sensor.
13#include <DHT11.h>
14
15// Create an instance of the DHT11 class.
16// Connect the DHT11 signal lead to shield S on digital column 4 (Nano D4).
17DHT11 dht11(4);
18
19void setup() {
20 // Initialize serial communication to allow debugging and data readout.
21 // Using a baud rate of 9600 bps.
22 Serial.begin(9600);
23
24 // Uncomment the line below to set a custom delay between sensor readings.
25 // dht11.setDelay(500); // Set this to the desired delay. Default is 500ms.
26}
27
28void loop() {
29 int temperature = 0;
30 int humidity = 0;
31
32 // Attempt to read the temperature and humidity values from the DHT11 sensor.
33 int result = dht11.readTemperatureHumidity(temperature, humidity);
34
35 // Check the results of the readings.
36 // If the reading is successful, print the temperature and humidity values.
37 // If there are errors, print the appropriate error messages.
38 if (result == 0) {
39 Serial.print("Temperature: ");
40 Serial.print(temperature);
41 Serial.print(" C\tHumidity: ");
42 Serial.print(humidity);
43 Serial.println(" %");
44 } else {
45 // Print error message based on the error code.
46 Serial.println(DHT11::getErrorString(result));
47 }
48}

Reproduced from the DHT11 library by Dhruba Saha, MIT licence. Reading it is the fastest way to see the shape of every sketch below: construct DHT11 with a pin, call readTemperatureHumidity with two ints by reference, and check the return value, where 0 means the read worked.

The sketches

Seven steps, in order

Blink was step 1. Each of the rest is a complete sketch: open a new sketch, select all, paste over it, upload.

1BlinkThe on-board LED on D13. Nothing wired, so it only tests the toolchain.
2First readingTemperature and humidity printed once every two seconds.
3Serial PlotterThe same readings drawn as a live graph instead of a list.
4Hand warmthMeasure the room, then light D13 when your hand raises the reading.
5CalibrationA procedure, not a sketch: set the threshold from what your own hand does.
6Steady outputTwo thresholds keep the LED steady when the reading is near the switching point.
7Temperature against humidityPlot both as change from the start and see which moves first.

Sketch 2

The first reading

Upload, then open Tools > Serial Monitor and set it to 9600 baud.

02_first_reading.inoArduino C++
1#include <DHT11.h>
2
3DHT11 dht11(4); // KY-015 signal -> D4
4
5void setup() {
6 Serial.begin(9600);
7 dht11.setDelay(2000); // datasheet: no faster than once every 2 s
8 Serial.println("temp_C, humidity_pct");
9}
10
11void loop() {
12 int temperature = 0;
13 int humidity = 0;
14
15 // 0 means the read worked. 253 is a timeout, 254 a bad checksum.
16 int result = dht11.readTemperatureHumidity(temperature, humidity);
17
18 if (result == 0) {
19 Serial.print(temperature);
20 Serial.print(", ");
21 Serial.println(humidity);
22 } else {
23 Serial.println(DHT11::getErrorString(result));
24 }
25} // no delay() here: the library waits for you

This is the library's own ReadTempAndHumidity example with the pin changed to 4, the datasheet delay set, and the printing trimmed to two columns. Two numbers every two seconds. readTemperatureHumidity() returns 0 when the read worked and 253 or 254 when it did not, so there is no NaN to test for. Breathe on the sensor and the humidity climbs within a few seconds; the temperature takes longer.

What sketch 2 prints
Arduino IDE 2.3.8 on the workshop laptop, showing this sketch's output format with example readings. Your numbers depend on the room.

What sketch 2 prints

The column names once, then one line every two seconds: temperature in degrees C, then humidity in percent. Breathe on the sensor and the humidity jumps within a few seconds while the temperature barely moves. A failed read prints an error message instead of the two numbers; the troubleshooting table at the bottom covers them.

Sketch 3

The Serial Plotter

The same readings, drawn instead of listed. Tools > Serial Plotter, same 9600 baud. The Serial Monitor can stay open: IDE 2 runs both at once.

Opening the plotter
Arduino IDE 2.3.8 on Windows, screenshot from the workshop laptop.

Opening the plotter

The wavy-line icon at the top right of the IDE window, next to the Serial Monitor icon, or Tools > Serial Plotter. Set 9600 baud at the bottom of the plotter window once it opens.

What sketch 3 draws
Arduino IDE 2.3.8 on the workshop laptop, showing this sketch's output format with example readings. Your numbers depend on the room.

What sketch 3 draws

One line per label the sketch prints: temp_C and humidity. A breath makes the humidity line jump; a hand held over the sensor lifts the temperature line a couple of degrees. Untick a label at the top to hide its line.

03_plotter.inoArduino C++
1#include <DHT11.h>
2
3DHT11 dht11(4);
4
5void setup() {
6 Serial.begin(9600);
7 dht11.setDelay(2000);
8}
9
10void loop() {
11 int temperature = 0;
12 int humidity = 0;
13 if (dht11.readTemperatureHumidity(temperature, humidity) != 0) return;
14
15 // "label:value" pairs. The plotter uses the labels as its legend.
16 Serial.print("temp_C:");
17 Serial.print(temperature);
18 Serial.print(",humidity:");
19 Serial.println(humidity);
20}

IDE 2 reads label:value pairs and builds a legend from the labels. Print anything else on the same line and the trace breaks, which is why a failed read returns early rather than printing an error. The library ships this as File > Examples > DHT11 > ReadPlot.

What to do with the plot open

Breathe across the sensor from about 10 cm. Humidity moves first and moves further. That's the water in your breath.
Cup a hand over the module without touching it and hold it there. Temperature climbs about 1 to 3 degrees over 20 to 30 seconds.
Take your hand away and time how long it takes to come back down. The plastic housing holds heat, so the fall is slower than the rise.
The trace moves in whole steps. The library returns ints because the DHT11 reports 1 degree C and 1 percent RH, so that is the sensor's own resolution showing.

Sketch 4

Hand warmth on the D13 LED

Measure the room for 20 seconds, store that as a baseline, then light the on-board LED whenever your hand pushes the reading above it. Still no extra wiring.

04_hand_warmth.inoArduino C++
1#include <DHT11.h>
2
3const uint8_t LED = 13; // the on-board LED. No extra wiring.
4const uint8_t SAMPLES = 10; // 10 readings x 2 s = 20 s of baseline
5const float RISE_C = 1.0; // <-- YOUR calibration goes here
6
7DHT11 dht11(4);
8float baseline = 0;
9
10bool bad(int v) { // one place to test both error codes
11 return v == DHT11::ERROR_TIMEOUT || v == DHT11::ERROR_CHECKSUM;
12}
13
14void setup() {
15 pinMode(LED, OUTPUT);
16 Serial.begin(9600);
17 dht11.setDelay(2000);
18
19 Serial.println("Hands off. Measuring the room.");
20 long total = 0;
21 uint8_t taken = 0;
22 while (taken < SAMPLES) {
23 int t = dht11.readTemperature();
24 if (!bad(t)) { total += t; taken++; Serial.print('.'); }
25 }
26 baseline = total / (float) SAMPLES; // ten whole readings, one fraction
27
28 Serial.println();
29 Serial.print("Room baseline ");
30 Serial.print(baseline, 1);
31 Serial.println(" C. Now cup a hand over the sensor.");
32}
33
34void loop() {
35 int t = dht11.readTemperature();
36 if (bad(t)) return;
37
38 float rise = t - baseline;
39 bool warm = rise >= RISE_C;
40 digitalWrite(LED, warm ? HIGH : LOW);
41
42 Serial.print("baseline:"); Serial.print(baseline, 1);
43 Serial.print(",now:"); Serial.print(t);
44 Serial.print(",rise:"); Serial.print(rise, 1);
45 Serial.print(",led:"); Serial.println(warm ? 1 : 0);
46}

readTemperature() hands back a whole number, so averaging ten of them is what gives the baseline a decimal place to work with. RISE_C starts at 1.0, which is a guess; step 5 replaces it with a number you measured.

Where your hand goes
ChatGPT rendering of the hand position, made from the KY-015 manufacturer photo.

Where your hand goes

Cup your hand over the module with the palm 1 to 2 cm above the blue sensor, and keep it still. Do not touch the sensor.

What sketch 4 prints
Arduino IDE 2.3.8 on the workshop laptop, showing this sketch's output format with example readings. Your numbers depend on the room.

What sketch 4 prints

Keep your hands away while the dots print: that is the 20-second baseline. Then one line every two seconds. When rise reaches RISE_C, led changes to 1 and the L LED on the Nano lights.

Step 5

Calibrating the threshold to your own hand

The right threshold depends on the room, the sensor, and how close you hold your hand, so measure it.

Step 5.1: Upload sketch 4, then hands off
Arduino IDE 2.3.8 on the workshop laptop, showing this sketch's output format with example readings. Your numbers depend on the room.
Step 5.1

Upload sketch 4, then hands off

Upload sketch 4 and keep your hands away from the bench. Wait for the baseline line to print, about 20 seconds.

  1. Open the Serial Monitor at 9600 baud and click the clock icon, so every line shows the time it arrived. Steps 5.4 and 5.6 use those times.
Step 5.2: Cup a hand over the sensor
ChatGPT rendering of the hand position, side view, made from the KY-015 manufacturer photo.
Step 5.2

Cup a hand over the sensor

Cup a hand over the sensor, 1 to 2 cm above it, without touching it. Hold still and watch the rise value in the Serial Monitor.

  1. The DHT11 reads whole degrees, so rise climbs in steps of 1.0. Give it 20 to 30 seconds.
Step 5.3: Note your highest rise
Arduino IDE 2.3.8 on the workshop laptop, showing this sketch's output format with example readings. Your numbers depend on the room.
Step 5.3

Note your highest rise

Note the highest rise you can hold for ten seconds. In a normal room that's usually 1 to 3 degrees C.

  1. Tools > Serial Plotter draws the same numbers. Untick baseline, now and led so only rise is left. At one reading every 2 seconds, ten seconds is five points.
Step 5.4: Take your hand away and time the fall
Arduino IDE 2.3.8 on the workshop laptop, showing this sketch's output format with example readings. Your numbers depend on the room.
Step 5.4

Take your hand away and time the fall

Take your hand away and watch rise fall back towards zero. Note how long that takes; 30 to 60 seconds is normal.

  1. Take the time on the first 0.0 and subtract the time on the last reading before your hand left.
Step 5.5: Set RISE_C to half of it
Arduino IDE 2.3.8 on Windows, screenshot from the workshop laptop.
Step 5.5

Set RISE_C to half of it

Set RISE_C to about half your highest rise. If you held 3.0, use 1.5.

  1. It's line 5 of sketch 4, the one marked YOUR calibration goes here.
Step 5.6

Upload again and test it

Re-upload and check it: the LED should come on within about 10 seconds of your hand arriving, and go off within a minute of it leaving.

  1. The led value in the Serial Monitor and the L LED on the board change together.

If the calibration won't hold

The LED never comes on: your RISE_C is above what your hand can do. Lower it, or hold your hand closer.
The LED is on before you start: the baseline was measured with a hand or a laptop vent near the sensor. Reset the board and stand back.
The LED flickers on and off around the threshold: that's a single-threshold problem, and sketch 6 fixes it.
Everything reads whole numbers: correct. The DHT11 has 1 degree C resolution, so a rise of 1.0 is one whole step.

Sketch 6

Keep the LED steady with two thresholds

Switch on when the temperature rise reaches 1.5 degrees C and switch off below 0.5 degrees C. Between those values, keep the previous LED state. This is hysteresis. The sketch below still waits inside the DHT11 read; it does not use a millis-based scheduler.

06_steady.inoArduino C++
1#include <DHT11.h>
2
3const uint8_t LED = 13;
4const float ON_RISE = 1.5; // switch on above this
5const float OFF_RISE = 0.5; // switch off below this
6const uint8_t SAMPLES = 10;
7
8DHT11 dht11(4);
9float baseline = 0;
10bool warm = false;
11
12bool bad(int v) {
13 return v == DHT11::ERROR_TIMEOUT || v == DHT11::ERROR_CHECKSUM;
14}
15
16void setup() {
17 pinMode(LED, OUTPUT);
18 Serial.begin(9600);
19 dht11.setDelay(2000);
20
21 long total = 0;
22 uint8_t taken = 0;
23 while (taken < SAMPLES) {
24 int t = dht11.readTemperature();
25 if (!bad(t)) { total += t; taken++; }
26 }
27 baseline = total / (float) SAMPLES;
28 Serial.print("baseline "); Serial.println(baseline, 1);
29}
30
31void loop() {
32 int t = dht11.readTemperature();
33 if (bad(t)) return;
34
35 float rise = t - baseline;
36
37 if (!warm && rise >= ON_RISE) warm = true; // two thresholds,
38 if ( warm && rise < OFF_RISE) warm = false; // not one
39
40 digitalWrite(LED, warm ? HIGH : LOW);
41
42 Serial.print("rise:"); Serial.print(rise, 1);
43 Serial.print(",led:"); Serial.println(warm ? 1 : 0);
44}

Switching on at 1.5 and off at 0.5 leaves a 1 degree gap. Widen it if the LED still flickers, narrow it if the LED stays on too long after your hand leaves. Note that the read itself blocks for the whole setDelay period, so nothing else in loop() runs during it.

What sketch 6 prints
Arduino IDE 2.3.8 on the workshop laptop, showing this sketch's output format with example readings. Your numbers depend on the room.

What sketch 6 prints

rise and led every two seconds. The LED switches on at 1.5 and only switches off below 0.5, so a reading that wobbles between 1.0 and 2.0 leaves it steadily on.

Sketch 7

Temperature against humidity

Both plotted as change from the first reading, so they share one scale and you can see which one reacts first.

07_temp_vs_humidity.inoArduino C++
1#include <DHT11.h>
2
3DHT11 dht11(4);
4int t0 = -1, rh0 = -1; // the first good reading, as a reference
5
6void setup() {
7 Serial.begin(9600);
8 dht11.setDelay(2000);
9}
10
11void loop() {
12 int temperature = 0;
13 int humidity = 0;
14 if (dht11.readTemperatureHumidity(temperature, humidity) != 0) return;
15
16 if (t0 < 0) { t0 = temperature; rh0 = humidity; } // first pass only
17
18 // Both plotted as change from the start, so they share one scale.
19 Serial.print("temp_delta:");
20 Serial.print(temperature - t0);
21 Serial.print(",humidity_delta:");
22 Serial.println(humidity - rh0);
23}

Breathe on it and humidity jumps well ahead of temperature. Cup your hand over it instead and temperature leads. The two signals have different sources and different lag.

What sketch 7 draws
Arduino IDE 2.3.8 on the workshop laptop, showing this sketch's output format with example readings. Your numbers depend on the room.

What sketch 7 draws

Both lines start at zero. A breath sends humidity_delta up by about 20 within seconds while temp_delta moves by 1. A hand held over the sensor moves temp_delta first.

Next

Things to change

Small edits to the sketches above. Each takes a couple of minutes.

Change the sample intervalCompare dht11.setDelay(2000) with dht11.setDelay(5000). The slower setting gives fewer samples; keep at least two seconds between reads for this exercise.
Average the readingKeep the last five values in an array and print the mean. The trace gets smoother, and the fixed error stays exactly where it was.
Add a second thresholdLight D13 for a small rise and add a buzzer on D5 for a large one.
Log itPrint millis() as the first column, run for ten minutes, then paste the Serial Monitor into a spreadsheet and plot it there.
Cover the sensorPut the module in a cup and watch how long the humidity takes to settle. It runs to minutes.
Swap the sensorUse the analog temperature module's own wiring and example sketch, then compare its response with the DHT11. The DHT11 library does not read an analog module.

Faults

Troubleshooting

Work down this table before changing the sketch. Most of these are a cable, the wiring, or one menu setting.

SymptomPossible causeFix
No COM port in the Tools menuCharge-only cable, or no CH340 driverSwap the cable first. Then install the driver and replug the board.
avrdude: stk500_recv() not respondingWrong Processor settingSwitch Tools > Processor between ATmega328P (Old Bootloader) and ATmega328P, then upload again.
Every read prints a timeout errorModule in backwards, unpowered, or on the wrong pinMinus to G, + to V, S to S: read the letters, not the wire colours. Then check DHT11 dht11(4) matches the column it is plugged into.
The board resets when the buzzer soundsBrown-out from switch-on currentNot a software bug. Power the buzzer separately, or drop it.
Readings barely moveSampled faster than the sensor updatesdht11.setDelay(2000), which is the datasheet limit.
An LED is permanently on and the module is warmModule plugged in backwardsUnplug it now, then check the orientation before repowering.
Serial output is garbage charactersBaud rate mismatch, or something wired to D0 or D1Match the Serial Monitor to Serial.begin(9600), and keep D0 and D1 free.
pinMode(A6, OUTPUT) does nothingA6 and A7 have no digital hardware behind themUse A0 to A5 if you need a pin that can do both.
'DHT' does not name a typeThe Adafruit library is installed, not this oneInstall DHT11 by Dhruba Saha and use DHT11 dht11(4).

The rest of the kit

Explore the sensor kit

Every module in the 37-in-1 kit has its own page, with what it detects, how the sensing works and a starter sketch.

Sources

Documentation used on this page

Photo credits

The shield and KY-015 pictures are the supplier and manufacturer photos of the hardware in the kit; the Nano and hand pictures are renderings made from those photos, and the Arduino IDE screenshots were taken on the workshop laptop. The other photographs are Creative Commons images from Wikimedia Commons, reused under their own licences. Diagrams in the orange-and-teal house style are our own workshop figures. The module photos are from the Joy-IT SensorKit documentation and the pinout sheet from Arduino.

USB-C Nano board photoKit supplier product photo, labels by Fix It Today, the board supplied in the kit
Nano I/O expansion shield, top viewVoltaat, supplier product photo of the kit shieldSource file
KY-015 DHT11 module photoJoy-IT, manufacturer product photoSource file
Arduino IDE 2 interfaceKarl Soderby and Jacob Hylen, CC BY-SA 3.0Source file
Arduino IDE 2.3.8 screenshotsFix It Today, taken on the workshop laptop; the Serial Monitor and Plotter readings are examples
Hand position and Nano-on-shield picturesChatGPT renderings, made from the supplier photos of the kit hardware, checked against the real boards

Survey and feedback

Help improve MakerAccess

Have an idea for what MakerAccess should stock, improve, or explain next? Share it in the survey. If you bought or used a product and want to comment on the item itself, use the product feedback form.

Do the surveyProduct feedback form