Altium
Arduino Projects

Arduino Weather Station using dht11 and Display Data on Gauges

Description:

weather station

Arduino Weather Station– This project is based on the Real-Time weather station monitoring system using Arduino, DHT11” temperature and humidity sensor” and Visual Basic 2010 Express edition. The main purpose of this project is to share with you the idea of how you can make a real-time weather station and display the Temperature and Humidity values on the Gauges. In this project, you will also learn how to install and use the Dev Components.

The DHT11 sensor will be interfaced with the Arduino Uno or Mega. The temperature and humidity values will be calculated by the Arduino or Mega, and then these values will be sent Serially to the Computer designed application. This project also focuses on the concept of how multiple sensors values can be sent in a single string message separated with comma, and then how each sensor value can be accessed individually and display them in there own boxes or Gauges. So this project will also help you learn, how to split the string message. This technique can be used in Advanced level projects, where you need to monitor multiple sensors connected with Arduino or Mega or any other controller.

For the step by step designing and explanation watch video available at the end of this Article.


Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

Mega 2560:

DHT11 Temperature and Humidity Module:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Softwares used in this project:

  1. Visual Basic 2010 Express Edition “Vb.net”
  2. Arduino IDE

The weather station application forms will be designed and programmed in the Visual Basic.Net, while the Arduino programming will be done in the Arduino IDE. Both the Softwares are freely available and can be downloaded without any problems.  The desktop application programming and Arduino programming both are available at the end of this Article.

DHT11 sensor Pinout:

weather station

This is the DHT11 temperature and humidity sensor which is used in this project for building the Real-Time weather station. DHT11 Sensor has a total of 4 pins. Pin number 1 is the VCC, pin number 2 is the data, pin number 3 is not connected while pin number 4 is the Ground.

The other useful information about the DHT11 sensor can be found in its datasheet. For example its applications, Features, Dimensions, Product parameter, Electrical characteristics, Pin description, and data format, etc. It’s a good designing practice to study the datasheet of the electrical component before you start using it any circuit.


For the easy connections, I highly recommend firs you need to fix this sensor on the Vero Board, Solder its legs and the 10-kilo resistor. Then solder jumper wires. This way you can easy interface the DHT11 temperature and humidity sensor with the Arduino Uno or Mega.

weather station

Circuit Diagram of the Arduino Weather Station:

weather station

The connection of the DHT11 temperature and humidity sensor with the Arduino Uno or Mega is really simple. As you can see in the circuit diagram above, a 10 kilo Ohm resistor is connected between pin number 1 and pin number 2. As I said earlier the pin number 3 of the dht11 sensor is not used. Pin number 4 of the DHT11 temperature and humidity sensor is connected with the Arduino’s Ground, while pin number 2 is connected with the Arduino’s pin number 12.


Weather Station Programming:

This project is basically based on two programs, one program is written for the Arduino, while the other program is for the computer software designed in visual basic 2010 express edition.

Before you start the programming first of all, make sure you download all the necessary libraries.

Arduino Weather Station Programming:

#include "DHT.h"

#define DHTPIN 12     // what pin we're connected to

//Uncomment whatever the type of sensor we are using. 
#define DHTTYPE DHT11   // DHT 11 
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is 
// pin3 of the sensor is not connected
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// NOTE: For working with a faster chip, like an Arduino Due or Teensy, you
// might need to increase the threshold for cycle counts considered a 1 or 0.
// You can do this by passing a 3rd parameter for this threshold.  It's a bit
// of fiddling to find the right value, but in general the faster the CPU the
// higher the value.  The default for a 16mhz AVR is a value of 6.  For an
// Arduino Due that runs at 84mhz a value of 30 works.
// Example to initialize DHT sensor for Arduino Due:
//DHT dht(DHTPIN, DHTTYPE, 30);


String TextForSms ;
String humidity = " Humidity: %";
String temperature = "   Temperature";
String sign = " *C";

char fromc; // character from computer

void setup() {
  Serial.begin(9600); 
 // Serial.println("DHT11 test!");
 
  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  int h = dht.readHumidity();
  // Read temperature as Celsius
  int t = dht.readTemperature();
  // Read temperature as Fahrenheit
  int f = dht.readTemperature(true);
  
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index
  // Must send in temp in Fahrenheit!
  int hi = dht.computeHeatIndex(f, h);

//  Serial.print("Humidity: "); 
//  Serial.print(h);
//  Serial.print(" %\t");
//  Serial.print("Temperature: "); 
//  Serial.print(t);
//  Serial.print(" *C ");
  
   TextForSms = TextForSms + t + "," + h + ",";
Serial.println(TextForSms); 
     TextForSms = ""; 
   delay(1000);   
 
//  TextForSms.concat(humidity);
//   TextForSms.concat(h);
//   TextForSms.concat(temperature);
//    TextForSms.concat(t);
//    TextForSms.concat(sign);
//    Serial.println(TextForSms);
   
//  Serial.print(f);
//  Serial.print(" *F\t");
//  Serial.print("Heat index: ");
//  Serial.print(hi);
//  Serial.println(" *F");

}


Computer application Programming of  Weather Station:

Imports System.IO
Imports System.IO.Ports

Public Class Form1

    Dim value1 As Decimal
    Dim value2 As Decimal


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        SerialPort1.Close()
        SerialPort1.PortName = "com5"
        SerialPort1.BaudRate = "9600"
        SerialPort1.DataBits = 8
        SerialPort1.Parity = Parity.None
        SerialPort1.StopBits = StopBits.One
        SerialPort1.Handshake = Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default
        SerialPort1.Open()
    End Sub



    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim s As String

        s = TextBox1.Text + "," + "," + "," + ","

        Dim somestring() As String
        ' Split string based on comma
        somestring = s.Split(New Char() {","c})

        TextBox2.Text = somestring(0)
        Try
            value1 = Convert.ToDecimal(TextBox2.Text)

        Catch ex As Exception
            TextBox1.Text = ""
        End Try

        TextBox3.Text = somestring(1)
        Try
            value2 = Convert.ToDecimal(TextBox3.Text)

        Catch ex As Exception
            TextBox1.Text = ""
        End Try
        TextBox4.Text = somestring(2)
 
        gc1.SetPointerValue("Scale1", "Pointer1", value1)
        gc2.SetPointerValue("Scale1", "Pointer1", value2)
        TextBox1.Text = ""

    End Sub

    Private Sub DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived


        Try

            Dim mydata As String = ""
            mydata = SerialPort1.ReadExisting()

            If TextBox1.InvokeRequired Then
                TextBox1.Invoke(DirectCast(Sub() TextBox1.Text &= mydata, MethodInvoker))
            Else
                TextBox1.Text &= mydata
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

End Class

Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

4 Comments

  1. i need help in visual basic code
    gc1.SetPointerValue(“Scale1”, “Pointer1”, value1)
    gc2.SetPointerValue(“Scale1”, “Pointer1”, value2)
    in these line it is saying gc1 is not decleard
    same for gc2
    any help??

Leave a Reply

Your email address will not be published.

Back to top button