Skip to content

Commit

Permalink
Fixed humidity plug errors. Changed default settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnerWill committed Jan 26, 2025
1 parent d7b730a commit cd8babf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ const unsigned char bitmap_image[] PROGMEM = {
};

#endif
//vim: filetype=arduino:shiftwidth=2:softtabstop=2:expandtab:nowrap:cursorline:cursorcolumn:number:relativenumber
//vim: filetype=arduino:shiftwidth=2:softtabstop=2:expandtab:nowrap:cursorline:cursorcolumn:number:relativenumber
10 changes: 5 additions & 5 deletions src/main/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// ============================================================================
// WIFI CONFIGURATION
constexpr char WIFI_SSID[] = ""; // Wi-Fi SSID
constexpr char WIFI_PASSWORD[] = ""; // Wi-Fi password
constexpr char WIFI_PASSWORD[] = "!"; // Wi-Fi password
constexpr char WIFI_HOSTNAME[] = "esp32-plant"; // Hostname
constexpr int WIFI_TIMEOUT_TIME = 30000; // Timeout if unable to connect to WiFi (ms)
constexpr int WIFI_CHECK_INTERVAL = 5000; // Check WiFi time (ms)
Expand All @@ -28,7 +28,7 @@ constexpr int SCREEN_WIDTH = 128; // OLED display width,
constexpr int SCREEN_HEIGHT = 64; // OLED display height, in pixels
constexpr uint8_t SCREEN_ADDRESS = 0x3C; // Address of OLED display (could also be '0x3D' depending on screen resolution)
constexpr int SCREEN_UPDATE_TIME = 1000; // Time to wait before updating OLED (ms)
constexpr int SCREEN_STARTUP_DISPLAY_TIME = 4000; // Startup screen delay time (ms)
constexpr int SCREEN_STARTUP_DISPLAY_TIME = 3000; // Startup screen delay time (ms)
bool SHOW_STARTUP = true; // Set to true to show the startup sequence
bool SHOW_BITMAP = true; // Set to true to show the bitmap
bool SHOW_CUSTOM_TEXT = true; // Set to true to show custom text
Expand All @@ -42,11 +42,11 @@ constexpr int INTERRUPT_BITMAP_TIME = 300000; // Check WiFi time (ms)
const char *intakePlugAlias = "tent1_intake"; // Kasa plug alias (Intake)
const char *exhaustPlugAlias = "tent1_exhaust"; // Kasa plug aliases (Exhaust)
const char *humidifierPlugAlias = "tent1_humidifier"; // Kasa plug aliases (Humidifier)
const char *lightPlugAlias = "tent1_light"; // Kasa plug aliases (Lights)
//const char *lightPlugAlias = "tent1_light"; // Kasa plug aliases (Lights)
constexpr int SMARTPLUG_UPDATE_TIME = 30000; // Update smart plugs time (ms)
bool FLOWER = false; // Set to true to set flower mode //TODO: Link this to a physical switch
constexpr float DESIRED_TEMP_VEG = 75.0; // Desired temperature in F (veg)
constexpr float DESIRED_HUMIDITY_VEG = 65.0; // Desired humidity in percentage (veg)
constexpr float DESIRED_HUMIDITY_VEG = 60.0; // Desired humidity in percentage (veg)
constexpr float DESIRED_CO2_VEG = 800.0; // Desired CO2 level (ppm) (veg)
constexpr float DESIRED_TEMP_FLOWER = 70.0; // Desired temperature in F (flower)
constexpr float DESIRED_HUMIDITY_FLOWER = 45.0; // Desired humidity in percentage (flower)
Expand All @@ -58,4 +58,4 @@ constexpr float CO2_HYSTERESIS = 100.0; // CO2 hysteresis
// SERIAL CONFIGURATION
constexpr int BAUD_RATE = 115200; // Baud rate
// ============================================================================
//vim: filetype=arduino:shiftwidth=2:softtabstop=2:expandtab:nowrap:cursorline:cursorcolumn:number:relativenumber
//vim: filetype=arduino:shiftwidth=2:softtabstop=2:expandtab:nowrap:cursorline:cursorcolumn:number:relativenumber
19 changes: 10 additions & 9 deletions src/main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ AsyncWebServer server(SERVER_PORT); // Define serv
KASAUtil kasaUtil; // Kasa utility object
KASASmartPlug *intakePlug = NULL; // Smart plug pointers (Intake)
KASASmartPlug *exhaustPlug = NULL; // Smart plug pointers (Exhaust)
KASASmartPlug *humidifierPlug = NULL; // Smart plug pointers (Humidifier)
// ============================================================================

