AWTRIX 3

repository·main·Indexed 25 days ago

https://github.com/blueforcer/awtrix3

An open-source ESP32-based firmware for pixel matrix clocks, such as the Ulanzi TC001, that functions as a visual dashboard for smart home data via MQTT and HTTP APIs. The project includes support for CustomApps, which act as dynamic display pages driven by external logic, and integrates various libraries including ArduinoHA for Home Assistant integration, DFMiniMp3 for MP3 module control, and MeanFilter/MedianFilter for data processing.

Tokens
33.2K
Snippets
48
Records
166
Agent score
81%

What's inside awtrix3

  1. Overview of the DFMiniMp3 library

    main

    The DFMiniMp3 library is designed to control the DFPlayer Mini MP3 module within Arduino projects.

    Key features include:

    • Serial Support: Works with both hardware serial and software serial.
    • Resource Efficient: Optimized for small Arduino hardware by minimizing code and memory consumption.

    Important: Before connecting your module, review the official hardware documentation to avoid errors: DFRobot's DFPlayer Mini Mp3 Wiki

  2. Overview of AWTRIX 3

    main

    AWTRIX 3 is an open-source custom firmware designed for the Ulanzi Smart Pixel clock TC001, the older AWTRIX 2 Mainboard, or self-built matrix clocks.

    Key Requirements & Compatibility:

    • Hardware: Only compatible with ESP32-based devices.
    • Purpose: Designed as a companion for smart home ecosystems like HomeAssistant, IOBroker, FHEM, and NodeRed.
    • Privacy: Features no cloud connectivity and no telemetry.

    Out of the box, it includes pre-installed pages for time, date, temperature, and humidity. Advanced users can extend functionality using CustomApps via MQTT or HTTP APIs.

  3. Overview of the TJpg_Decoder library

    main

    The TJpg_Decoder library is an Arduino library designed to render JPEG files onto a TFT display. It supports loading images from several sources:

    • SD cards
    • Program memory (FLASH) via arrays
    • SPIFFS (ESP32, ESP8266)
    • LittleFS (ESP32, ESP8266, RP2040)
    • PROGMEM arrays

    The library uses the highly optimized TJpgDec decompressor engine.

  4. Integrate Arduino/ESP devices with Home Assistant using ArduinoHA

    main

    ArduinoHA is a library designed to integrate Arduino or ESP-based devices (such as ESP8266/ESP8255) with Home Assistant via MQTT. It is optimized for low resource consumption (RAM/flash) and is compatible with hardware ranging from Arduino Uno with Ethernet Shields to ESP-based boards.

    Key capabilities include:

    • Two-way communication: The device can report its state to Home Assistant and execute commands received from it.
    • MQTT Discovery: Devices are automatically added to the Home Assistant dashboard using MQTT discovery protocols.
    • Availability Reporting: The library manages online/offline states using MQTT Last Will and Testament and availability reporting.
    • Custom Messaging: Supports publishing and subscribing to custom MQTT messages.
    • Resilience: Includes automatic reconnection logic for the MQTT broker.
  5. Integrate Arduino/ESP devices with Home Assistant via MQTT

    main

    The ArduinoHA library allows you to integrate Arduino or ESP-based hardware with Home Assistant using the MQTT protocol. It is designed for low resource consumption (RAM/flash) and supports two-way communication: reporting device states to Home Assistant and executing commands received from Home Assistant.

    Key features include:

    • MQTT Discovery: Devices are automatically added to the Home Assistant panel.
    • Two-way communication: State reporting and command execution.
    • MQTT Last Will and Testament (LWT): For reliable connection monitoring.
    • Availability reporting: Automatically reports online/offline states.
    • Custom MQTT support: Ability to publish and subscribe to custom topics.
    • Auto-reconnect: Automatically handles MQTT broker disconnections.
  6. Configure AWTRIX via the Web Interface

    main

    The web interface provides several configuration sections for initial setup and ongoing management:

    • WiFi Setup: Configure Wi-Fi settings or change the access point.
    • Network: Assign a static IP address to the device.
    • MQTT: Set up an MQTT broker and enable Home Assistant discovery.
    • Time: Configure the time server and time zone (supports automatic daylight saving time adjustments).
    • Icons: Download LaMetric icons by entering an icon ID; AWTRIX uses an internal downloader.
    • Auth: Enable basic authentication to secure the web interface and API. Warning: If you lose these credentials, you must reset the AWTRIX completely.
    • Files: Use the integrated file manager to upload/download icons or RTTTL melodies.
    • Update: Manually upload firmware updates using a .bin file from the AWTRIX 3 release section.
    • LiveView: View a live stream of the matrix, take screenshots, or create animated GIFs.
    • Backup: Download a zip file containing the entire flash memory to restore on another AWTRIX device.
  7. What is the Mean Filter library?

    main
    The MeanFilter library implements a moving average filter for Arduino. It maintains a circular buffer of the last N elements to calculate the mean, ensuring high efficiency. The library uses C++ templates, allowing it to work with various data types such as int, long, and float.
  8. Migrate API usage from AWTRIX 2 to AWTRIX 3

    main
    AWTRIX 3 is a complete redevelopment from scratch. The API used in AWTRIX 2 is not compatible with AWTRIX 3. If you are migrating existing integrations, you must update your code to match the new API specifications. Pay particular attention to the implementation of "apps," as the logic and structure have changed.
  9. How MQTT device discovery works

    main

    The library automates the connection to the MQTT broker and the Home Assistant discovery process. When you create device types (such as sensors, switches, lights, or fans), they are automatically registered in the MQTT manager. Once a connection to the MQTT broker is established, the configuration for all registered device types is pushed to Home Assistant.

    Crucial Requirement: To ensure device types can access the internal MQTT instance, you must construct your device types after the HAMqtt class has been instantiated.

  10. How device types work in Home Assistant integration

    main

    A Device type represents a single entity within the Home Assistant panel (e.g., a sensor, lock, or camera).

    A single physical device (such as an ESP-01 board) can have multiple device types assigned to it. In the Home Assistant interface, these assigned types will appear as child entities belonging to the main physical device.

  11. Core rules for implementing Home Assistant integration

    main

    To implement business logic using the Home Assistant integration, you must follow these initialization and lifecycle rules:

    1. Global Initialization: HADevice and HAMqtt instances must be initialized once globally or as part of another global object.
    2. MQTT Setup: Call HAMqtt::begin at the end of your setup() logic. This method provides the MQTT broker credentials used for the connection.
    3. MQTT Lifecycle: Call the HAMqtt::loop() method periodically within your main loop (it does not need to be called on every single tick).
    4. Initialization Order: Device types must be initialized after the HAMqtt class.