Arduino-TWI
Two-Wire Interface (TWI) library for Arduino
BMP085.ino
Go to the documentation of this file.
1 #include "TWI.h"
2 #include "Driver/BMP085.h"
3 #include "assert.h"
4 
5 // Configure: TWI bus manager (software or hardware)
6 // #define USE_SOFTWARE_TWI
7 
8 #if defined(USE_SOFTWARE_TWI)
9 #include "GPIO.h"
10 #include "Software/TWI.h"
12 #else
13 // Configure: Hardware TWI bus clock frequency (100 or 400 kHz)
14 #include "Hardware/TWI.h"
15 Hardware::TWI twi(100000UL);
16 // Hardware::TWI twi(400000UL);
17 #endif
18 
19 BMP085 bmp(twi);
20 
21 void setup()
22 {
23  Serial.begin(57600);
24  while (!Serial);
25 
26  // Start the digital pressure sensor
28 }
29 
30 void loop()
31 {
32  // Print start time and sampled values
33  uint32_t start = millis();
34  Serial.print(start / 1000.0);
35  Serial.print(':');
36 
37  // Sample, calculate and print temperature and pressure
38  ASSERT(bmp.sample());
39  Serial.print(bmp.temperature() / 10.0);
40  Serial.print(F(" C, "));
41  Serial.print(bmp.pressure() / 100.0);
42  Serial.println(F(" hPa"));
43 
44  // Periodic execute every two seconds
45  delay(2000 - (millis() - start));
46 }
void setup()
Definition: BMP085.ino:21
bool begin(Mode mode=ULTRA_LOW_POWER)
Definition: BMP085.h:81
void loop()
Definition: BMP085.ino:30
int32_t pressure() const
Definition: BMP085.h:285
Hardware::TWI twi(100000UL)
bool sample()
Definition: BMP085.h:264
int16_t temperature() const
Definition: BMP085.h:274
BMP085 bmp(twi)
Definition: BMP085.h:50