Things used in this project

Hardware components:
Photon new
Particle Photon
×1
13676 01
SparkFun Atmospheric Sensor Breakout - BME280
https://www.amazon.de/gp/product/B01GQ3T1A
×1
OLE Display 128x64
https://www.amazon.de/gp/product/B00NHKM1C0
×1
12002 04
Breadboard (generic)
×1
11026 02
Jumper wires (generic)
×1
Software apps and online services:
Particle WebIDE

Schematics

Code

Example to display temp, humidity & clockC/C++
#include "Particle.h"
#include "Adafruit_BME280.h"
#include "Adafruit_Sensor.h"
#include "Adafruit_SSD1306.h"
#include <math.h> // isnan()

Adafruit_BME280 bme; // I2C
//#define OLED_RESET D4
//Adafruit_SSD1306 display(OLED_RESET);
Adafruit_SSD1306 display(-1);

const unsigned long UPDATE_PERIOD_MS = 2000;

// I2C wiring
#define BME_MOSI D0
#define BME_SCK D1

#define SEALEVELPRESSURE_HPA (1013.25)

unsigned long lastUpdate = 0;
char buf[64];

void setup() {
	Serial.begin(9600);
	
    Serial.println(F("BME280 + OLEDisplay 128x64"));

    if (bme.begin()) {
        Serial.println("BME280 sensor works!");
    }
	
	display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

    display.display(); // show splashscreen
    delay(2000);
    display.clearDisplay();   // clears the screen and buffer

    Time.zone(+2.00);  // setup a time zone, which is part of the ISO6801 format 
}


void loop() { 
	if (millis() - lastUpdate >= UPDATE_PERIOD_MS) {
		lastUpdate = millis();
		
    	Serial.print("Temperature = ");
    	float temp = bme.readTemperature(); // degrees C
        Serial.print(temp);
        Serial.println(" *C");
    
        Serial.print("Pressure = ");
    	float pressure = (bme.readPressure() / 100.0F); // hPa
        Serial.print(pressure);
        Serial.println(" hPa");
    
        Serial.print("Approx. Altitude = ");
        float altitude = (bme.readAltitude(SEALEVELPRESSURE_HPA)); 
        Serial.print(altitude);
        Serial.println(" m");
    
        Serial.print("Humidity = ");
        float humidity = bme.readHumidity(); // % 
        Serial.print(humidity);
        Serial.println(" %");
		
	if (!isnan(temp) && !isnan(humidity)) {
	    
	    	display.clearDisplay();
		    
			display.setTextSize(2);
			display.setTextColor(WHITE);
			display.setCursor(0,0);
//			display.println("Hello, world!");

			snprintf(buf, sizeof(buf), "%.2f C", temp);
			display.println(buf);

			//snprintf(buf, sizeof(buf), "%.1f F", temp * 9.0 / 5.0 + 32.0);
			//display.println(buf);

			snprintf(buf, sizeof(buf), "%.2f %%", humidity);
			display.println(buf);
			
//			snprintf(buf, sizeof(buf), "%.1f %% hPa", pressure);
//			display.println(buf);

//			snprintf(buf, sizeof(buf), "%.1f %% m", altitude);
//			display.println(buf);

            display.println(Time.format(Time.now(), "%H:%M h"));
           	
  		}
		display.display();
	}
}

Credits

Img 6554 3ywwumwxbh
Ingo Lohs
17 projects • 39 followers
I am well over 40 years and come from the middle of Germany. You can contact me also in German. Donation for projects: paypal.me/ingolohs
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login