Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
BMP180.h
1 /*
2 BMP180.h - Header file for the BMP180 Barometric Pressure Sensor Arduino Library.
3 Copyright (C) 2012 Love Electronics Ltd (loveelectronics.com)
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the version 3 GNU General Public License as
7 published by the Free Software Foundation.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17  Datasheet for BMP180:
18  http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP180-DS000-07.pdf
19 
20 */
21 
22 #ifndef BMP180_h
23 #define BMP180_h
24 
25 #include <inttypes.h>
26 
27 #include "../../SmingCore/Wire.h"
28 
29 #define BMP180_Address 0x77
30 
31 #define ChipIdData 0x55
32 #define ControlInstruction_MeasureTemperature 0x2E
33 #define ControlInstruction_MeasurePressure 0x34
34 
35 #define Reg_ChipId 0xD0
36 #define Reg_Control 0xF4
37 #define Reg_CalibrationStart 0xAA
38 #define Reg_CalibrationEnd 0xBE
39 #define Reg_AnalogConverterOutMSB 0xF6
40 #define Reg_SoftReset 0xE0
41 #define SoftResetInstruction 0xB6
42 
43 #define ErrorCode_1 "Entered sample resolution was invalid. See datasheet for details."
44 #define ErrorCode_1_Num 1
45 
46 #define BMP180_Mode_UltraLowPower 0
47 #define BMP180_Mode_Standard 1
48 #define BMP180_Mode_HighResolution 2
49 #define BMP180_Mode_UltraHighResolution 3
50 
51 class BMP180
52 {
53  public:
54  BMP180();
55 
56  void Initialize(void);
57 
58  int GetUncompensatedTemperature();
59  float CompensateTemperature(int uncompensatedTemperature);
60 
61  long GetUncompensatedPressure();
62  long CompensatePressure(long uncompensatedPressure);
63 
64  float GetTemperature();
65  long GetPressure();
66 
67  //float GetAltitude(float currentSeaLevelPressureInPa);
68 
69  void SoftReset();
70  uint8_t SetResolution(uint8_t sampleResolution, bool oversample);
71 
72  void PrintCalibrationData();
73 
74  uint8_t EnsureConnected();
75  uint8_t IsConnected;
76  const char* GetErrorText(int errorCode);
77  protected:
78  void Write(int address, int byte);
79  uint8_t* Read(int address, int length);
80  void Read2(int address, int length, uint8_t buffer[]);
81  private:
82  uint8_t OversamplingSetting;
83  bool Oversample;
84  int16_t ConversionWaitTimeMs;
85  int16_t LastTemperatureData;
86  int16_t LastTemperatureTime;
87  int16_t AcceptableTemperatureLatencyForPressure;
88 
89  int16_t Calibration_AC1;
90  int16_t Calibration_AC2;
91  int16_t Calibration_AC3;
92  unsigned int Calibration_AC4;
93  unsigned int Calibration_AC5;
94  unsigned int Calibration_AC6;
95  int16_t Calibration_B1;
96  int16_t Calibration_B2;
97  int16_t Calibration_MB;
98  int16_t Calibration_MC;
99  int16_t Calibration_MD;
100  uint8_t buffer[64];
101 };
102 #endif
Definition: BMP180.h:51