BMP085.h 2.2 KB

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