Weather station: Arduino, DHT11 sensor, Oled display

How to make a mini weather station (temperature, humity monitor) using Arduino, DHT11 sensor and Oled display

Jun 6, 2020

43133 views

11 respects

Components and supplies

1

SSD1306 OLED 128X64 0.96 inch - I2C

1

DHT11 Temperature & Humidity Sensor (3 pins)

1

Jumper wires (generic)

1

Solderless Breadboard Half Size

1

Arduino UNO

Apps and platforms

1

Arduino IDE

Project description

Code

weather station code

c_cpp

weather station code

c_cpp

Downloadable files

Weather station schematic

Weather station schematic

Comments

Only logged in users can leave comments

kardx

6 months ago

Hey everyone, kardx here. I have heard many complaints about the OLED showing up nan%, nanC and nanF. I also experienced these problems. What worked for me was connecting the signal pin of the DHT11 to digital pin 2. Many people here thought that the signal pin was to be connected to analog 2, and the OLED couldn't display the content. As for the Adafruit splash, the code provided is not this project's author's own, it is provided by an external company called Adafruit. Adafruit is a company that provides electrical components, shields, etc. , as well as tutorials on their website. It also provides libraries for the Arduino IDE, like this DHT library (see code). Since Adafruit themselves have produced this code, they have put their splash here. You can find Adafruit's website here: www.adafruit.com Hope you found some answers here! Happy programming, kardx.

kardx

6 months ago

Hey everyone, kardx here. I have heard many complaints about the OLED showing up nan%, nanC and nanF. I also experienced these problems. What worked for me was connecting the signal pin of the DHT11 to digital pin 2. Many people here thought that the signal pin was to be connected to analog 2, and the OLED couldn't display the content. As for the Adafruit splash, the code provided is not this project's author's own, it is provided by an external company called Adafruit. Adafruit is a company that provides electrical components, shields, etc. , as well as tutorials on their website. It also provides libraries for the Arduino IDE, like this DHT library (see code). Since Adafruit themselves have produced this code, they have put their splash here. You can find Adafruit's website here: www.adafruit.com Hope you found some answers here! Happy programming, kardx.

Anonymous user

2 years ago

Hi, I am trying to do this project, but my display is a Adafruit 2.4" screen with a ssd1305 my problem is that my display has 20 pins compared to the 4 pins of the ssd1306. Can anyone please help with the wiring. I don't know if it can be wired using 4 pins as in hacksters project or if it needs more than 4 pins. Regards George Nicholls. georgenicholls50@gmail.com

Anonymous user

2 years ago

The screen works, but all it shows is nan% for the humidity and naC and naF for temperatures. I saw another comment about this issue, and I tried your resolution, but that didn't work either. Any other possible fixes?

Anonymous user

2 years ago

I found the fix is that I was using the wrong type of sensor. I am using the DHT20 sensor, which doesn't work with this script.

oldmufflerman

2 years ago

Okay, I'm having a duhhhh moment! how do I download the code for the weather station? Thank you in advance ever so much for your speedy reply to my request. Much appreciated!

oldmufflerman

2 years ago

Fantastic!!!! Everything is working fantastically as supposed to be! Yaaaa! I'm a newbie, I'm as green as grass. so much to learn and so little time. HaHa

Anonymous user

2 years ago

On Arduino Leonardo, IIC pins are: D2 - SDA, D3 - SCL.

Anonymous user

2 years ago

Hi! Thank you for sharing this. I'm stuck on how to fix "nan" output on the OLED. I repeatedly watch your videos and rewire if I have mistaken but still the output on the OLED is "nan% ,nanC,nanF". Can you help me? Thank you very much

Anonymous user

2 years ago

try to change "#define SCREEN_HEIGHT 64" to "#define SCREEN_HEIGHT 32" or vice versa

Anonymous user

2 years ago

hi all This really work and works well, which is better than some l have tried plus l think there is room for expansion too (Great)

