123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- #ifndef BMP280_h
- #define BMP280_h
- #if defined(ARDUINO) && ARDUINO >= 100
- #include "Arduino.h"
- #else
- #include "WProgram.h"
- #endif
- class BMP280
- {
- public:
- BMP280();
- char begin();
- char begin(int sdaPin, int sclPin);
-
-
-
- short getOversampling(void);
- char setOversampling(short oss);
-
- char startMeasurment(void);
-
-
-
-
- char calcTemperature(double &T, double &uT);
-
-
- char calcPressure(double &P, double uP);
-
-
- double sealevel(double P, double A);
-
-
-
-
- double altitude(double P, double P0);
-
-
-
-
- char getError(void);
-
-
-
-
-
-
-
-
- char getTemperatureAndPressure(double& T,double& P);
- private:
-
- char readCalibration();
-
-
-
-
- char readInt(char address, double &value);
-
-
-
-
- char readUInt(char address, double &value);
-
-
-
-
- char readBytes(unsigned char *values, char length);
-
-
-
-
-
- char writeBytes(unsigned char *values, char length);
-
-
-
-
-
- char getUnPT(double &uP, double &uT);
-
-
-
-
-
- double dig_T1, dig_T2 , dig_T3 , dig_T4 , dig_P1, dig_P2 , dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9;
- short oversampling, oversampling_t;
- double t_fine;
- char error;
- };
- #define BMP280_ADDR 0x76
- #define BMP280_REG_CONTROL 0xF4
- #define BMP280_REG_RESULT_PRESSURE 0xF7
- #define BMP280_REG_RESULT_TEMPRERATURE 0xFA
- #define BMP280_COMMAND_TEMPERATURE 0x2E
- #define BMP280_COMMAND_PRESSURE0 0x25
- #define BMP280_COMMAND_PRESSURE1 0x29
- #define BMP280_COMMAND_PRESSURE2 0x2D
- #define BMP280_COMMAND_PRESSURE3 0x31
- #define BMP280_COMMAND_PRESSURE4 0x5D
- #define BMP280_COMMAND_OVERSAMPLING_MAX 0xF5
- #endif
|