esp32-warm-water
esp32 based project for the control of a heating element based on temperature
Functions | Variables
main.c File Reference

main entrypoint for the warm-water project More...

#include <stdio.h>
#include <stdbool.h>
#include "sdkconfig.h"
#include "led.h"
#include "wifi_sta.h"
#include "wifi_sap.h"
#include "utility.h"
#include "ds18b20_wrapper.h"
#include "timer.h"
#include "ssd1306.h"
#include "symbols.h"
#include "esp_log.h"
#include "control.h"
#include "spiffs.h"
#include "webserver.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

void update_display (void)
 
void relay_on (void)
 
void relay_off (void)
 
void check_system_handler (void *arg)
 
void check_relay (float average_temp)
 
void app_deinit (void)
 
void app_main (void)
 

Variables

char ip_address [16]
 
volatile float goal = CONFIG_INITIAL_GOAL_TEMP
 goal temp for the system to aim for More...
 
volatile float temp = 0.0f
 current temp More...
 
volatile float under = 0.5f
 margin below goal temp at which to turn relay on More...
 
volatile float over = 0.5f
 margin above goal temp at which to turn relay off More...
 
volatile bool heating = false
 whether or not the system should be outputing a signal to enable the relay (note: could be used to control pump as well) More...
 
int num_sensors = 0
 the number of sensors ds18b20 init has found (initially 0) More...
 
esp_timer_handle_t periodic_check_timer
 variable to control the timer associated with running the temperature polling to check system More...
 
SSD1306_t dev
 device for oled More...
 

Detailed Description

main entrypoint for the warm-water project

Author
wolffshots

esp-idf warm-water project.

employs wifi, onewire and a relay to control the temperature of a body of water for the purpose of film development primarily. other uses include cooking and general chemistry.

the main motivation to do this project was to be able to better process c41 colour film.

Definition in file main.c.

Function Documentation

◆ app_deinit()

void app_deinit ( void  )

free resources and ensure safe shutdown of app

< cleanup timer associated with checking temp and relay

< relay off and deinit gpio

< deallocate owb and ds18b20

< deallocate i2c and ssd1306

< wifi off and deinit

< disable spiffs

Definition at line 177 of file main.c.

Here is the call graph for this function:

◆ app_main()

void app_main ( void  )

main method that is run by default (similar to arduino style setup)

Definition at line 191 of file main.c.

Here is the call graph for this function:

◆ check_relay()

void check_relay ( float  average_temp)

check if a change in the relay's operation is necessary and perform it if so

Todo:
average results/check difference between sensors if multiple here

Definition at line 149 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_system_handler()

void check_system_handler ( void *  arg)

polls the ds18b20 sensor for it's latest temperatures and checks what range we are in with respect to the goal and sets the output to the relay accordingly

Parameters
argvoid pointer mainly because that's the fingerprint that the isr expects. a void pointer holds some address to an unknown type. read more at: https://www.geeksforgeeks.org/void-pointer-c-cpp/

< create correctly sized float array for the sensor data

< average temp across sensors (for now =results[0] until we have averaging is implemented)

Definition at line 134 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ relay_off()

void relay_off ( void  )

turn the relay off

Definition at line 119 of file main.c.

Here is the caller graph for this function:

◆ relay_on()

void relay_on ( void  )

turn the relay on

Definition at line 112 of file main.c.

Here is the caller graph for this function:

◆ update_display()

void update_display ( void  )

Definition at line 86 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ dev

SSD1306_t dev

device for oled

Definition at line 81 of file main.c.

◆ goal

volatile float goal = CONFIG_INITIAL_GOAL_TEMP

goal temp for the system to aim for

Definition at line 71 of file main.c.

◆ heating

volatile bool heating = false

whether or not the system should be outputing a signal to enable the relay (note: could be used to control pump as well)

Definition at line 75 of file main.c.

◆ ip_address

char ip_address[16]

Definition at line 54 of file main.c.

◆ num_sensors

int num_sensors = 0

the number of sensors ds18b20 init has found (initially 0)

Definition at line 78 of file main.c.

◆ over

volatile float over = 0.5f

margin above goal temp at which to turn relay off

Definition at line 74 of file main.c.

◆ periodic_check_timer

esp_timer_handle_t periodic_check_timer

variable to control the timer associated with running the temperature polling to check system

Definition at line 79 of file main.c.

◆ temp

volatile float temp = 0.0f

current temp

Definition at line 72 of file main.c.

◆ under

volatile float under = 0.5f

margin below goal temp at which to turn relay on

Definition at line 73 of file main.c.