Wiring diagram and peripheral details

Wiring diagram and notes for the Electricity Price Ticker project, including optional peripherals and GPIO connections.
This commit is contained in:
2026-03-07 11:17:58 +01:00
committed by GitHub
parent 26b1a309e1
commit 6a6cf113b3
+49 -93
View File
@@ -4,11 +4,13 @@ This document depicts the wiring for the **Electricity Price Ticker** project ba
It includes: It includes:
- Required peripherals (LCD + button) - 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: > 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 ESP32C3 SDA/SCL pins** in the Seeed pinout; the sketch uses the board default I²C pins. > - Verify your **XIAO ESP32C3 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 youre doing.
--- ---
@@ -16,118 +18,72 @@ It includes:
```mermaid ```mermaid
flowchart TB flowchart TB
MCU[Seeed XIAO ESP32C3]:::mcu MCU["Seeed XIAO ESP32-C3"]:::mcu
LCD[20x4 I²C LCD (2004)\nPCF8574 backpack\nAddr: 0x27]:::lcd LCD["20x4 I2C LCD 2004<br/>PCF8574 backpack<br/>I2C addr 0x27"]:::lcd
BTN[Momentary pushbutton\n(active LOW via INPUT_PULLUP)]:::btn
PRES[RCWL0516 presence sensor (optional)]:::pres
LED[White LED / LED strip control (optional)]:::led
RPD[10 kΩ pulldown resistor\n(required for presence sensor)]:::res
MOSFET[MOSFET / transistor driver\n(recommended for LED strips)]:::drv
PSU5V[5V supply\n(USBC or regulated 5V)]:::pwr %% Button input options (GPIO 4)
PSU3V3[3.3V rail\n(from XIAO)]:::pwr GPIO4["GPIO 4 node<br/>(buttonPin input)"]:::io
GND[(Common GND)]:::gnd BTN["Mechanical pushbutton<br/>default option<br/>active LOW to GND"]:::btn
TTP["TTP223 capacitive touch<br/>optional alternative<br/>OUT is HIGH when touched"]:::touch
%% Presence-sensor input stage (GPIO 9) - always present
GPIO9["GPIO 9 node<br/>(presencePin input)"]:::io
RPD["10k pull-down resistor<br/>GPIO 9 to GND<br/>MANDATORY"]:::res
PRES["RCWL-0516 presence sensor<br/>optional"]:::pres
LED1["White indicator LED<br/>optional"]:::led
PSU5V["5V supply<br/>USB-C or regulated 5V"]:::pwr
V33["3.3V rail from XIAO"]:::pwr
GND["Common GND"]:::gnd
%% Power %% Power
PSU5V -->|5V| MCU PSU5V -->|"5V"| MCU
PSU5V -->|5V (or 3V3 if LCD supports it)| LCD PSU5V -->|"5V or 3V3 if LCD supports"| LCD
MCU -->|3V3| PSU3V3 MCU -->|"3V3"| V33
PSU3V3 -->|3.3V| PRES V33 -->|"3V3"| PRES
V33 -->|"3V3"| TTP
%% Grounds %% Grounds
MCU --- GND MCU --- GND
LCD --- GND LCD --- GND
BTN --- GND
TTP --- GND
GPIO4 --- GND
GPIO9 --- GND
RPD --- GND
PRES --- GND PRES --- GND
LED --- GND
MOSFET --- GND LED1 --- GND
PSU5V --- GND PSU5V --- GND
%% I2C %% I2C
MCU -->|SDA| LCD MCU -->|"SDA (board I2C SDA)"| LCD
MCU -->|SCL| LCD MCU -->|"SCL (board I2C SCL)"| LCD
%% Button %% GPIO 4 button input stage (always)
MCU -->|GPIO 4 (buttonPin)| BTN MCU -->|"GPIO 4 (buttonPin)"| GPIO4
BTN -->|to GND| GND BTN -->|"button to GND"| GPIO4
TTP -->|"OUT to GPIO 4 node"| GPIO4
%% Presence sensor %% GPIO 9 presence input stage (always)
MCU -->|GPIO 9 (presencePin)| PRES MCU -->|"GPIO 9 (presencePin)"| GPIO9
RPD -->|10 kΩ| GND GPIO9 ---|"10k"| RPD
MCU -->|GPIO 9 node| RPD RPD -->|"to GND"| GND
PRES -->|"OUT to GPIO 9 node"| GPIO9
%% White LED / strip driver %% White LED (single LED, directly from GPIO with series resistor)
MCU -->|GPIO 5 (whiteLedPin)| LED MCU -->|"GPIO 5 (whiteLedPin)"| LED1
MCU -->|GPIO 5 (better)| MOSFET
MOSFET -->|drives| LED
classDef mcu fill:#e8f0ff,stroke:#2b5fd9,stroke-width:1px,color:#000; classDef mcu fill:#e8f0ff,stroke:#2b5fd9,stroke-width:1px,color:#000;
classDef lcd fill:#fff4e5,stroke:#cc7a00,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 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 pres fill:#f3e8ff,stroke:#7b2cbf,stroke-width:1px,color:#000;
classDef led fill:#ffe8ef,stroke:#c9184a,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 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 pwr fill:#fff,stroke:#444,stroke-width:1px,color:#000;
classDef gnd fill:#fff,stroke:#000,stroke-width:1.5px,color:#000; classDef gnd fill:#fff,stroke:#000,stroke-width:1.5px,color:#000;
``` classDef io fill:#f5f5f5,stroke:#111,stroke-width:1px,color:#000;
---
## 2) Pin mapping (as used by the sketch)
| Peripheral | Signal | XIAO ESP32C3 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 (RCWL0516, optional) | OUT | **GPIO 9** (`presencePin`) | Requires pulldown resistor |
| Presence sensor (RCWL0516, optional) | VCC | **3.3V** | Recommended 3.3V |
| Presence sensor (RCWL0516, optional) | GND | GND | Common ground |
| Pulldown 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 (RCWL0516, optional)
- Wiring:
- `VCC`**3.3V**
- `GND`**GND**
- `OUT`**GPIO 9**
- **10 kΩ pulldown** between **GPIO 9** and **GND** (required)
### White LED / LED strip output (optional)
- Single LED wiring:
- **GPIO 5 → series resistor (220470 Ω) → 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 ESP32C3
- [x] 20x4 I²C LCD (PCF8574 backpack)
- [x] Pushbutton (or touch alternative using same GPIO)
- [x] Presence sensor RCWL0516 (optional)
- [x] 10 kΩ pulldown resistor for presence sensor (required when used)
- [x] White LED output / LED strip driver (optional)