Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Created May 18, 2018 15:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arduinothai/4067d1ba1f747677e7fa08c932bd8e76 to your computer and use it in GitHub Desktop.
Save arduinothai/4067d1ba1f747677e7fa08c932bd8e76 to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 test"));
if (!bmp.begin(0x76)) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (1);
}
}
void loop() {
Serial.print(F("Temperature = "));
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print(F("Approx altitude = "));
Serial.print(bmp.readAltitude(1013.25)); // this should be adjusted to your local forcase
Serial.println(" m");
Serial.println();
delay(2000);
}
// ที่มา https://github.com/adafruit/Adafruit_BMP280_Library
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment