Build a mini weather station ☂️
Make your own mini weather station to get the weather forcast by using Arduino UNO, DHT11, and LCD
Scroll down to follow step by step or jump to the section by clicking on it
Know it
Explore what you will learn
Buy it
Buy the parts that you need
Wire it
Wire all the parts togather
Code it
Understand the code and upload it
Test it
Test the project that you have built
Get it
Get the resources for this project
Know it
To build our tiny weather station, a temperature and humidity sensor is needed. For our case, we will use the DHT11 sensor and connect it to an LCD screen to display the readings. This allows us to see the temperature and humidity and calculate the heat index. You can pick between Celsius and Fahrenheit too!
Buy it
For this tutorial we will need the following components, you can buy them rightway through our store.
Wire it
The connections between the components we mentioned are straight forward (you can also check the wiring):
Connections from the Arduino to the breadboard:
- Arduino pin GND → Breadboard ground line
- Arduino pin 5V → Breadboard 5V line
Connections from the LCD I2C driver:
- LCD GND → Breadboard ground line
- LCD Vcc → Breadboard 5V line
- LCD SDA → Arduino pin A4
- LCD SCL → Arduino pin A5
Connections from the DHT sensor:
- DHT GND → Breadboard ground line
- DHT Vcc → Breadboard 5V line
- DHT Signal → Arduino pin 2
Code it
Below is the complete code that you can upload to the Arduino board in order to complete the tutorial. You can follow the comments in the code to understand how to code works and if you want to develope upon it.
/*Level using accelerometerTutorial link: https://www.learn.voltaat.com/post/use-an-accelerometer-to-build-a-levelThis is an Arduino sketch that simulates a level using an ADXL345 accelerometer and displaying it on an LCD screenComponents Needed:1. ADXL345 ........x12. LCD screen .....x13. 10K resistor ...x2Connections:LCD GND → Breadboard ground lineLCD Vcc → Arduino pin 5VLCD SDA → Breadboard SDA lineLCD SCL → Breadboard SCL lineADXL345 GND → Breadboard ground lineADXL345 Vcc → Breadboard 3.3V lineADXL345 SDA → Breadboard SDA lineADXL345 SCL → Breadboard SCL lineArduino pin GND → Breadboard ground lineArduino pin 3.3V → Breadboard 3.3V lineArduino pin A4 → Breadboard SDA lineArduino pin A5 → Breadboard SCL line1st 10K resistor → Between Breadboard SDA line and 3.3V line2nd 10K resistor → Between Breadboard SCL line and 3.3V line*/#include// I2C library#include // Adafruit sensor library#include // ADXL345 Adafruit's library#include // LCD library// ADXL345 instance (12345 is the I2C address)Adafruit_ADXL345_Unified accel =Adafruit_ADXL345_Unified(12345);// LCD instance (0x27 is the I2C address)LiquidCrystal_I2Clcd(0x27,16,2);// Commands inside void setup run oncevoidsetup(){Serial.begin(9600);// Start the serial monitorlcd.init();// Initialize the LCD screenlcd.backlight();// Turn on backlight on the LCD// Initialise the sensorif(!accel.begin()){// There was a problem detecting the ADXL345 ... check your connectionsSerial.println("Ooops, no ADXL345 detected ... Check your wiring!");lcd.clear();lcd.setCursor(0,0);lcd.print("Sensor error");while(1);}// Set the range to whatever is appropriate for your project// Uncomment the needed lineaccel.setRange(ADXL345_RANGE_16_G);// accel.setRange(ADXL345_RANGE_8_G);// accel.setRange(ADXL345_RANGE_4_G);// accel.setRange(ADXL345_RANGE_2_G);}// Commands inside void loop run forevervoidloop(){// Get a new sensor eventsensors_event_t event;accel.getEvent(&event);// Print to serial monitor (acceleration is measured in m/s^2)Serial.print("X: ");Serial.print(event.acceleration.x);Serial.print(", Y: ");Serial.print(event.acceleration.y);Serial.print(", Z: ");Serial.print(event.acceleration.z);Serial.println(" m/s^2 ");// Calculate the bubble location on the screen// One row on the LCD is 16 characters. But we use only 15 to get// an odd number for the center value. The x-axis range between// -10 and 10. With basic math, we get the followingint bubble =round(15-(((event.acceleration.x +10)/20.0)*15));if(bubble <0) bubble =0;if(bubble >14) bubble =14;// Print the bubblelcd.setCursor(0,0);for(int i =0; i <16;++i){if(i == bubble){lcd.print('o');}elseif(i ==5|| i ==9){lcd.print('|');}else{lcd.print(' ');}}// Pretty-print axes to the LCDchar buf[17];sprintf(buf,"X:%02d Y:%02d Z:%02d",(int) event.acceleration.x,(int) event.acceleration.y,(int) event.acceleration.z);lcd.setCursor(0,1);lcd.print(buf);// Wait for 0.1 seconddelay(100);}
Test it
As you can see on the screen, the LCD is display the temparture in C and humidity.
Get it
Follwoing is the code links, library and the frizting file if you need to use it:
- Code
- Library
- Fritazing file
- Datasheet
Going futher
Understand your plant needs with soil moisture sensor 🌱
How to use the soil moisture sesnor with the Arduino to sense how dry is the plant's soil
Make some noise with passive buzzer 🔊
Learn how to use the buzzer with the Arduion to make beeps!
Know how far things are with Ultrasonic Sensor 📏
Explore the ultrasonice sensor and it's ablility ot measure the distance with the Arduion