#include "config.h" #include "sensor.h" #include "wlan.h" #include #include #include #include WiFiClient wifi_client; PubSubClient mqtt_client(wifi_client); SensirionI2cScd4x sensor; int error_code; char error_msg[64]; const char *config_file_path = "/config.json"; Config *config; void setup() { Serial.begin(9600); config = (Config *)malloc(sizeof(Config)); if (!load_config_file(config_file_path, config)) Serial.println("ERROR: The config file could not be loaded"); connect_wlan(config); initialize_sensor(sensor, error_code, error_msg); } void loop() { float data[3]; read_values(sensor, data, error_code, error_msg); mqtt_transfer(mqtt_client, config, data); delay(config->sleep_time); }