-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarometer-a.c
43 lines (34 loc) · 1.06 KB
/
barometer-a.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
This code is based on the BMP085 library by Stefan Sicklinger published on
http://www.sicklinger.com
I am redistributing this modified version under the GNU General Public
License version 3
*/
#include <avr/io.h>
#include <string.h>
#include <util/delay.h>
#include "uart.h"
#include "i2c.h"
#include "bmp.h"
int main(void)
{
int32_t temperature = 0;
int32_t pressure = 0;
uint8_t errorCode = 0;
// Call setup functions
uartSetup();
i2cSetup();
bmpCalibrate(&errorCode);
while (1)
{
bmpComputePressureAndTemperature(&temperature, &pressure, &errorCode);
//printf("Temperature: %ld (in 0.1 degress Celcius)\n", temperature);
printf("Temperature: %ld (in degress Celcius)\n", temperature/10);
printf("Pressure: %ld Pa\n", pressure);
//printf("Altitude: %ld dm\n", bmpComputeAltitude(pressure));
printf("Altitude: %ld m\n", bmpComputeAltitude(pressure)/10);
printf("Global error code: %d\n\n", errorCode);
_delay_ms(2000);
}
return 0;
}