-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
executable file
·56 lines (42 loc) · 975 Bytes
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
/* Name: main.c
* Author: <insert your name here>
* Copyright: <insert your copyright message here>
* License: <insert your license reference here>
*/
#include <bme280.h>
#include <ftoa.h>
int main(void)
{
init_uart(57600);
i2c_init();
init();
for(;;)
{
float a = bme280_readTemperature();
float b = bme280_readPressure();
float c = bme280_readHumidity();
float d = bme280_readAltitude(1013.25);
char buf[10];
uart_puts("Temperature: ");
ftoa( buf, a, 2);
uart_puts(buf);
uart_puts("C ");
uart_puts("Pressure: ");
ftoa( buf, b, 2);
uart_puts(buf);
uart_puts(" ");
uart_puts("Humidity: ");
ftoa( buf, c, 2);
uart_puts(buf);
uart_puts("% ");
uart_puts("Altitude: ");
ftoa( buf, d, 2);
uart_puts(buf);
uart_puts("\n\r");
PORTB = 0xFF;
_delay_ms(500);
PORTB = 0x00;
_delay_ms(1000);
}
return 0; /* never reached */
}