Introduction: Arduino OLED Thermometer and Hygrometer With DHT11 for Beginners

Picture of Arduino OLED Thermometer and Hygrometer With DHT11 for Beginners

Hello ! I'm going to show you how to make an Arduino OLED thermometer and hygrometer* with DHT11.

The OLED we will use today is 1.3″ inch in size, features 128×64 pixels and uses the SPI Bus. On the next step you will find more useful information about the OLED tech and this display.

We will use the u8glib library to communicate with our display. This library has many available parameters with it you can display numbers, letters, bitmaps and other symbols on OLEDs and graphic LCDs also it works for E-ink displays.


* A hygrometer /haɪˈɡrɒmɨtər/ is an instrument used for measuring the moisture content in the atmosphere. - Wikipedia

Step 1: Info About the OLED Display and Tech

Picture of Info About the OLED Display and Tech

An organic light-emitting diode (OLED) is a light-emitting diode (LED) in which the emissive electroluminescent layer is a film of organic compound that emits light in response to an electric current. This layer of organic semiconductor is situated between two electrodes; typically, at least one of these electrodes is transparent. - Wikipedia

The one I use is produced by Waveshare. Its 1.3″ inch in size, features 128×64 pixels and uses the 4-wire Serial Peripheral Interface Bus. It is monochrome blue in color also it consumes 0.04 W of energy which is one tenth that is required to run traditional 16x2 LCD display.

The OLED could be modified (soldering required) to communicate with different Bus, like a I2C or a 3-wire SPI, by moving one of the two resistors which can be found on the back of the display board. They are marked with 0s, check the pic above.

Changing the Bus from a 4-wire SPI to a I2C or a 3-wire SPI:

I2C - move BS1 resistor on 1 but keep BS0 on 0 as it is.

3-wire SPI - BS1 must be 0 and BS0 on 1

Step 2: Info About DHT11

Picture of Info About DHT11

The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, sensor readings can be up to 2 seconds old.


  • Small size, low cost
  • Easy to use 3 to 5V power and I/O
  • 2.5mA max current use during conversion (while requesting data)
  • Good for 20-80% humidity readings with 5% accuracy
  • Good for 0-50°C temperature readings ±2°C accuracy
  • No more than 1 Hz sampling rate (once every second)

Step 3: Gathering Materials

Picture of Gathering Materials

To make it we gonna need the following stuff:

  1. Arduino UNO board or similar
  2. OLED display (1.3inch; 128x64) or similar
  3. DHT11 - temperature and humidity sensor
  4. Breadboard
  5. Jumpers x 12 - to connect everything

Step 4: Connecting the Sensor and the OLED

Picture of Connecting the Sensor and the OLED

Now take a look on the schematic above, plug in the display and the sensor into the breadboard. Then connect the negative and positive voltage pins of both DHT11 and the OLED to the ground and +5v pins of the Arduino UNO board with jumpers.

Then take one jumper and connect the output pin of the sensor to A0 of the Arduino board.

Connect the OLED pins: DIN to pin 13; CLK to pin 11; CS to pin 10; D/C to pin 9 and RES to pin 8 with the rest of the jumpers. 13, 11, 10, 9 and 8 are the SPI Bus of Arduino UNO they are also the ICSP connector under the microcontroller.

Once you connect them you can upload the code to the board (you can do that before connecting the sensor and the display).

Step 5: Upload the Code

This step is easy, just download one of the two .INO files, named Fahrenheit (measures in F) and Celsius (measures in C), and open it with the Arduino IDE then upload the code to the Arduino board.

If you don't like the current font you can change it simply by editing the code. You can find all supported fonts here.

If you don't have Arduino IDE click here to download it. Then install it.

Libraries you will need: DHT and u8glib download the libraries and then unzip them at /Program Files(x86)/Arduino/Libraries (default).


Step 6: Congrats !!!

Picture of Congrats !!!

Now you have an Arduino OLED thermometer and hygrometer and you can measure the temperature in Fahrenheit or in Celsius and the moisture content of the air anywhere you want.

Bitcoin tips: 1Bfgrq4dQSuRHuTdk5jzZPtnMZLymDQ5dv

Featured comments:

"It's a nice beginners project to get started with OLEDs and temperature sensors". - MaterialBall

"Thanks for the share, very easy to follow instructions!" - Akin Yildiz

