Files
learning-garden/sources/brewery-pid-replacement.md

266 lines
7.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
pageType: source
id: source.brewery-pid-replacement
title: brewery-pid-replacement
sourceType: local-file
sourcePath: /home/topher/.openclaw/workspace-crash-bot/projects/brewery-pid-replacement.md
ingestedAt: 2026-05-02T21:16:19.602Z
updatedAt: 2026-05-02T21:16:19.602Z
status: active
growth: seed
---
# brewery-pid-replacement
## Source
- Type: `local-file`
- Path: `/home/topher/.openclaw/workspace-crash-bot/projects/brewery-pid-replacement.md`
- Bytes: 6887
- Updated: 2026-05-02T21:16:19.602Z
## Content
````text
# Brewery PID Controller Replacement
**Status:** Prototyping — Path Decided
**Created:** 2026-04-16
**Updated:** 2026-04-16 (major revision)
**Tags:** `brewery`, `esp32-s3`, `esphome`, `pid`, `home-assistant`, `pt100`, `max31865`, `nextion`, `custom-pcb`
---
## Summary
Replace 8 existing Chinese commodity PID controllers in a commercial brewery with custom ESP32-S3-based PID controllers with Nextion displays, ESPHome firmware, and Home Assistant integration. All 8 units are interchangeable — heating vs cooling is a software setting.
---
## System Overview
**8 PIDs total:**
| # | Vessel | Type | Control |
|---|--------|------|---------|
| 1 | Fermenter 1 | Cooling | Glycol valve |
| 2 | Fermenter 2 | Cooling | Glycol valve |
| 3 | Fermenter 3 | Cooling | Glycol valve |
| 4 | Fermenter 4 | Cooling | Glycol valve |
| 5 | Glycol Chiller | Monitoring/Control | Chiller |
| 6 | HLT | Heating | 4× SSR → contactors |
| 7 | Mash RIMS | Heating | 1× SSR → contactor |
| 8 | Kettle | Heating | 4× SSR → contactors |
**Existing sensors:** PT100 (3-wire) in all vessels
**Control signals:**
- **Hot side:** ESP32 → G3MB-202P → 120V AC contactor coil → heating element
- **Cold side:** ESP32 → G3MB-202P → 120V AC coil relay → 24V relay → glycol valve
- Both sides use identical output hardware — mode is set in ESPHome YAML
---
## Architecture (2026-04-16 revision)
**Per-PID architecture — one unit per vessel:**
```
[Surenoo NX4880E043] ← UART ← [Custom PCB]
4.3" 480×800 display ├── ESP32-S3 Supermini
├── MAX31865 (PT100)
└── G3MB-202P (SSR output)
```
**Why per-PID over central:**
- Each vessel is independently controlled
- Hot-swappable — swap a board without affecting others
- No single point of failure
- Simpler wiring (sensors/outputs local to each vessel)
- Interchangeable like-for-like with original PIDs
**Software: ESPHome** (not Arduino)
- Native HA integration — no custom MQTT code
- `climate.pid` component for PID loop
- `max31865` sensor component
- `nextion` display component
- OTA updates
---
## Hardware Decisions (2026-04-16)
### Per-Unit Hardware Add-ons (Protection & Reliability)
| Component | Unit Cost | Notes |
|-----------|-----------|-------|
| 100nF decoupling caps (×3) | ~$0.10 | On VCC pins |
| TVS diodes (SMBJ5.0A) | ~$0.20 | 5V rail clamping |
| 220Ω resistor (SSR gate) | ~$0.05 | G3MB-202P LED input |
| Reverse polarity diode (SMB5819) | ~$0.10 | 5V input protection |
| Hardware watchdog (TPS3823) | ~$0.50 | Reset on ESP32 hang |
| RC filter (49.9K + 100nF) | ~$0.15 | PT100 input filtering |
| **Total add-ons** | **~$1.10** | |
**Hardware Watchdog (TPS3823):**
- 3-pin voltage supervisor chip
- Watches ESP32's heartbeat (toggle a GPIO periodically)
- If ESP32 hangs and stops toggling, watchdog resets it after ~1.6 seconds
- Essential for unattended commercial installations
- Research: search "TPS3823 ESP32 watchdog" for wiring diagram
- Alternative: software watchdog in ESPHome handles most cases, hardware is belt-and-suspenders
### Per-unit total
| Section | Cost |
|---------|------|
| Custom PCB (components) | ~$11-12 |
| Protection add-ons | ~$1.10 |
| Display (NX4880E043) | ~$37 |
| **Per unit total** | **~$49-50** |
**8-unit system total: ~$392-400**
### Output Driver Detail
**G3MB-202P SSR:**
- 2A output, 120-380V AC
- DIP-4 package, PCB-mount
- Logic-level input (3.3V from ESP32 works)
- Random fire (fine for coil loads)
- ~$1.50 in quantity
**Why G3MB-202P over SSR-10DA module:**
- DIP-4 is much smaller than panel-mount SSR modules
- Enough current rating for contactor coils (50-100mA)
- One part to stock for both hot and cold sides
**MOV across output terminals** — spike protection for inductive coil
### ESP32-S3 Supermini (AITRIP)
- 5-pack ~$13 on Amazon
- GP1-GP48 GPIO broken out
- Type-C USB for programming
- 160MHz (underclocked but fine for PID)
- Dual-core ESP32-S3
---
## Display: Surenoo NX4880E043
**Specs:**
| Spec | Value |
|------|-------|
| Size | 4.3" |
| Resolution | 480×800 (tall) |
| Touch | Capacitive (CTP) |
| MCU | 200MHz |
| Flash | 128MB |
| GPIOs | 8 available |
| RTC | Yes (coin cell backup) |
| Interface | Serial UART |
| Bezel | Slim/flush mount |
| Price | ~$35-40 |
**Why NX4880E043 over JC4827W543:**
- Nextion editor — drag-drop UI design
- ESPHome native `nextion` component support
- 128MB flash for fonts and assets
- 8 GPIOs on the display module itself
- RTC built-in
**Why NX4880E043 over official Nextion:**
- ~$35-40 vs $89+ for equivalent Nextion
- Same Nextion instruction set and editor
- Slimmer bezel
---
## Software: ESPHome
### YAML Components Needed
```yaml
# ESPHome config per unit
climate:
- platform: pid
name: "${vessel_name} PID"
sensor: pt100_sensor
output: ssr_output
default_target_temperature: 70°F
heat_output: ssr_output # or separate heat/cool outputs
# PID tuning parameters
sensor:
- platform: max31865
name: "${vessel_name} Temperature"
cs_pin: GPIOXX
# 3-wire PT100 config
output:
- platform: gpio
pin: GPIOXX
id: ssr_output
display:
- platform: nextion
# Bind to temperature sensor, setpoint, mode
```
### HA Integration
- Native ESPHome API — zero-config discovery
- HA sees each PID as a `climate` entity
- Setpoint control from HA UI
- Temperature history graphing
- Automation triggers on temp reached
---
## Next Steps
- [ ] Find Nextion in lab (or order NX4880E043)
- [ ] Write starter ESPHome YAML for one unit
- [ ] Prototype: ESP32-S3 + MAX31865 + G3MB-202P wired up
- [ ] Test PID loop and HA integration
- [ ] Design custom PCB in EasyEDA
- [ ] Order PCB prototypes (JLCPCB)
- [ ] Build and test first complete unit
- [ ] Flash all 8 units with vessel-specific YAML
- [ ] Scale to full installation
---
## Decision Log
### 2026-04-16 — Major revision
**Changes from original plan:**
- ✅ **Switched from Arduino to ESPHome** — user prefers ESPHome + easy HA integration
- ✅ **Switched from central architecture to per-PID** — hot-swappable, no single point of failure
- ✅ **Display: NX4880E043 Surenoo Nextion** instead of CrowPanel 7"
- ✅ **Custom PCB** using AITRIP ESP32-S3 Supermini + MAX31865 module + G3MB-202P
- ✅ **Per-unit BOM: ~$48-49** (down from ~$93 central architecture)
- ✅ **8-unit total: ~$390-395** (vs $700+ for official Nextion)
- ✅ **Hot/cold is software switch** — same hardware for all 8 units
### 2026-04-16 — Original architecture (superseded)
- Central ESP32 + 2× CrowPanel 7" = ~$213
- Custom Arduino firmware (not ESPHome)
- Per-vessel architecture also considered
---
## Related Projects
- [[fermentation-dashboard.md]] — separate brewery HA dashboard (TILT hydrometer)
- [[pihole-blocker.md]] — CM4 board could be brewery server
````
## Notes
<!-- openclaw:human:start -->
<!-- openclaw:human:end -->
## Related
<!-- openclaw:wiki:related:start -->
### Referenced By
- [README](sources/readme.md)
<!-- openclaw:wiki:related:end -->