embernet project fire detection system sensor test
Dependencies: mbed CCS811 BME280
main.cpp
- Committer:
- cege1808
- Date:
- 2019-03-08
- Revision:
- 1:91de8a17fbea
- Parent:
- 0:24692a601d5e
File content as of revision 1:91de8a17fbea:
#include "mbed.h"
#include "BME280.h"
#include "CCS811.h"
#include "Adafruit_SGP30.h"
#include <iostream>
using namespace std;
/*------------------------------------------------------------------------------
Before to use this example, ensure that you an hyperterminal installed on your
computer. More info here: https://developer.mbed.org/handbook/Terminals
The default serial comm port uses the SERIAL_TX and SERIAL_RX pins (see their
definition in the PinNames.h file).
The default serial configuration in this case is 9600 bauds, 8-bit data, no parity
If you want to change the baudrate for example, you have to redeclare the
serial object in your code:
Serial pc(SERIAL_TX, SERIAL_RX);
Then, you can modify the baudrate and print like this:
pc.baud(115200);
pc.printf("Hello World !\n");
------------------------------------------------------------------------------*/
Serial pc(SERIAL_TX, SERIAL_RX);
I2C i2c(PB_7, PB_8);
DigitalOut led(LED1);
//BME280 bme(PB_7, PB_8);
//Adafruit_SGP30 sgp(PB_7, PB_8);
CCS811 ccs(i2c, pc);
uint16_t eco2, tvoc;
//float temp, hum, pres;
void CCS811Initialize(void){
bool ccs_status = false;
while(ccs_status == false){
printf("Initialize CCS811 \n");
ccs.init();
ccs_status = !ccs.checkHW();
cout << "CCS Status: " << ccs_status << endl;
}
}
void CCS811Callback(void){
ccs.readData(&eco2, &tvoc);
printf("eCO2 reading :%dppm, TVOC reading :%dppb\r\n", eco2, tvoc);
}
//void BME280Initialize(void){
// bool bme_status = false;
// while(bme_status == false){
// printf("Initialize BME280 \n");
// bme.initialize();
// bme_status = true;
// wait(3);
// }
//}
//
//
//void BME280Callback(void){
//bme.start();
// cout << "BME Read Status: " << bme.get(temp, pres, hum);
// bme.stop();
// cout << "Temperature: " << temp << " Pressure: " << pres << " Humidity: " << hum << endl;
// cout << "Temperature: " << bme.getTemperature() ;
// cout << " Pressure: " << bme.getPressure();
// cout << " Humidity: " << bme.getHumidity() << "\r"<< endl;
//}
//void SGP30Initialize(void){
// bool sgp_status = false;
// while(sgp_status == false){
// printf("Initialize SGP30 \n");
// sgp.begin();
// sgp_status = sgp.IAQinit();
// wait(3);
// }
//}
//
//void SGP30Callback(void){
// sgp.IAQmeasure();
// cout << "eCO2: " << sgp.eCO2 << " ppm";
// cout << " TVOC: " << sgp.TVOC << " ppb \r" << endl;
//}
int main()
{
printf("Hello World !\n");
// SGP30Initialize();
// BME280Initialize();
CCS811Initialize();
while(true) {
wait(3); // second
led = !led; // Toggle LED
// BME280Callback();
// SGP30Callback();
CCS811Callback();
}
}