"Outstanding!!" - kath65


Tstef (author)2017-07-12

Man, what is up with all these tutorials that connect DHT sensors to analog pins? They are digital sensors -- you even say so in the intro ("no analog pins required"). How are they even working?

PanagiotisS8 made it! (author)2017-06-21

Thank you Konstantin! I've just made it and it so great. I've modified the circuit by adding a solar panel, rechargeable batteries and a switch.

HeinrichK1 (author)2016-05-11

Very nice instructable. I just want to add something small. If you only have one OLED display you can tie the CS pin of the display to ground (chip select and you only have one chip)

Thats a good idea I will put it in `ible !

psxmaster made it! (author)2016-07-12

Thank !!!

I like what you did, nice work !

mport1 (author)2016-06-04

swapping din and clk is the solution

mport1 (author)2016-06-04

thank you Konstantin, i tried to make the project with dh22, nothing happens after uploading the sketch, edited the sketch for dht22 already.. , verified pinouts , i use the same oled using 5v out..any ideas???

mport1 (author)2016-06-04

thank you Konstantin, i tried to make the project with dh22, nothing happens after uploading the sketch, edited the sketch for dht22 already.. , verified pinouts , i use the same oled using 5v out..any ideas???

Sarvasv Kulpati (author)2016-03-05

Thanks for the AWESOME instructable, it was simple and super easy to follow. Although it might just have been a problem on my side, I wanted to point out that the code for celsius shows the input pin of the dht11 as A5, and not A0. Sorry if it was a problem from me ;D

Comatech (author)2016-02-12

Hi, i just tried use DHT22 with this scheme and sketch, and its not working, what modifications i need to make it work? Thanks ;)

Yes, open the sketch and replace DHT.read11(dht_apin); with DHT.read22(dht_apin);. It should be between line 29 and 35.

I has did it myself, and you writing next =) Funny! Thanks

Comatech (author)2016-02-12

Its sho 0 degrees and 1% humidity, i don't know maybe sensor is dead, but need to test it somehow =(

trimitsos made it! (author)2016-01-16

Could you help on modifying the code for the screen I have purchased?

I would like to have a custom heading in yellow and measurements in Blue bellow the heading.

Model: 0.96 inch OLED Display Module (B) Vertical Pinheader 128*64 SSD1306 SPI I2C

Your code is ready, go to step 5 and download it.

It worked perfectly, thank you so much!

Your welcome !

trimitsos made it! (author)2016-01-15

I did pass the error problem (there was a second tab open in arduino software), but now it seems I have a bigger one!

The oled screen seems not to be working!

Swap pin 13 and pin 11 and it should work, cause DIN is 11 and CLK is 13.

Oh yes it did work...

(but just found out I purchased a smaller screen than the one you did!)

Thats nice, you can change the resolution from 128x64 to 128x32 or change the font size. :)

trimitsos made it! (author)2016-01-14

I have followed all the steps and get an error when uploading your code
see attached photo
Please give a little help

Hello !

That a bit strange, did you install the libraries from step 5 (DHT and U8glib) ?

Also you have to connect the DHT sensor to analog 5, my bad it should be A0.

Yes, both libraries are copied in proper libralies folder.

I have used Analog5, since I saw that in the code.

But still get this message. Could you sent me a Copy of the code in Celcius in order to chack it again?

Ok, could you copy and paste the error message so I can see whats wrong.

HelgiB (author)2016-01-13

You got used a A5 pin in the sketch ;) but on scheme it's A0, anyway it's working nice, i like it.

My bad ! :) Thanks for the notice I will fix it later today.

laith mohamed (author)2016-01-12

Good work

Thank you !

maroelawerner (author)2016-01-10

Nice little project. Why don't you use the DHT22 instead of the cheaper DHT11? The DHT11 has a very restricted humidity range and is not so accurate. As soon as the weather starts becoming rainy, you will have exceeded the DHT11's range of 20 - 80% humidity. The DHT22 goes from 0 - 100% humidity (non-condensing). In my opinion the DHT22 should be used for most environments.

Yes DHT22 is better than DHT11 but also much expensive and I couldn't affort one. But I think that the code should work with DHT22 without a problem. Thank you !

terrible tinkerer (author)2015-12-19

Dear Mr KD, If I could bring your attn to Step 4. You say download the INO file, open it with Arduino IDE then upload the code to the Arduino board. I believe Arduino needs to verify the file first before uploading to Arduino board. This happens to be where I'm stuck as each time I try to verify Arduino highlights the 4th line down "dht DHT:" and states 'dht' does not name a type. Am I missing something?


Go to step 4 and download the DHT library and unzip it at the libraries folder in the Adruino IDE and the device should work. :)

Hey Hey Works! Thanks muchly KD. Needed both files to verify correctly but verify it did. After I walk my dogs I'll plug into my arduino board. Can't wait!


I'm beginning to feel like a pest KD. Hope you don't mind my questions. I see you use the larger OLED display while mine is the smaller .96" SSD1306 module. Do you think I need to change any wording in your sketch in order to get my OLED working? Nothing showing on my display after uploading the sketch is why I ask.


What Bus does it use to communicate, SPI or I2C ?

Whoa! Not sure about no Bus thang! Kidding aside, I've connected all 7 OLED pinouts to the corresponding seven Arduino pinouts - Ground to Gnd, VCC to 5v, DI(mosi/data) to 13, D0(clk) to 11, CS(chip select) to 10, DC(data/command) to 9, RST(reset) to 8.


The solution is simple. Open the code and replace U8GLIB_SH1106_128X64 with U8GLIB_SSD1306_128X32 on line 6 or 5, not sure, and it should work. :)

terrible tinkerer (author)2015-12-18

If your OLED has different pinouts, as mine does, the info on this page might help.

Info on SPI & I2C there too.

Yeah this info is very useful, I am going to put it in the instructuble. Thanks for sharing it ! :)

Hey, Glad to be of any help KD. Would be nice to fit this in a small project box.

ErixM (author)2015-12-15


it looks very nice, I've never worked with OLED yet, I think I will give it a try.

But before I've a question about what you wrote, here:


The OLED could be modified to work with different Bus, like I2C or 3-wire SPI,
by moving one of the two resistors which can be found on the back of
the display board. They are marked with 0s, check the pic above.

Changing the Bus from 4-wire SPI to I2C or 3-wire SPI:

I2C - move BS1 resistor on 1 but keep BS0 on 0 as it is.

3-wire SPI - BS1 must be 0 and BS0 on 1


I don't understand what I have to do to make it working with your "Arduino OLED Termometer". Can you, please, give me more details, as I cannot see modifications on your pictures ?

Thanks in advance for your help



Thanks Erix !

Well, my display can communicate with one of the two Buses SPI(by default) or I2C, with Arduino. The SPI bus has two variants with 3 and with 4 wires while I2C is using 2 wires. SPI has higher speed than I2C.

So, all you have to do is to buy OLED display with SPI interface to make my "Arduino OLED...." Thermometer.

Okay, I've order 2 x OLED this afternoon, let's see in 1 or 2 weeks when they arrive.

Bye for now and thank you again for sharing.

terrible tinkerer (author)2015-12-14

Great stuff Konstantin. I've been looking for a portable thermometer/ humidity gauge for in the house and outside. In your project it appears you supply the power through the arduino uno's usb connection? Do you think a 9v battery could be connected to the 5.5 x 2.1 barrel jack to supply power instead? This way the whole works could be fit into a small project box.

You got my vote in the 3 contests. Good job.

Thank you !

Yes you can power up the whole project with 9v battery connected to the 5.5x2.1 barrel jack, after all the arduino UNO is designed to work with higher voltages (it has voltage regulator).

Thanks again !

somnath1974 (author)2015-12-14

The project is very nice.

But the negative side is, the author used a whole Arduino. Which made it big and not compact.Should have use some "bare bone arduino". It would have little and can be used in real life. Like,.... in a car or in a room..

However nice project.

Thanks, unfortunately I don't have smaller arduino board cause UNO is cheaper than the Nano in my country.

mattcintosh (author)2015-12-13

Cool. At first glance, I thought it was a VFD

About This Instructable




Bio: I am a dreamer, maker and an engineer making and sharing interesting projects here at Instructables. Follow me @ instagram: @the_gadget.boy
More by Konstantin Dimitrov:Arduino/Genuino 101 BLE Thermometer With TMP102 and BlynkPixie: An Arduino Based NeoPixel WristwatchTurn Your Old 2.5'' Or 3.5'' Hard Drive Into Portable/External
Add instructable to: