Mirko Pavleski
Published © GPL3+

Classic Style Arduino Weather Station with three Oled Disp

This is a very simple, visually effective, but also very useful device that accurately displays the three basic meteorological parameters

BeginnerFull instructions provided2 hours1,449
Classic Style Arduino Weather Station with three Oled Disp

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
×3
I2C Hub 1 to 6 Expansion TCA9548A Module
M5Stack I2C Hub 1 to 6 Expansion TCA9548A Module
×1
SparkFun Atmospheric Sensor Breakout - BME280
SparkFun Atmospheric Sensor Breakout - BME280
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Schematic diagram

...

Code

Arduino code

C/C++
...
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(128, 64, &Wire, 4);
Adafruit_BME280 bme;
float temp, hum, pressure;

void TCA9548A(uint8_t bus)
{
  Wire.beginTransmission(0x70);
  Wire.write(1 << bus);
  Wire.endTransmission();
}

void setup()
{
  TCA9548A(1);
  bme.begin(0x76, &Wire);
    
  TCA9548A(2);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(4);
  display.setTextColor(WHITE);
  display.setCursor(18,20);
  display.println("HUM.");// Print text
  display.display();

  TCA9548A(3);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(4);
  display.setTextColor(WHITE);
  display.setCursor(10,20);
  display.println("PRES");// Print text
  display.display();
  
  TCA9548A(4);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(4);
  display.setTextColor(WHITE);
  display.setCursor(10,20);
  display.println("TEMP.");// Print text
  display.display();
  delay(5000);
 
}

void loop()
{
  TCA9548A(1);
  temp = bme.readTemperature();
  hum = bme.readHumidity();
  pressure = bme.seaLevelForAltitude(700.0, bme.readPressure())/100.0;

  TCA9548A(2);
  display.setTextColor(WHITE); display.clearDisplay();
  display.setTextSize(2); display.setCursor(0,0); display.print("Humidity %");
  display.setTextSize(3); display.setCursor(20,30);
  display.print(hum);
  display.display();

  TCA9548A(3);
  display.setTextColor(WHITE); display.clearDisplay();
  display.setTextSize(2); display.setCursor(5,0); display.print("Press. hPa");
  display.setTextSize(3); display.setCursor(0,30);
  display.print(pressure);
  display.display();
  
  TCA9548A(4);
  display.setTextColor(WHITE); display.clearDisplay();
  display.setTextSize(2); display.setCursor(30,0); display.print("Temp C");
  display.setTextSize(3); display.setCursor(20,30);
  display.print(temp);
  display.display();
  
  delay(1000);
}

Code with large numbers

C/C++
.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(128, 64, &Wire, 4);
Adafruit_BME280 bme;
int temp, hum, pressure;

void TCA9548A(uint8_t bus)
{
  Wire.beginTransmission(0x70);
  Wire.write(1 << bus);
  Wire.endTransmission();
}

void setup()
{
  TCA9548A(1);
  bme.begin(0x76, &Wire);
    
  TCA9548A(2);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(4);
  display.setTextColor(WHITE);
  display.setCursor(18,20);
  display.println("HUM.");// Print text
  display.display();

  TCA9548A(3);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(4);
  display.setTextColor(WHITE);
  display.setCursor(10,20);
  display.println("PRES");// Print text
  display.display();
  
  TCA9548A(4);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(4);
  display.setTextColor(WHITE);
  display.setCursor(10,20);
  display.println("TEMP.");// Print text
  display.display();
  delay(5000);
 
}

void loop()
{
  TCA9548A(1);
  temp = bme.readTemperature();
  hum = bme.readHumidity();
  pressure = bme.seaLevelForAltitude(700.0, bme.readPressure())/100.0;

  TCA9548A(2);
  display.setTextColor(WHITE); display.clearDisplay();
  display.setTextSize(2); display.setCursor(0,0); display.print("Humidity %");
  display.setTextSize(4); display.setCursor(45,30);
  display.print(hum);
  display.display();

  TCA9548A(3);
  display.setTextColor(WHITE); display.clearDisplay();
  display.setTextSize(2); display.setCursor(5,0); display.print("Press. hPa");
  display.setTextSize(4); display.setCursor(15,30);
  display.print(pressure);
  display.display();
  
  TCA9548A(4);
  display.setTextColor(WHITE); display.clearDisplay();
  display.setTextSize(2); display.setCursor(30,0); display.print("Temp C");
  display.setTextSize(4); display.setCursor(45,30);
  display.print(temp);
  display.display();
  
  delay(1000);
}

Credits

Mirko Pavleski

Mirko Pavleski

121 projects • 1179 followers

Comments