Mirko Pavleski
Published © GPL3+

Weather Station with a Processing Graphical User Interface

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

BeginnerFull instructions provided9,953
Weather Station with a Processing Graphical User Interface

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
BMP180 pressure sensor board
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Processing
The Processing Foundation Processing

Hand tools and fabrication machines

Breadboard, 400 Pin
Breadboard, 400 Pin

Story

Read more

Schematics

Shematic

Code

Arduino code

C/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 code

C/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));
  }
}

Libraries

C/C++
No preview (download only).

Credits

Mirko Pavleski
170 projects • 1384 followers
Contact

Comments

Please log in or sign up to comment.