Files
AQS-FW/main.cpp

99 lines
2.1 KiB
C++

/*
Particulate Matter Sensor firmware (ESP32 version)
Written by Jonathan Oxer for www.superhouse.tv
https://github.com/superhouse/PM25SensorESP32
refactored by Willem Oldemans
Read from a Plantower PMS7003 particulate matter sensor and a BME680
environmental sensosr using an ESP32, and report the values to an MQTT
broker and show them on a 240x240 LCD, with a mode button to change
between display modes.
External dependencies. Install using the Arduino library manager:
"Adafruit GFX Library" by Adafruit
TFT_eSPI.h
Adafruit_NeoPixel.h
Adafruit_Sensor.h
Adafruit_BME680.h
AdaFruit_SCD30.h
"PubSubClient" by Nick O'Leary
RunningMedian
Bundled dependencies. No need to install separately:
"PMS Library" by Mariusz Kacki, forked by SwapBap
Inspired by https://github.com/SwapBap/WemosDustSensor/
*/
#define VERSION "3"
/*--------------------------- Configuration ------------------------------*/
// Configuration should be done in the included file:
#include "Arduino.h"
#include "config.h"
/*--------------------------- Modules ------------------------------------*/
#include "lcd.h"
#include "mqtt.h"
#include "sensor.h"
#include "particles.h"
#include "CO2_sensor.h"
#include "VOC_sensor.h"
#include "button.h"
#include "esp_ota.h"
/*--------------------------- Program ---------------------------------------*/
/**
Setup
*/
void setup()
{
Serial.begin(SERIAL_BAUD_RATE);
Serial.println();
Serial.print("Air Quality Sensor starting up, v");
Serial.println(VERSION);
ProgressbarVisible(true);
initLCD();
setOTAProgress(10);
initButtons();
setOTAProgress(20);
initWifi();
setOTAProgress(30);
initEspOta();
setOTAProgress(40);
initMQTT();
setOTAProgress(50);
initSensor();
setOTAProgress(60);
initParticles();
setOTAProgress(70);
initCO2sensor();
setOTAProgress(80);
initVOCsensor();
setOTAProgress(90);
ProgressbarVisible(false);
}
/**
Main loop
*/
void loop()
{
handleParticles();
handleCO2sensor();
handleVOCsensor();
handleButtons();
handleSensor();
handleLCD();
handleMQTT();
handleEspOta();
}