Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Abid hossain
Published © GPL3+

Local Weather Station

A weather station that can show local atmospheric pressure, temperature humidity and UV index without any internet connection.

IntermediateFull instructions provided2 hours13,896
Local Weather Station

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Grove - Barometer Sensor (BMP280)
Seeed Studio Grove - Barometer Sensor (BMP280)
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
×1
GUVA-S12SD UV sensor
×1
DS3231 RTC
×1

Software apps and online services

Arduino IDE
Arduino IDE
Fusion
Autodesk Fusion

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Enclosure Main

Enclosure Top

Schematics

Arduino local weather station Scm

Code

Local weather station code

Arduino
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <DS3231.h>
#include <DHT.h>

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeMonoBoldOblique12pt7b.h>
//#include <Fonts/FreeMonoBoldOblique9pt7b.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET     4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define BMP_SCK  (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS   (10)

DS3231 clock;
bool century = false;
bool h12Flag;
bool pmFlag;

Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

#define DHTPIN  2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);



const unsigned char PROGMEM frame0 [] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x7F, 0x81, 0xFE, 0x00, 0x00, 0xFC, 0x00, 0x3F, 0x00, 0x01, 0xF0, 0x00, 0x0F, 0x80, 0x03, 0xE0, 0x18, 0x07, 0xC0, 0x07, 0x86, 0x18, 0x61, 0xE0, 0x0F, 0x02, 0x00, 0x40, 0xF0, 0x0F, 0x02, 0x00, 0x40, 0xF0, 0x1E, 0x00, 0x00, 0x00, 0x78, 0x1C, 0x40, 0x00, 0x02, 0x38, 0x3C, 0x61, 0x00, 0x06, 0x3C, 0x3C, 0x01, 0x80, 0x00, 0x3C, 0x38, 0x00, 0x80, 0x00, 0x1C, 0x38, 0x00, 0xC0, 0x00, 0x1C, 0x78, 0x00, 0xE0, 0x00, 0x1E, 0x79, 0xC0, 0xF0, 0x03, 0x9E, 0x79, 0xC0, 0x7C, 0x03, 0x9E, 0x78, 0x00, 0x7E, 0x00, 0x1E, 0x38, 0x00, 0x7E, 0x00, 0x1C, 0x38, 0xFC, 0xFF, 0x3F, 0x1C, 0x3C, 0xFC, 0x7E, 0x3F, 0x3C, 0x3C, 0xFE, 0x7E, 0x7F, 0x3C, 0x1C, 0x7E, 0x18, 0x7E, 0x38, 0x1E, 0x3F, 0x00, 0xFC, 0x78, 0x0F, 0x3F, 0xC3, 0xFC, 0xF0, 0x0F, 0x0F, 0xFF, 0xF8, 0xF0, 0x07, 0x87, 0xFF, 0xE1, 0xE0, 0x03, 0xC1, 0xFF, 0x83, 0xC0, 0x03, 0xF0, 0x3C, 0x0F, 0xC0, 0x01, 0xFC, 0x00, 0x3F, 0x80, 0x00, 0x7F, 0x81, 0xFE, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned char PROGMEM frame1 [] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x01, 0x00, 0x9D, 0x80, 0x00, 0x03, 0x80, 0xB4, 0xE0, 0x00, 0x06, 0x80, 0xA6, 0x80, 0x00, 0x04, 0xC0, 0xA6, 0xE0, 0x00, 0x0C, 0x40, 0xA6, 0xE0, 0x00, 0x08, 0x60, 0xA6, 0x80, 0x00, 0x08, 0x20, 0xA6, 0xE0, 0x00, 0x08, 0x60, 0xA6, 0x80, 0x00, 0x0E, 0xC0, 0xA6, 0xE0, 0x00, 0x03, 0x80, 0xA6, 0x80, 0x00, 0x00, 0x10, 0xA6, 0xC0, 0x00, 0x00, 0x38, 0xA6, 0xE0, 0x00, 0x00, 0x38, 0xA6, 0x80, 0x00, 0x00, 0x6C, 0xA6, 0xE0, 0x00, 0x00, 0x44, 0xA6, 0x80, 0x00, 0x00, 0x6C, 0xA6, 0xE0, 0x00, 0x00, 0x38, 0xA6, 0x80, 0x00, 0x00, 0x00, 0xA6, 0x80, 0x00, 0x00, 0x00, 0xA4, 0xE0, 0x00, 0x00, 0x00, 0xA6, 0x80, 0x00, 0x00, 0x40, 0xA6, 0xE0, 0x00, 0x00, 0xC0, 0xA6, 0x80, 0x00, 0x01, 0xA0, 0xA6, 0xE0, 0x00, 0x01, 0x30, 0xA6, 0xE0, 0x00, 0x03, 0x10, 0xA6, 0x80, 0x00, 0x02, 0x18, 0xA6, 0xE0, 0x00, 0x06, 0x08, 0xA6, 0x80, 0x00, 0x06, 0x08, 0xA6, 0x80, 0x00, 0x02, 0x19, 0xA6, 0xC0, 0x00, 0x03, 0xF3, 0x26,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{
    Serial.println(F("SSD1306 failed"));
  }
  Wire.begin();
  dht.begin();
  if (!bmp.begin()) {
    Serial.println(F("Problem.bmp"));
    while (1) delay(10);
  }
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0, 9);
  display.setFont(&FreeSans9pt7b);
  display.println("**** LOCAL ****");
  display.setCursor(0, 38);
  display.setFont(&FreeMonoBoldOblique12pt7b);
  display.println("wather");
  display.setCursor(27, 58);
  display.println("Station");
  display.display();
  delay(2000);


  bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                  Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                  Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                  Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                  Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */

}


