AVRly - AVR Development Resources
main.c File Reference

Example main routine to demonstrate taking readings using the CCS811 gas sensor.
More...

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

Go to the source code of this file.

Functions

int main ()
 

Variables

ccs811_config_t ccs811_config
 

Detailed Description

Example main routine to demonstrate taking readings using the CCS811 gas 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
15th March 2022
See also

Definition in file main.c.

Function Documentation

◆ main()

int main ( )

Definition at line 51 of file main.c.

52{
53 // Setup
55 uint8_t error = init_ccs811(&ccs811_config);
56 log_message_with_dec_val(p_system_tag, ERROR,
57 "CCS81 init return code: ", error);
58 // Loop forever
59 for(;;)
60 {
62 {
63 eco2 = ccs811_get_eco2_level();
64 log_message_with_16bit_dec_val(p_system_tag, DEBUG, "eCo2 Level: ", eco2);
65
66 etvoc = ccs811_get_etvoc_level();
67 log_message_with_16bit_dec_val(p_system_tag, DEBUG, "eTVOC Level: ", etvoc);
68 }
69 }
70}
uint16_t ccs811_get_etvoc_level(void)
Read eTVOC (equivalent total volatile organic compounds) level from sensor.
Definition: ccs811.c:189
uint16_t ccs811_get_eco2_level(void)
Read eCO2 (equivalent carbon dioxide) level from sensor.
Definition: ccs811.c:182
uint8_t init_ccs811(ccs811_config_t *p_config)
Initialisation routine (run once at startup).
Definition: ccs811.c:133
bool ccs811_data_ready_check(void)
Read the status register and check if the data ready flag is set.
Definition: ccs811.c:200
void init_log_system(void)
Initialisation routine - call this function once at startup before using other functions.
Definition: log_system.c:46

Variable Documentation

◆ ccs811_config

ccs811_config_t ccs811_config
Initial value:
=
{
.drive_mode = drive_mode_1sec,
.wake_pin_enabled = true,
.interrupt_dataready = false,
.interrupt_threshold = false,
}

Definition at line 43 of file main.c.