Project 6: Serial Communication

  1. ESP32 Devkit V1
  2. BMP280 Sensor
  3. 16x2 LCD Display
  4. Jumper wire
https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/
#include <Wire.h>
#include <SPI.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_BMP280.h>
#define BMP_SCK (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS (10)
// set the LCD number of columns and rows
int lcdColumns = 16;
int lcdRows = 2;
// set LCD address, number of columns and rows
// if you don't know your display address, run an 12C scanner sketch
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
Adafruit_BMP280 bmp; // 12C
//adatruit_BMP280 bap (BMP_cS); // hardware SPI
//Adafruit BMP280 bap (BMP Cs, EMP_MOSI, BMP_MISO, BMP_SCK):
void setup () {
Serial.begin (115200);

bool status = bmp.begin (0x76);
if (!status) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
/* Default settings from datasheet */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,
Adafruit_BMP280::SAMPLING_X2,
Adafruit_BMP280::SAMPLING_X16,
Adafruit_BMP280::FILTER_X16,
Adafruit_BMP280::STANDBY_MS_500);
// initialize LCD
lcd.init();
// turn on LCD backlight
lcd.backlight();
}
void loop () {
// set cursor to firat colunn, firet zow
lcd.setCursor(0, 0);
// print message
lcd.print("Temperature: ");
// set cursor to firat column, second row
lcd.setCursor(0, 1);
// print message
lcd.print(String(bmp.readTemperature()));
lcd.setCursor(6, 1);
lcd.print("*C");
delay(3000);
lcd.clear();

lcd.setCursor(0, 0);
lcd.print("Pressure: ");
lcd.setCursor(0, 1);
lcd.print(String(bmp.readPressure()));
lcd.setCursor(10, 1);
lcd.print("Pa");
delay(3000);
lcd.clear();

lcd.setCursor(0, 0);
lcd.print("Approx Altitude: ");
lcd.setCursor(0, 1);
lcd.print(String(bmp.readAltitude(1010)));
lcd.setCursor(6, 1);
lcd.print("m");
delay(3000);
lcd.clear();
}

--

--

--

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

Recommended from Medium

Getting on top of our technical challenges

Excerpt from Doctrine architecture documents

Introducing DevSpace Cloud: Turn any Kubernetes Cluster into a Powerful Developer Platform

Let’s have a coffee. Data Modeling of offers from Starbucks.

Eteesstore-Eteesstore Customer Care Number 8101439614=8927156725…Eteesstore-Eteesstore Customer…

Add custom metadata to image files

A bunch of tags

Advent of Code 2021 with Rust — Day 15

Asimov’s Three Laws Helped Shape A.I. and Robotics. We Need Four More.

Effective Cloud ETL in Cross-Cloud Setup — Part 1: Let Big Data Flow

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
Alvito Rizqi

Alvito Rizqi

More from Medium

Hofstra welcomes Eyewitness News ABC7 Long Island Bureau in new partnership

The .map method

What’s Next…Locusts??

Dlithe 22/04/2022 Experience