Anonymous user

2 years ago

It works perfectly. I'm a noob and would like to understand a bit of the code: at the beginning of loop(), we Serial.print everything, then in the next section we display.print(). It looks like the display.print() commands send the data to the display, so what did the Serial.print operations do? Also, the code includes a flash of the Adafruit logo before the main business of displaying data. Is this a common courtesy to the vendor? It is easy enough to remove, but would you say it is traditional to give them a plug? just curious.

Anonymous user

2 years ago

actually, the Serial.print operations don't have any function. I commented them out and the program works the same.

Anonymous user

2 years ago

Works Well, I've done this on a 128x32 OLED just change the line "oledDisplay(3,5,28,humi,"%");" to "oledDisplay(2,5,16,humi,"%");" and things line up perfectly.

Anonymous user

2 years ago

Thanks so much for this! Still using this code today! By far the best repo for dht22 and Arduino Uno OLED projects!

Anonymous user

2 years ago

i have build it and it works whit the DHT 11, but i use a 7 pin Oled 128x64 0.96 i2c, but i can´t get it to work, it shows nothing in the display ( i am new to Arduino )

Anonymous user

2 years ago

The screen works, but all it shows is nan% for the humidity and naC and naF for temperatures. I saw another comment about this issue, and I tried your resolution, but that didn't work either. Any other possible fixes?

Anonymous user

2 years ago

I found the fix is that I was using the wrong type of sensor. I am using the DHT20 sensor, which doesn't work with this script.

oldmufflerman

3 years ago

Fantastic!!!! Everything is working fantastically as supposed to be! Yaaaa! I'm a newbie, I'm as green as grass. so much to learn and so little time. HaHa

oldmufflerman

3 years ago

Okay, I'm having a duhhhh moment! how do I download the code for the weather station? Thank you in advance ever so much for your speedy reply to my request. Much appreciated!

Anonymous user

3 years ago

Hi, I am trying to do this project, but my display is a Adafruit 2.4" screen with a ssd1305 my problem is that my display has 20 pins compared to the 4 pins of the ssd1306. Can anyone please help with the wiring. I don't know if it can be wired using 4 pins as in hacksters project or if it needs more than 4 pins. Regards George Nicholls. georgenicholls50@gmail.com

dontreadmyusername

3 years ago

On Arduino Leonardo, IIC pins are: D2 - SDA, D3 - SCL.

Anonymous user

4 years ago

Hi! Thank you for sharing this. I'm stuck on how to fix "nan" output on the OLED. I repeatedly watch your videos and rewire if I have mistaken but still the output on the OLED is "nan% ,nanC,nanF". Can you help me? Thank you very much

dontreadmyusername

2 years ago

try to change "#define SCREEN_HEIGHT 64" to "#define SCREEN_HEIGHT 32" or vice versa

Anonymous user

4 years ago

Works Well, I've done this on a 128x32 OLED just change the line "oledDisplay(3,5,28,humi,"%");" to "oledDisplay(2,5,16,humi,"%");" and things line up perfectly.

Anonymous user

4 years ago

Hola : herolivechannel , podrias modificar el sketch para que los numero de la temperatura sean mas grande en la pantalla oled , el tamaño como los de humidity , pascualpalacios525@gmail.com

Anonymous user

4 years ago

hi all This really work and works well, which is better than some l have tried plus l think there is room for expansion too (Great)

Anonymous user

4 years ago

It works perfectly. I'm a noob and would like to understand a bit of the code: at the beginning of loop(), we Serial.print everything, then in the next section we display.print(). It looks like the display.print() commands send the data to the display, so what did the Serial.print operations do? Also, the code includes a flash of the Adafruit logo before the main business of displaying data. Is this a common courtesy to the vendor? It is easy enough to remove, but would you say it is traditional to give them a plug? just curious.

Anonymous user

2 years ago

actually, the Serial.print operations don't have any function. I commented them out and the program works the same.