Add bme280 library
This commit is contained in:
+6
-3
@@ -8,7 +8,10 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:miniatmega328]
|
||||
[env:pro16MHzatmega328]
|
||||
platform = atmelavr
|
||||
board = miniatmega328
|
||||
framework = arduino
|
||||
board = pro16MHzatmega328
|
||||
monitor_speed = 115200
|
||||
lib_deps =
|
||||
https://github.com/Sylaina/bme280.git
|
||||
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (C) PlatformIO <contact@platformio.org>
|
||||
* See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#include "bme280.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// make the LED pin an output for PORTB5
|
||||
DDRB = 1 << 5;
|
||||
|
||||
float temp = 0.0;
|
||||
float pressure = 0.0;
|
||||
float humidity = 0.0;
|
||||
|
||||
bme280_init(0);
|
||||
|
||||
temp = bme280_readTemperature(0);
|
||||
pressure = bme280_readPressure(0);
|
||||
humidity = bme280_readHumidity(0);
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
_delay_ms(1000);
|
||||
|
||||
printf("Temp: %f\tPressure: %f\tHumidity: %f\n", temp, pressure, humidity);
|
||||
|
||||
// toggle the LED
|
||||
PORTB ^= 1 << 5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user