Created
May 18, 2018 13:48
-
-
Save arduinothai/ec59feffb53f6896ac67016cff7a33b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include "SparkFunBME280.h" | |
BME280 mySensor; | |
void setup() | |
{ | |
Serial.begin(9600); | |
Serial.println("Reading basic values from BME280"); | |
Wire.begin(); | |
if (mySensor.beginI2C() == false) //Begin communication over I2C | |
{ | |
Serial.println("The sensor did not respond. Please check wiring."); | |
while(1); //Freeze | |
} | |
} | |
void loop() | |
{ | |
Serial.print("Humidity: "); | |
Serial.print(mySensor.readFloatHumidity(), 0); | |
Serial.print(" Pressure: "); | |
Serial.print(mySensor.readFloatPressure(), 0); | |
Serial.print(" Alt: "); | |
//Serial.print(mySensor.readFloatAltitudeMeters(), 1); | |
Serial.print(mySensor.readFloatAltitudeFeet(), 1); | |
Serial.print(" Temp: "); | |
Serial.print(mySensor.readTempC(), 2); | |
//Serial.print(mySensor.readTempF(), 2); | |
Serial.println(); | |
delay(50); | |
} | |
// ที่มา https://github.com/sparkfun/SparkFun_BME280_Arduino_Library |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment