Project tutorial
Weather Station with a Processing Graphical User Interface

Weather Station with a Processing Graphical User Interface © GPL3+

Nice looking weather station based on BMP180 and DHT11 sensor boards.

  • 1,495 views
  • 0 comments
  • 2 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

This weather station gives us real-time data for temperature, humidity and relative atmospheric pressure. We can observe data directly on the PC monitor in the form of three analog meters. This nice graphic user interface (GUI) is created with the help of Processing software, specifically the "meter" library created by Bill Kujawa. There are many other options to modify meters. You can find all available options in Example section under Meter library in Processing.

The electronic part consists of an Arduino compatible board to which are connected BMP180 (atmospheric pressure) and DHT11 (humidity and temperature) sensor boards.The circuit diagram is shown in the picture below. Also, is given the Arduino code who is based on SFE_BMP180 and DHT11 libraries. On the serial monitor we can see comma separated measured values.The processing software retrieves this data from the serial port and forms the graphical interface.

To run the final application, first upload the code in Arduino and keep connected the Arduino to the PC. Next, open the Processing sketch and modify the serial port name and baud-rate according to you setup. And then just click on run it will shows a Temperature, Humidity and relative Pressure meters running with real time data coming from the sensors.

Code

Arduino codeC/C++
#include <Wire.h> //Including wire library

#include <SFE_BMP180.h> //Including BMP180 library

#include <SimpleDHT.h>
int pinDHT11 = 6;
SimpleDHT11 dht11;


#define ALTITUDE 700 //Altitude where I live (change this to your altitude)

SFE_BMP180 pressure; //Creating an object

void setup() {
  Serial.begin(9600); //Starting serial communication

  if (pressure.begin()) //If initialization was successful, continue
    Serial.println("BMP180");
  else //Else, stop code forever
  {
    Serial.println("BMP180 init fail");
    while (1);
  }
}

void loop() {

 char status;
  double T, P, p0; //Creating variables for temp, pressure and relative pressure


float temperature = 0;
float humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht11.read2(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(2000);
return;
}

Serial.print((float)temperature);
Serial.print(",");
Serial.print((float)humidity);
Serial.print(",");

  
 
  status = pressure.startTemperature();
  if (status != 0) {
    delay(status);

    status = pressure.getTemperature(T);
    if (status != 0) {
      
      status = pressure.startPressure(3);

      if (status != 0) {
        delay(status);

        status = pressure.getPressure(P, T);
        if (status != 0) {
         
          p0 = pressure.sealevel(P, ALTITUDE);
          Serial.print("");
          Serial.println(p0);
        
        }
      }
    }
  }  
  delay(2000);
}
Processing codeC/C++
import meter.*;
import processing.serial.*;

Serial port;
String[] list;

Meter m, m2, m3;

void setup() {
  size(1260, 900);
  background(255, 255, 200);
  
  port = new Serial(this, "COM4", 9600);

  fill(120, 50, 0);
  m = new Meter(this, 10, 100);
  // Adjust font color of meter value  +
  m.setMeterWidth(400);
  m.setTitleFontSize(20);
  m.setTitleFontName("Arial bold");
  m.setTitle("Temperature (C)");
  m.setDisplayDigitalMeterValue(true);
  
  // Meter Scale
  String[] scaleLabelsT = {"0", "10", "20", "30", "40", "50", "60", "70", "80"};
  m.setScaleLabels(scaleLabelsT);
  m.setScaleFontSize(18);
  m.setScaleFontName("Times New Roman bold");
  m.setScaleFontColor(color(200, 30, 70));
  
  m.setArcColor(color(141, 113, 178));
  m.setArcThickness(10);
  m.setMaxScaleValue(80);
  
  m.setNeedleThickness(3);
  
  m.setMinInputSignal(0);
  m.setMaxInputSignal(80);

  // A second meter for reference
  int mx = m.getMeterX();
  int my = m.getMeterY();
  int mw = m.getMeterWidth();
  
  m2 = new Meter(this, mx + mw + 20, my);
  m2.setMeterWidth(400);
  m2.setTitleFontSize(20);
  m2.setTitleFontName("Arial bold");
  m2.setTitle("Humidity (%)");
  m2.setDisplayDigitalMeterValue(true);
  
  String[] scaleLabelsH = {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"};
  m2.setScaleLabels(scaleLabelsH);
  m2.setScaleFontSize(18);
  m2.setScaleFontName("Times New Roman bold");
  m2.setScaleFontColor(color(200, 30, 70));
  
  m2.setArcColor(color(141, 113, 178));
  m2.setArcThickness(10);
  m2.setMaxScaleValue(100);
  
  m2.setNeedleThickness(3);
  
  m2.setMinInputSignal(0);
  m2.setMaxInputSignal(100);
  
  // A third meter for reference
  int m2x = m2.getMeterX();
  int m2y = m2.getMeterY();
  int m2w = m2.getMeterWidth();
  
  
  
  m3 = new Meter(this, m2x + m2w + 20, m2y);
  m3.setMeterWidth(400);
  m3.setTitleFontSize(20);
  m3.setTitleFontName("Arial bold");
  m3.setTitle("Pressure (HPa)");
  m3.setDisplayDigitalMeterValue(false);
  
  String[] scaleLabelsP = {"990", "995", "1000", "1005", "1010", "1015", "1020", "1025", "1030", "1035", "1040"};
  m3.setScaleLabels(scaleLabelsP);
  m3.setScaleFontSize(15);
  m3.setScaleFontName("Times New Roman bold");
  m3.setScaleFontColor(color(200, 30, 70));
  
  m3.setArcColor(color(141, 113, 178));
  m3.setArcThickness(10);
  m3.setMaxScaleValue(1040);
  
  m3.setNeedleThickness(3);
  
  m3.setMinInputSignal(990);
  m3.setMaxInputSignal(1040);
  
}

public void draw() {
  
  textSize(70);
  fill(0, 255, 0);
  text("ARDUINO Weather Station", 200, 700);
  
  if (port.available() > 0) {
    String val = port.readString();
    list = split(val, ',');
    float temp = float(list[0]);
    float hum = float(list[1]);
    float press = float(list[2]);
    
    println("Temperature: " + temp + " C  " + "Humidity: " + hum + " %" + "Pressure: " + press + "HPa");
    
    m.updateMeter(int(temp));
    m2.updateMeter(int(hum));
    m3.updateMeter(int(press));
  }
}
LibrariesC/C++
No preview (download only).

Schematics

Shematic
Untitled sketch bb p9grn3qzok

Comments

Similar projects you might like

Personal Weather Station (Arduino+ ESP8266 + Thingspeak)

Project tutorial by Jayraj Desai

  • 69,008 views
  • 34 comments
  • 137 respects

Mobile Weather Station Being Powered by Solar Energy

Project tutorial by Kutluhan Aktar

  • 4,569 views
  • 0 comments
  • 16 respects

$10 Portable Arduino Weather Station (AWS)

Project tutorial by Prajjwal Nag

  • 37,047 views
  • 6 comments
  • 73 respects

iShield Weather Station

Project tutorial by Victor Carreño

  • 7,900 views
  • 0 comments
  • 17 respects

Arduino Easy Weather Station With BME280 Sensor

Project tutorial by Nick Koumaris

  • 25,666 views
  • 1 comment
  • 37 respects

MKRFox1200 Weather Station

Project tutorial by Antoine de Chassey

  • 21,626 views
  • 24 comments
  • 33 respects
Add projectSign up / Login