BMP085.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Barometer.h
  3. A library for barometer
  4. Copyright (c) 2012 seeed technology inc.
  5. Website : www.seeed.cc
  6. Author : LG
  7. Create Time:
  8. Change Log :
  9. loovee 9-24-2014
  10. Change all int to short, all unsigned int to unsigned short to fit some 32bit system
  11. The MIT License (MIT)
  12. Permission is hereby granted, free of charge, to any person obtaining a copy
  13. of this software and associated documentation files (the "Software"), to deal
  14. in the Software without restriction, including without limitation the rights
  15. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16. copies of the Software, and to permit persons to whom the Software is
  17. furnished to do so, subject to the following conditions:
  18. The above copyright notice and this permission notice shall be included in
  19. all copies or substantial portions of the Software.
  20. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26. THE SOFTWARE.
  27. */
  28. #ifndef __BMP085_H__
  29. #define __BMP085_H__
  30. #include <Arduino.h>
  31. #include <Wire.h>
  32. const unsigned char OSS = 0;
  33. #define BMP085_ADDRESS 0x77
  34. class BMP085 {
  35. public:
  36. void init(void);
  37. long PressureCompensate;
  38. float bmp085GetTemperature(unsigned short ut);
  39. long bmp085GetPressure(unsigned long up);
  40. float calcAltitude(float seaLevelPressure = 101325);
  41. unsigned short bmp085ReadUT(void);
  42. unsigned long bmp085ReadUP(void);
  43. private:
  44. short ac1;
  45. short ac2;
  46. short ac3;
  47. unsigned short ac4;
  48. unsigned short ac5;
  49. unsigned short ac6;
  50. short b1;
  51. short b2;
  52. short mb;
  53. short mc;
  54. short md;
  55. char bmp085Read(unsigned char address);
  56. short bmp085ReadInt(unsigned char address);
  57. void writeRegister(short deviceAddress, byte address, byte val);
  58. short readRegister(short deviceAddress, byte address);
  59. };
  60. #endif