void loop() {

  //Time
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(13, 15);
  display.setFont(&FreeMonoBoldOblique12pt7b);
  display.print(clock.getHour(h12Flag, pmFlag));
  display.setCursor(38, 15);
  display.println(":");
  display.setCursor(50, 15);
  display.println(clock.getMinute());
  display.setCursor(70, 15);
  if (pmFlag) {
    display.println(" PM");
  } else {
    display.println(" AM ");
  }
  display.setFont(&FreeSans9pt7b);

  display.setCursor(20, 60);
  display.println(clock.getDate());
  display.setCursor(40, 60);
  display.println("/");
  display.setCursor(46, 60);
  display.println(clock.getMonth(century));
  display.setCursor(65, 60);
  display.println("/");
  display.setCursor(70, 60);
  display.println("20");
  display.setCursor(90, 60);
  display.println(clock.getYear());
  display.setCursor(30, 30);
  display.setFont(&FreeSans9pt7b);
  switch (clock.getDoW()) {
    case 1:
      display.println("Saturday");
      break;
    case 2:
      display.println("Sunday");
      break;
    case 3:
      display.println("Monday");
      break;
    case 4:
      display.println("Tuesday");
      break;
    case 5:
      display.println("Wednesday");
      break;
    case 6:
      display.println("Thursday");
      break;
    case 7:
      display.println("Friday");
      break;
  }


  display.display();
  delay(5000);
  //P
  display.clearDisplay();
  display.drawBitmap(0, 0, frame0, 40, 40, 1);
  display.setFont(&FreeSans9pt7b);
  display.setCursor(41, 28);
  display.println(bmp.readPressure() / 100);
  display.setCursor(110, 28);
  display.setFont();
  display.println("hPa");
  display.setCursor(0, 55);
  display.setFont(&FreeSans9pt7b);
  display.println("Altitude:");
  display.setCursor(65, 62);
  display.println(bmp.readAltitude(1005.47));
  display.setCursor(113, 62);
  display.println("m");
  display.display();
  delay(5000);
  //T&RH
  display.clearDisplay();
  display.setFont(&FreeMonoBoldOblique12pt7b);
  display.drawBitmap(0, 5, frame1, 40, 51, 1);
  display.setCursor(35, 30);
  display.print(bmp.readTemperature());
  display.setFont(&FreeSans9pt7b);
  display.setCursor(102, 28);
  display.println(" *");
  display.setCursor(110, 31);
  display.println(" C");
  display.setFont();
  display.setCursor(66, 45);
  display.println("RH :");
  byte RH = dht.readHumidity();
  display.setCursor(95, 45);
  display.println(RH);
  display.setCursor(110, 45);
  display.println("%");
  display.drawBitmap(0, 56, frame2, 135, 15, 1);
  display.display();
  delay(5000);
  //UV
  display.clearDisplay();
  float sensorValue = analogRead(A0);
  float sensorVoltage = sensorValue / 1024 * 5.0;
  int UV_index = sensorVoltage / 0.1;
  display.setFont(&FreeSans9pt7b);
  display.setCursor(0, 15);
  display.print("    UV INDEX  ");
  display.setCursor(58, 45);
  display.println(UV_index);
  display.display();
  delay(5000);
}

Credits

Abid hossain

Abid hossain

4 projects • 50 followers
Student of BSEEE in United International University, Bangladesh. Loves to learn and make new stuff.

Comments