// ============================================================================
Expand Down Expand Up @@ -124,12 +125,13 @@ void initSmartPlugs() {
exhaustPlug = plug;
Serial.println("Exhaust plug initialized.");
} else if (strcmp(plug->alias, humidifierPlugAlias) == 0) {
humidifierPlugAlias = plug;
humidifierPlug = plug;
Serial.println("Humidifier plug initialized.");
}
}

// Check if plugs were found
//TODO: Could clean this up
if (intakePlug == NULL) {
Serial.println("Error: Intake plug not found!");

Expand All @@ -148,7 +150,7 @@ void initSmartPlugs() {
display.display();
delay(1000);
}
if (humidifierPlugAlias == NULL) {
if (humidifierPlug == NULL) {
Serial.println("Error: Humidifier plug not found!");

display.clearDisplay();
Expand All @@ -162,8 +164,7 @@ void initSmartPlugs() {
// Function to turn a plug on or off
void setPlugState(KASASmartPlug* plug, bool state) {
// Setting variable for printing. otherwise dont need this
//TODO: Figure out how to turn this into a string
KASASmartPlug *plugAlias = kasaUtil.GetSmartPlug(plug->alias);
//KASASmartPlug *plugAlias = kasaUtil.GetSmartPlug(plug->alias);

if (plug == NULL) {
//Serial.printf("Error: Could not find plug with alias '%s'\n", plugAlias);
Expand Down Expand Up @@ -201,14 +202,14 @@ void handleTemperature(float temperatureF, float desiredTemp, const char* mode)
void handleHumidity(float humidity, float desiredHumidity, const char* mode) {
if (humidity > desiredHumidity + HUMIDITY_HYSTERESIS) { // Humidity too high
Serial.printf("Humidity too high in %s mode! Turning off humidifier...\n", mode); //
setPlugState(humidifierPlugAlias, false); // Turn off humidifier
setPlugState(humidifierPlug, false); // Turn off humidifier

} else if (humidity < desiredHumidity - HUMIDITY_HYSTERESIS) { // Humidity too low
Serial.printf("Humidity too low in %s mode! Turning on humidifier...\n", mode); //
setPlugState(humidifierPlugAlias, true); // Turn on humidifier
setPlugState(humidifierPlug, true); // Turn on humidifier

} else { // Humidity within range
setPlugState(humidifierPlugAlias, false); // Turn off humidifier to save energy
setPlugState(humidifierPlug, false); // Turn off humidifier to save energy
}
}

Expand Down Expand Up @@ -314,7 +315,7 @@ void showStart() {
int16_t y = (SCREEN_HEIGHT - text_h) / 2;

display.setCursor(x, y);
display.print(text);
display.print(STARTUP_TEXT);
display.display();
delay(SCREEN_STARTUP_DISPLAY_TIME);
display.clearDisplay();
Expand Down Expand Up @@ -531,4 +532,4 @@ void loop() {
}
}
// ============================================================================
//vim: filetype=arduino:shiftwidth=2:softtabstop=2:expandtab:nowrap:cursorline:cursorcolumn:number:relativenumber
//vim: filetype=arduino:shiftwidth=2:softtabstop=2:expandtab:nowrap:cursorline:cursorcolumn:number:relativenumber

0 comments on commit cd8babf

Please sign in to comment.