From 6a6cf113b38992692bc623926535b2cbfef30759 Mon Sep 17 00:00:00 2001 From: Legolas-2025 Date: Sat, 7 Mar 2026 11:17:58 +0100 Subject: [PATCH] Wiring diagram and peripheral details Wiring diagram and notes for the Electricity Price Ticker project, including optional peripherals and GPIO connections. --- HARDWARE_WIRING_DIAGRAM.md | 142 +++++++++++++------------------------ 1 file changed, 49 insertions(+), 93 deletions(-) diff --git a/HARDWARE_WIRING_DIAGRAM.md b/HARDWARE_WIRING_DIAGRAM.md index f8aa484..267339e 100644 --- a/HARDWARE_WIRING_DIAGRAM.md +++ b/HARDWARE_WIRING_DIAGRAM.md @@ -4,11 +4,13 @@ This document depicts the wiring for the **Electricity Price Ticker** project ba It includes: - Required peripherals (LCD + button) -- Supported optional peripherals (presence sensor + white LED / LED strip driver) +- Supported optional peripherals (presence sensor + white LED + optional TTP223 touch button alternative) > Notes: -> - Always connect **all grounds together** (ESP32 GND, LCD GND, sensor GND, LED driver GND, external PSU GND). +> - Always connect **all grounds together** (ESP32 GND, LCD GND, sensor GND, LED GND). > - Verify your **XIAO ESP32‑C3 SDA/SCL pins** in the Seeed pinout; the sketch uses the board default I²C pins. +> - **Important:** The **10 kΩ pull-down resistor on GPIO 9 is mandatory at all times** (even if the presence sensor is not connected). +> - Button input is on **GPIO 4**. You may use either a **mechanical pushbutton** (default) *or* a **TTP223 touch module** (alternative), but not both in parallel unless you know what you’re doing. --- @@ -16,118 +18,72 @@ It includes: ```mermaid flowchart TB - MCU[Seeed XIAO ESP32‑C3]:::mcu + MCU["Seeed XIAO ESP32-C3"]:::mcu - LCD[20x4 I²C LCD (2004)\nPCF8574 backpack\nAddr: 0x27]:::lcd - BTN[Momentary pushbutton\n(active LOW via INPUT_PULLUP)]:::btn - PRES[RCWL‑0516 presence sensor (optional)]:::pres - LED[White LED / LED strip control (optional)]:::led - RPD[10 kΩ pull‑down resistor\n(required for presence sensor)]:::res - MOSFET[MOSFET / transistor driver\n(recommended for LED strips)]:::drv + LCD["20x4 I2C LCD 2004
PCF8574 backpack
I2C addr 0x27"]:::lcd - PSU5V[5V supply\n(USB‑C or regulated 5V)]:::pwr - PSU3V3[3.3V rail\n(from XIAO)]:::pwr - GND[(Common GND)]:::gnd + %% Button input options (GPIO 4) + GPIO4["GPIO 4 node
(buttonPin input)"]:::io + BTN["Mechanical pushbutton
default option
active LOW to GND"]:::btn + TTP["TTP223 capacitive touch
optional alternative
OUT is HIGH when touched"]:::touch + + %% Presence-sensor input stage (GPIO 9) - always present + GPIO9["GPIO 9 node
(presencePin input)"]:::io + RPD["10k pull-down resistor
GPIO 9 to GND
MANDATORY"]:::res + PRES["RCWL-0516 presence sensor
optional"]:::pres + + LED1["White indicator LED
optional"]:::led + + PSU5V["5V supply
USB-C or regulated 5V"]:::pwr + V33["3.3V rail from XIAO"]:::pwr + GND["Common GND"]:::gnd %% Power - PSU5V -->|5V| MCU - PSU5V -->|5V (or 3V3 if LCD supports it)| LCD - MCU -->|3V3| PSU3V3 - PSU3V3 -->|3.3V| PRES + PSU5V -->|"5V"| MCU + PSU5V -->|"5V or 3V3 if LCD supports"| LCD + MCU -->|"3V3"| V33 + V33 -->|"3V3"| PRES + V33 -->|"3V3"| TTP %% Grounds MCU --- GND LCD --- GND + BTN --- GND + TTP --- GND + GPIO4 --- GND + + GPIO9 --- GND + RPD --- GND PRES --- GND - LED --- GND - MOSFET --- GND + + LED1 --- GND PSU5V --- GND %% I2C - MCU -->|SDA| LCD - MCU -->|SCL| LCD + MCU -->|"SDA (board I2C SDA)"| LCD + MCU -->|"SCL (board I2C SCL)"| LCD - %% Button - MCU -->|GPIO 4 (buttonPin)| BTN - BTN -->|to GND| GND + %% GPIO 4 button input stage (always) + MCU -->|"GPIO 4 (buttonPin)"| GPIO4 + BTN -->|"button to GND"| GPIO4 + TTP -->|"OUT to GPIO 4 node"| GPIO4 - %% Presence sensor - MCU -->|GPIO 9 (presencePin)| PRES - RPD -->|10 kΩ| GND - MCU -->|GPIO 9 node| RPD + %% GPIO 9 presence input stage (always) + MCU -->|"GPIO 9 (presencePin)"| GPIO9 + GPIO9 ---|"10k"| RPD + RPD -->|"to GND"| GND + PRES -->|"OUT to GPIO 9 node"| GPIO9 - %% White LED / strip driver - MCU -->|GPIO 5 (whiteLedPin)| LED - MCU -->|GPIO 5 (better)| MOSFET - MOSFET -->|drives| LED + %% White LED (single LED, directly from GPIO with series resistor) + MCU -->|"GPIO 5 (whiteLedPin)"| LED1 classDef mcu fill:#e8f0ff,stroke:#2b5fd9,stroke-width:1px,color:#000; classDef lcd fill:#fff4e5,stroke:#cc7a00,stroke-width:1px,color:#000; classDef btn fill:#eaffea,stroke:#2d8a2d,stroke-width:1px,color:#000; +classDef touch fill:#e6fcff,stroke:#0077b6,stroke-width:1px,color:#000; classDef pres fill:#f3e8ff,stroke:#7b2cbf,stroke-width:1px,color:#000; classDef led fill:#ffe8ef,stroke:#c9184a,stroke-width:1px,color:#000; classDef res fill:#f5f5f5,stroke:#444,stroke-width:1px,color:#000; -classDef drv fill:#f5f5f5,stroke:#444,stroke-width:1px,color:#000; classDef pwr fill:#fff,stroke:#444,stroke-width:1px,color:#000; classDef gnd fill:#fff,stroke:#000,stroke-width:1.5px,color:#000; -``` - ---- - -## 2) Pin mapping (as used by the sketch) - -| Peripheral | Signal | XIAO ESP32‑C3 pin | Notes | -|---|---:|---:|---| -| LCD (I²C, PCF8574) | SDA | **Board I²C SDA** | Check Seeed pinout for your board variant | -| LCD (I²C, PCF8574) | SCL | **Board I²C SCL** | Check Seeed pinout for your board variant | -| LCD (I²C, PCF8574) | VCC | **5V** (or 3V3) | Many LCD backpacks expect 5V; use 3V3 only if your module supports it | -| LCD (I²C, PCF8574) | GND | GND | Common ground | -| Button | input | **GPIO 4** (`buttonPin`) | Sketch uses `INPUT_PULLUP`; wiring is button → GPIO4 and button → GND | -| Presence sensor (RCWL‑0516, optional) | OUT | **GPIO 9** (`presencePin`) | Requires pull‑down resistor | -| Presence sensor (RCWL‑0516, optional) | VCC | **3.3V** | Recommended 3.3V | -| Presence sensor (RCWL‑0516, optional) | GND | GND | Common ground | -| Pull‑down resistor (required if presence sensor used) | 10 kΩ | **GPIO 9 → GND** | Stabilizes the OUT line | -| White LED (optional) | control | **GPIO 5** (`whiteLedPin`) | Use series resistor for a single LED | -| LED strip driver (recommended for strips) | gate/base | **GPIO 5** | Use a MOSFET/transistor + external supply; do not power strips from GPIO | - ---- - -## 3) Practical wiring notes - -### LCD (I²C) -- The sketch instantiates: `LiquidCrystal_I2C lcd(0x27, 20, 4);` -- If your LCD uses a different I²C address, you must change `0x27`. - -### Button (default) -- Recommended wiring: - - One leg of the button → **GPIO 4** - - Other leg → **GND** -- The code reads it as active-low using: - - `pinMode(buttonPin, INPUT_PULLUP);` - - `int reading = !digitalRead(buttonPin);` - -### Presence sensor (RCWL‑0516, optional) -- Wiring: - - `VCC` → **3.3V** - - `GND` → **GND** - - `OUT` → **GPIO 9** - - **10 kΩ pull‑down** between **GPIO 9** and **GND** (required) - -### White LED / LED strip output (optional) -- Single LED wiring: - - **GPIO 5 → series resistor (220–470 Ω) → LED anode** - - LED cathode → **GND** -- LED strip / higher current: - - Use a logic-level MOSFET (or suitable transistor) and an external PSU. - - Ensure **common ground** between PSU and ESP32. - ---- - -## 4) Included peripherals checklist - -- [x] Seeed XIAO ESP32‑C3 -- [x] 20x4 I²C LCD (PCF8574 backpack) -- [x] Pushbutton (or touch alternative using same GPIO) -- [x] Presence sensor RCWL‑0516 (optional) -- [x] 10 kΩ pull‑down resistor for presence sensor (required when used) -- [x] White LED output / LED strip driver (optional) \ No newline at end of file +classDef io fill:#f5f5f5,stroke:#111,stroke-width:1px,color:#000;