Project 6 : Serial Communication

Where to connect from ESP32 to BMP280 sensor and OLED display
Schematic (https://randomnerdtutorials.com/)
My final arrangements on my breadboard
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);Adafruit_BMP280 bmp; // I2Cvoid setup() {
// put your setup code here, to run once:
Serial.begin(115200);
bool status = bmp.begin(0x76);
if(!status){
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while(1);
}
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
delay(2000);
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
}
void loop() {
delay(2000);

// put your main code here, to run repeatedly:
float temp = bmp.readTemperature();
float pres = bmp.readPressure();
float alti = bmp.readAltitude(1013.25);
if(isnan(temp) || isnan(pres) || isnan(alti)){
Serial.println("Failed to read from bmp sensor!");
}
display.clearDisplay();display.setCursor(0,0);
display.print("Temperature: ");
display.print(temp);
display.print(" ");
display.cp437(true);
display.write(248);
display.println("C");
display.setCursor(0, 25);
display.print("Pressure: ");
display.print(pres/1000);
display.print(" kPa");
display.display();
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Flutter Animations Made Easy

Creating a Python-based Automated Mailing Alert System

Dockerizing a Flask App

Installing Oracle JDBC-Driver On Wildfly / JBoss

Pickeling Objects in Python

A Gentle Introduction to Computer Algorithms

Person typing on laptop

No More Reverted Transactions in NFT War

#Augmented #Reality #solutions #provider #CGS #joins #Metas #Quest #Business #program

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gresya Leman

Gresya Leman

More from Medium

Full Circle Offers Media — Issue #11

3 Things To Know About Scrum

Routine Building — Week 2

YouTube: Patterns & Flows