Help with Esp thermostat controls
im using a seeed studio xiao esp32c6 and im having issues with everything working basically i have a simple 16x2 i2c lcd, my esp, a level shifter, and 3 mechanical switches to control my system originally i was using a esp wroom 32 dev but im trying to get it as compact as possible with my limited resources so i got the esp32 c6 but when i change my code over the lcd lights up but i see none of my information that its supposed to show and only 1 of my switches partially work it only shows up in logs it doesnt even actually change my thermostat at all
these are the logs for the lcd
[22:57:52.439][C][logger:219]: Logger:
[22:57:52.439][C][logger:219]: Max Level: DEBUG
[22:57:52.439][C][logger:219]: Initial Level: DEBUG
[22:57:52.440][C][logger:226]: Log Baud Rate: 115200
[22:57:52.440][C][logger:226]: Hardware UART: USB_SERIAL_JTAG
[22:57:52.440][C][logger:235]: Task Log Buffer Size: 768 bytes
[22:57:52.455][C][i2c.idf:092]: I2C Bus:
[22:57:52.458][C][i2c.idf:093]: SDA Pin: GPIO6
[22:57:52.458][C][i2c.idf:093]: SCL Pin: GPIO7
[22:57:52.458][C][i2c.idf:093]: Frequency: 50000 Hz
[22:57:52.458][C][i2c.idf:103]: Recovery: bus successfully recovered
[22:57:52.458][C][i2c.idf:113]: Results from bus scan:
[22:57:52.463][C][i2c.idf:115]: Found no devices
[22:57:52.475][C][lcd_pcf8574:022]: PCF8574 LCD Display:
[22:57:52.475][C][lcd_pcf8574:022]: Columns: 16, Rows: 2
[22:57:52.476][C][lcd_pcf8574:026]: Address: 0x27
[22:57:52.476][C][lcd_pcf8574:451]: Update Interval: 1.0s
[22:57:52.480]
[E][lcd_pcf8574:029]: Communication failed
[22:57:52.480][E][component:224]: display is marked FAILED: unspecified
Heres the code it was written with a mix of claude and chat gpt and might not be entirely correct becasuse of the troubleshooting
esphome:
name: ac-controller
esp32:
board: seeed_xiao_esp32c6
framework:
type: esp-idf
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
api:
ota:
platform: esphome
# -------------------------
# HOME ASSISTANT INPUTS
# -------------------------
sensor:
- platform: homeassistant
id: room_temp
entity_id: sensor.ac_office_temperature_clean
unit_of_measurement: "°F"
- platform: homeassistant
id: target_temp
entity_id: climate.ac_office_thermostat
attribute: temperature
unit_of_measurement: "°F"
text_sensor:
- platform: homeassistant
id: hvac_mode_ha
entity_id: climate.ac_office_thermostat
- platform: homeassistant
id: hvac_action_ha
entity_id: climate.ac_office_thermostat
attribute: hvac_action
# -------------------------
# I2C BUS
# -------------------------
i2c:
sda: GPIO6
scl: GPIO7
scan: true
display:
- platform: lcd_pcf8574
dimensions: 16x2
address: 0x27
update_interval: 1s
lambda: |-
// --- Line 0: Room temp ---
if (!isnan(id(room_temp).state)) {
it.printf(0, 0, "Room: %.1fF", id(room_temp).state);
} else {
it.print(0, 0, "Room: --.-F");
}
// --- Line 1: Status ---
std::string action = id(hvac_action_ha).state;
std::string mode = id(hvac_mode_ha).state;
if (mode == "off") {
it.print(0, 1, "AC: OFF ");
} else if (action == "cooling") {
if (!isnan(id(target_temp).state)) {
it.printf(0, 1, "Cool->%.1fF ", id(target_temp).state);
} else {
it.print(0, 1, "Cooling... ");
}
} else if (action == "idle") {
if (!isnan(id(target_temp).state)) {
it.printf(0, 1, "Idle @%.1fF ", id(target_temp).state);
} else {
it.print(0, 1, "Idle ");
}
} else {
it.printf(0, 1, "%-16s", action.c_str());
}
# -------------------------
# BUTTONS
# -------------------------
binary_sensor:
# TEMP UP
- platform: gpio
pin:
number: GPIO2
mode: INPUT_PULLUP
inverted: true
name: Temp Up
filters:
- delayed_on: 50ms
on_press:
- homeassistant.service:
service: climate.set_temperature
data:
entity_id: climate.ac_office_thermostat
temperature: !lambda |-
return id(target_temp).state + 1;
# TEMP DOWN
- platform: gpio
pin:
number: GPIO3
mode: INPUT_PULLUP
inverted: true
name: "Temp Down"
filters:
- delayed_on: 50ms
on_press:
- homeassistant.service:
service: climate.set_temperature
data:
entity_id: climate.ac_office_thermostat
temperature: !lambda |-
return id(target_temp).state - 1;
# TOGGLE
- platform: gpio
pin:
number: GPIO4
mode: INPUT_PULLUP
inverted: true
name: "AC Toggle"
filters:
- delayed_on: 50ms
on_press:
- if:
condition:
lambda: 'return id(hvac_mode_ha).state == "cool";'
then:
- homeassistant.service:
service: climate.set_hvac_mode
data:
entity_id: climate.ac_office_thermostat
hvac_mode: "off"
else:
- if:
condition:
lambda: 'return id(hvac_mode_ha).state != "";'
then:
- homeassistant.service:
service: climate.set_hvac_mode
data:
entity_id: climate.ac_office_thermostat
hvac_mode: "cool"