AVRly - AVR Development Resources

Example main routine demonstrating the BME280 sensor. More...

#include <util/delay.h>
#include "bme280.h"
#include "log_system.h"

Go to the source code of this file.

Functions

int main ()
 

Variables

int16_t temperature = 0
 
uint16_t humidity = 0
 
int8_t neg_val = -43
 
int8_t pos_val = 56
 
int8_t zer_val = 0
 
log_system_config_t log_system_main
 

Detailed Description

Example main routine demonstrating the BME280 sensor.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
Jason Duffy
Date
22nd June 2022

Definition in file main.c.

Function Documentation

◆ main()

int main ( )

Definition at line 52 of file main.c.

53{
54 // Initialisations & Setup
59
60 // Superloop
61 while (1)
62 {
63 temperature = bme280_get_temperature();
64 humidity = bme280_get_humidity();
65 /*
66 log_message_with_16bit_unsigned_val(&log_system_main,
67 INFO,
68 "Temperature: ",
69 temperature,
70 DECIMAL);
71
72 log_message_with_16bit_unsigned_val(&log_system_main,
73 INFO,
74 "Humidity: ",
75 humidity,
76 DECIMAL);
77 */
78 _delay_ms(1000);
79 log_message_with_8bit_signed_val(&log_system_main,
80 INFO,
81 "Signed variable: ",
82 neg_val,
83 DECIMAL);
84
85 log_message_with_8bit_signed_val(&log_system_main,
86 INFO,
87 "Signed variable: ",
88 pos_val,
89 DECIMAL);
90
91 log_message_with_8bit_signed_val(&log_system_main,
92 INFO,
93 "Signed variable: ",
94 zer_val,
95 DECIMAL);
96 }
97
98 return 0;
99}
uint16_t bme280_get_humidity(void)
Fetches the latest humidity data from the sensor, compensates and formats the data as RH * 100.
Definition: bme280.c:207
void init_bme280(void)
Initialise the device ready for measurements to be taken.
Definition: bme280.c:125
int16_t bme280_get_temperature(void)
Fetches the latest temperature data from the sensor, compensates and formats the data in degrees Celc...
Definition: bme280.c:164
void log_global_on(void)
Turns logging system on globally.
Definition: log_system.c:133
void init_log_system(void)
Initialisation routine - call this function once at startup before using other functions.
Definition: log_system.c:46
void log_set_global_max_output_level(log_type_t level)
Sets maximum output level of logging required, has global effect.
Definition: log_system.c:229
void log_message_with_8bit_signed_val(log_system_config_t *p_config, log_type_t level, const char *msg, int8_t val, format_type_t format)
Sends a string, followed by an 8 bit value.
Definition: log_system.c:118

Variable Documentation

◆ temperature

int16_t temperature = 0

Definition at line 37 of file main.c.

◆ humidity

uint16_t humidity = 0

Definition at line 38 of file main.c.

◆ neg_val

int8_t neg_val = -43

Definition at line 40 of file main.c.

◆ pos_val

int8_t pos_val = 56

Definition at line 41 of file main.c.

◆ zer_val

int8_t zer_val = 0

Definition at line 42 of file main.c.

◆ log_system_main

log_system_config_t log_system_main
Initial value:
=
{
.p_system_tag = "Main",
.file_log_level = DEBUG,
}

Definition at line 44 of file main.c.