DCC/MQTT Light Decoder with Current Monitoring U2.9 Purpose ------- Project UNION based ESP32 DCC/MQTT light decoder for programmable WS2812 LED strips, extended with INA226 voltage, current and power monitoring. The decoder supports up to 5 LED strips with up to 50 LEDs per strip. Measured voltage, current and power are shown on the OLED display and on the web configuration/status page. Important --------- This documentation was produced from the supplied U2.9 INA226 project package. No source code has been modified. Required libraries ------------------ - ProjectUNION Core 0.3.1 - ProjectUNION MQTT 0.3.1 - ProjectUNION DCC 0.3.0 - NmraDcc - PubSubClient - FastLED - Adafruit GFX - Adafruit SSD1306 Main hardware ------------- - ESP32 development module - DCC interface, 6N137 or equivalent - SSD1306 OLED display - INA226 current/voltage monitor, I2C address 0x40 - External 0.022 ohm shunt resistor - WS2812 programmable LED strips INA226 / shunt -------------- The present software is configured for: - INA226 address: 0x40 - External shunt: 0.022 ohm - INA226 module R100: 0.100 ohm, still fitted - Effective parallel shunt resistance: approximately 0.01803 ohm - Current calibration factor: 1.000 If the module R100 resistor is removed, the effective shunt becomes 0.022 ohm and the software shunt value must be changed accordingly. The INA226 module has 10K pull-up resistors on SDA and SCL. Additional 4K7 pull-ups are therefore normally not required when using the module with short I2C connections. Connections ----------- ESP32: - DCC input: GPIO26 - Setup button: GPIO27 - OLED + INA226 SDA: GPIO32 - OLED + INA226 SCL: GPIO33 - LED strip A: GPIO5 - LED strip B: GPIO18 - LED strip C: GPIO19 - LED strip D: GPIO21 - LED strip E: GPIO22 INA226: - VCC -> 3.3 V - GND -> GND - SDA -> GPIO32 - SCL -> GPIO33 - VBS -> IN- - A0/A1 -> GND for address 0x40 - ALE -> not used - +5 V supply -> IN+ -> shunt -> IN- -> LED strip +5 V - Supply GND -> LED strip GND and common ESP32/INA226 GND Functions --------- - DCC, MQTT or combined DCC + MQTT control - Up to 5 WS2812 strips - Up to 50 LEDs per strip - Individual address, colour/effect and brightness per LED - Random-house lighting function - Web configuration and test controls - OLED status pages - INA226 voltage, current and power monitoring - Current measurement shown on OLED and web status page Developer checklist ------------------- 1. Install the ESP32 board package and all required libraries. 2. Open the .ino file from its own sketch folder. 3. Verify all GPIO assignments against the hardware diagram/PCB. 4. Verify that INA226 responds at I2C address 0x40. 5. Confirm whether R100 remains fitted before selecting the software shunt value. 6. Upload by USB and verify WiFi/hostname. 7. Test one LED from the web page. 8. Verify DCC packet counter and switching. 9. Verify MQTT connection and switching. 10. Compare INA226 current measurement with a reference ammeter before final installation. 11. Test on one decoder before programming additional units. Notes ----- The current-monitoring prototype was tested against a digital multimeter at several LED loads and brightness levels, with good agreement. During documentation generation no source code has been modified. If inconsistencies are found between the code, PCB and diagrams, verify the hardware before assembly.