ESP-IDF v5.3.2 firmware for the CrowPanel 2.1" rotary display. Builds clean;
nothing has been run on hardware yet.
Hardware verified against Elecrow's own source for this board and
cross-checked against their ESPHome config, per PRD 8.1. Three corrections to
the PRD's pinout, all documented in docs/HARDWARE.md:
- touch is CST826 at 0x15, not CST816 (chip ID reads 0x11, not 0xB4)
- the ST7701S needs a 3-wire SPI bus on GPIO 16/2/1 that the PRD omitted;
without it the init sequence cannot be sent and the panel stays black
- the backlight is GPIO6
Two further departures from the PRD, both forced by facts on the ground:
- Transport is MQTT, not HTTP. zigbee2mqtt has no REST endpoint for live
sensor state. Subscribing to the broker also gets retained topics, so
every room's last reading arrives on connect rather than after a poll.
- The furnace is 2-wire R/W with no C, not 3-wire. The board needs its own
5V supply. The thermostat's 5 CPH setting is enforced as a minimum
12-minute period between heat-call starts, which a minimum off-time alone
does not achieve.
All of PRD section 5 is implemented in the relay layer itself: fail-open,
watchdog-gated output, max on-time, min off-time, cycle-rate limit, startup
lockout, and the stale-data fallback ladder down to open-loop freeze
protection. The one gap that cannot be closed in software — the PCF8574 not
resetting when the ESP32 does — is documented rather than papered over.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
31 lines
904 B
C
31 lines
904 B
C
/*
|
|
* i2c_bus — single owner of the board's I2C bus.
|
|
*
|
|
* SDA 38 / SCL 39, shared by the PCF8574 expander (0x21) and the CST826 touch
|
|
* controller (0x15). The I2C connector on the case brings the same bus out, so
|
|
* anything added later lands here too.
|
|
*/
|
|
#pragma once
|
|
|
|
#include "driver/i2c_master.h"
|
|
#include "esp_err.h"
|
|
|
|
#define I2C_BUS_SDA_GPIO 38
|
|
#define I2C_BUS_SCL_GPIO 39
|
|
#define I2C_BUS_FREQ_HZ 400000
|
|
|
|
/* Initialise the bus. Safe to call more than once. */
|
|
esp_err_t i2c_bus_init(void);
|
|
|
|
/* Add a device to the shared bus. */
|
|
esp_err_t i2c_bus_add_device(uint8_t addr, i2c_master_dev_handle_t *out);
|
|
|
|
/*
|
|
* Probe every address and log what answers.
|
|
*
|
|
* PRD 8.1: this is the cheap sanity check that tells you the board is alive
|
|
* and the I2C pins are right, independently of the display. Expect 0x21 and
|
|
* 0x15. Returns the number of devices found.
|
|
*/
|
|
int i2c_bus_scan(void);
|