docs: add hardware bring-up sketches, known-issues note, and tablet reference
Standalone Arduino test sketches for IS31FL3193 LED driver and PCF8575/PCF8574 relay bring-up (not part of the PlatformIO build), a known-issues note, and two Dart files from the tablet app kept as reference for the comms protocol. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* ═══════════════════════════════════════════════════════════════════════════════
|
||||
* pcf_22_relay_sequence_test.ino — Combined bring-up test: onboard 6 + external 16
|
||||
* ═══════════════════════════════════════════════════════════════════════════════
|
||||
*
|
||||
* TEMPORARY TEST SKETCH — not part of the Vesper firmware build.
|
||||
* Open directly in Arduino IDE and flash it on its own (does NOT go through
|
||||
* PlatformIO / src/main.cpp). Delete once both chips are verified.
|
||||
*
|
||||
* Purpose: treat the board as one 22-relay unit —
|
||||
* - Outputs 0-5 = onboard PCF8574 (KC868-A6 relays, 6ch)
|
||||
* - Outputs 6-21 = external PCF8575 (your 16ch expansion board)
|
||||
*
|
||||
* Sequence:
|
||||
* 1. Fire all 22 relays in order, one at a time (onboard 1-6, then external 1-16).
|
||||
* 2. Flash all 22 relays together ALL_FLASH_COUNT times (on/off/on/off...).
|
||||
* 3. Repeat forever.
|
||||
*
|
||||
* Hardware:
|
||||
* - Board: Kincony KC868-A6 (ESP32-D0WD-V3)
|
||||
* - I2C bus: SDA = GPIO4, SCL = GPIO15 (see src/main.cpp Wire.begin(4, 15))
|
||||
* - Chip 1: PCF8574, address 0x24 (onboard relay outputs)
|
||||
* - Chip 2: PCF8575, address 0x20 (external expansion board)
|
||||
* - Both chips share the same I2C bus/address space as the firmware —
|
||||
* do NOT run this at the same time as the main Vesper firmware.
|
||||
*
|
||||
* Library: Adafruit PCF8574 + Adafruit PCF8575 (same libraries the firmware
|
||||
* uses in src/OutputManager/OutputManager.cpp)
|
||||
*
|
||||
* Convention: ACTIVE-LOW outputs, matching OutputManager::firePhysicalOutput()
|
||||
* — LOW = relay energized/fired, HIGH = relay off.
|
||||
* ═══════════════════════════════════════════════════════════════════════════════
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_PCF8574.h>
|
||||
#include <Adafruit_PCF8575.h>
|
||||
|
||||
// ── Config ───────────────────────────────────────────────────────────────────
|
||||
#define I2C_SDA_PIN 4
|
||||
#define I2C_SCL_PIN 15
|
||||
|
||||
#define ONBOARD_ADDR 0x24 // KC868-A6 relay PCF8574
|
||||
#define EXTERNAL_ADDR 0x20 // External PCF8575
|
||||
|
||||
#define ONBOARD_COUNT 6
|
||||
#define EXTERNAL_COUNT 16
|
||||
#define TOTAL_COUNT (ONBOARD_COUNT + EXTERNAL_COUNT) // 22
|
||||
|
||||
#define STEP_ON_MS 150
|
||||
#define STEP_OFF_MS 30
|
||||
|
||||
#define ALL_FLASH_COUNT 5 // how many times to flash all 22 together
|
||||
#define ALL_ON_MS 300
|
||||
#define ALL_OFF_MS 300
|
||||
|
||||
#define CYCLE_PAUSE_MS 1500
|
||||
|
||||
#define FIRED LOW // active-low: LOW = relay on
|
||||
#define OFF HIGH // active-low: HIGH = relay off
|
||||
|
||||
Adafruit_PCF8574 onboard;
|
||||
Adafruit_PCF8575 external;
|
||||
|
||||
void allOff() {
|
||||
for (uint8_t i = 0; i < ONBOARD_COUNT; i++) onboard.digitalWrite(i, OFF);
|
||||
for (uint8_t i = 0; i < EXTERNAL_COUNT; i++) external.digitalWrite(i, OFF);
|
||||
}
|
||||
|
||||
void allOn() {
|
||||
for (uint8_t i = 0; i < ONBOARD_COUNT; i++) onboard.digitalWrite(i, FIRED);
|
||||
for (uint8_t i = 0; i < EXTERNAL_COUNT; i++) external.digitalWrite(i, FIRED);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
Serial.println();
|
||||
Serial.println("=== 22-Relay Sequence + Flash Test (onboard 6 + external 16) ===");
|
||||
|
||||
Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN);
|
||||
|
||||
if (!onboard.begin(ONBOARD_ADDR, &Wire)) {
|
||||
Serial.printf("FAILED to init onboard PCF8574 at 0x%02X\n", ONBOARD_ADDR);
|
||||
while (true) { delay(1000); }
|
||||
}
|
||||
Serial.printf("Onboard PCF8574 OK at 0x%02X\n", ONBOARD_ADDR);
|
||||
|
||||
if (!external.begin(EXTERNAL_ADDR, &Wire)) {
|
||||
Serial.printf("FAILED to init external PCF8575 at 0x%02X\n", EXTERNAL_ADDR);
|
||||
while (true) { delay(1000); }
|
||||
}
|
||||
Serial.printf("External PCF8575 OK at 0x%02X\n", EXTERNAL_ADDR);
|
||||
|
||||
for (uint8_t i = 0; i < ONBOARD_COUNT; i++) onboard.pinMode(i, OUTPUT);
|
||||
for (uint8_t i = 0; i < EXTERNAL_COUNT; i++) external.pinMode(i, OUTPUT);
|
||||
allOff();
|
||||
|
||||
Serial.printf("Ready. %d onboard + %d external = %d total relays.\n",
|
||||
ONBOARD_COUNT, EXTERNAL_COUNT, TOTAL_COUNT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// ── Step 1: fire all 22 relays in sequence, one at a time ──────────────
|
||||
Serial.println("--- Sequence: onboard 1-6, then external 1-16 ---");
|
||||
for (uint8_t i = 0; i < ONBOARD_COUNT; i++) {
|
||||
Serial.printf("Onboard relay %d -> ON\n", i + 1);
|
||||
onboard.digitalWrite(i, FIRED);
|
||||
delay(STEP_ON_MS);
|
||||
onboard.digitalWrite(i, OFF);
|
||||
delay(STEP_OFF_MS);
|
||||
}
|
||||
for (uint8_t i = 0; i < EXTERNAL_COUNT; i++) {
|
||||
Serial.printf("External relay %d -> ON\n", i + 1);
|
||||
external.digitalWrite(i, FIRED);
|
||||
delay(STEP_ON_MS);
|
||||
external.digitalWrite(i, OFF);
|
||||
delay(STEP_OFF_MS);
|
||||
}
|
||||
|
||||
// ── Step 2: flash all 22 together, several times ───────────────────────
|
||||
Serial.printf("--- Flashing all %d relays together x%d ---\n", TOTAL_COUNT, ALL_FLASH_COUNT);
|
||||
for (uint8_t flash = 0; flash < ALL_FLASH_COUNT; flash++) {
|
||||
Serial.printf("Flash %d: ALL ON\n", flash + 1);
|
||||
allOn();
|
||||
delay(ALL_ON_MS);
|
||||
|
||||
Serial.printf("Flash %d: ALL OFF\n", flash + 1);
|
||||
allOff();
|
||||
delay(ALL_OFF_MS);
|
||||
}
|
||||
|
||||
Serial.println("=== cycle complete, restarting ===\n");
|
||||
delay(CYCLE_PAUSE_MS);
|
||||
}
|
||||
Reference in New Issue
Block a user