add input for Burner Error

This commit is contained in:
Hendrik Schutter 2024-12-07 18:37:09 +01:00
parent 9ac3792c6c
commit 3c5f0835f5
4 changed files with 147 additions and 36 deletions

View File

@ -16,7 +16,8 @@ Control <|-- HTTP_Metrics
Safety <|-- HTTP_Metrics
class Inputs{
+loop()
+ initInputs()
-loop()
+getChamberTemperature()
+getOutdoorTemperature()
+getInletFlowTemperature()
@ -59,3 +60,4 @@ Safety <|-- HTTP_Metrics
|------------------|-----------------|------------------|
| CirculationPump | IO27 | Relay 1 NO1 |
| Burner | IO14 | Relay 1 NC2 |
| Burner Fault | IO19 | Digital Input IN1 |

View File

@ -0,0 +1,83 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "inputs.h"
static const char *TAG = "smart-oil-heater-control-system-inputs";
const uint8_t uBurnerFaultPin = 19U;
static eBurnerErrorState sBurnerErrorState;
void loop(void *pvParameters);
void initInputs(void)
{
gpio_config_t ioConfBurnerFault = {
.pin_bit_mask = (1ULL << uBurnerFaultPin), // Pin mask
.mode = GPIO_MODE_INPUT, // Set as inout
.pull_up_en = GPIO_PULLUP_ENABLE, // Enable pull-up
.pull_down_en = GPIO_PULLDOWN_DISABLE, // Disable pull-down
.intr_type = GPIO_INTR_DISABLE // Disable interrupts
};
gpio_config(&ioConfBurnerFault);
BaseType_t taskCreated = xTaskCreate(
loop, // Function to implement the task
"loop_inputs", // Task name
2048, // Stack size (in words, not bytes)
NULL, // Parameters to the task function (none in this case)
5, // Task priority (higher number = higher priority)
NULL // Task handle (optional)
);
if (taskCreated == pdPASS)
{
ESP_LOGI(TAG, "Task created successfully!");
}
else
{
ESP_LOGE(TAG, "Failed to create task");
}
}
void loop(void *pvParameters)
{
// This task will run in a loop
while (1)
{
ESP_LOGI(TAG, "Running task Input...");
vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay for 1 second
if (gpio_get_level(uBurnerFaultPin) == 1)
{
sBurnerErrorState = FAULT;
}
else
{
sBurnerErrorState = NO_ERROR;
}
}
}
float getChamberTemperature(void)
{
return 42.42;
}
float getOutdoorTemperature(void)
{
return 42.42;
}
float getInletFlowTemperature(void)
{
return 42.42;
}
float getReturnFlowTemperature(void)
{
return 42.42;
}
eBurnerErrorState getBurnerError(void)
{
return sBurnerErrorState;
}

View File

@ -0,0 +1,13 @@
#pragma once
typedef enum _BurnerErrorState{
NO_ERROR,
FAULT
} eBurnerErrorState;
void initInputs(void);
float getChamberTemperature(void);
float getOutdoorTemperature(void);
float getInletFlowTemperature(void);
float getReturnFlowTemperature(void);
eBurnerErrorState getBurnerError(void);

View File

@ -13,6 +13,7 @@
#include "http_metrics.h"
#include "outputs.h"
#include "inputs.h"
#define I2C_MASTER_SCL 19
#define I2C_MASTER_SDA 18
@ -41,6 +42,7 @@ void app_main(void)
ESP_ERROR_CHECK(i2cdev_init());
initOutputs();
initInputs();
ESP_LOGI(TAG, "running");
@ -60,6 +62,16 @@ void app_main(void)
vSetMetrics(aMetrics, u16MetricCounter);
if (getBurnerError() == FAULT)
{
ESP_LOGI(TAG, "Burner FAULT");
}
else
{
ESP_LOGI(TAG, "Burner OK");
}
/*
setCirculationPumpState(ENABLED);
setBurnerState(ENABLED);
@ -103,5 +115,6 @@ void app_main(void)
{
ESP_LOGI(TAG, "CirculationPump DISABLED");
}
*/
}
}