Back to Projects
Arduino UNO R4 WiFi · MQTT · Home Assistant

Office Touch Panel

Smart TFT controller for office appliances via Home Assistant

A wall-mounted touch panel built on the Arduino UNO R4 WiFi with a resistive TFT shield. Controls lights, power, and 3D printer via MQTT, reports door state from a reed switch, broadcasts internal temperature, and supports multi-tap + long-press on a physical button — all synced live with Home Assistant.

Arduino Uno r4 stock photo Office touch panel showing MQTT status and temperature reading

Parts List

Wiring

The TFT shield slots directly onto the Arduino headers. The two external sensors connect to spare pins left exposed by the shield.

Required Libraries

Install all of these through the Arduino IDE Library Manager (Tools → Manage Libraries):

Home Assistant & MQTT Setup

  1. Install & configure the Mosquitto MQTT broker

    In Home Assistant, go to Settings → Add-ons → Mosquitto broker and install it. Create an MQTT user under Settings → People (or use an existing HA user). Note the broker's local IP — you'll put it in the sketch.

  2. MQTT topics used by this sketch

    All topics are prefixed with home/buttons/office/ or office/. The sketch publishes commands and subscribes to /state feedback so the display stays in sync if HA changes a device externally.

    MQTT topic map
    # Published by Arduino (commands)
    home/buttons/office/light          → "ON" / "OFF"
    home/buttons/office/power          → "ON" / "OFF"
    home/buttons/office/3dprint        → "ON" / "OFF"
    home/buttons/office/tap            → "1" / "2" / "3" / "long"
    office/door/state                  → "open" / "closed"
    office/arduino/temperature         → "26.3"  (°C, float string)
    
    # Subscribed by Arduino (state feedback)
    home/buttons/office/light/state    → "ON" / "OFF"
    home/buttons/office/power/state    → "ON" / "OFF"
    home/buttons/office/3dprint/state  → "ON" / "OFF"
    
    # Auto-discovery (published once on boot, retained)
    homeassistant/binary_sensor/office_door/config
    homeassistant/sensor/office_arduino_temp/config
  3. Create HA automations for each button

    In Home Assistant create an automation triggered by MQTT message on e.g. home/buttons/office/light. The action toggles your light switch entity, then publishes the new state back to home/buttons/office/light/state so the panel display updates.

    YAML — example HA automation (light button)
    alias: "Office panel - light button"
    trigger:
      - platform: mqtt
        topic: home/buttons/office/light
    action:
      - service: >
          {% if trigger.payload == 'ON' %}
            light.turn_on
          {% else %}
            light.turn_off
          {% endif %}
        target:
          entity_id: light.office_main
      - service: mqtt.publish
        data:
          topic: home/buttons/office/light/state
          payload: "{{ trigger.payload }}"
          retain: false

Arduino Sketch

Download the sketch and edit the WiFi & MQTT CONFIG block near the top of the file before uploading. The sketch compiles on Arduino IDE 2.x with the UNO R4 WiFi board package installed.

Download sketch_jan27a.ino

What to edit before uploading

Everything else — pin numbers, touch calibration, button layout — can be left as-is for the standard MCUFRIEND 2.4" shield on an UNO R4 WiFi.

How It Works

Notes & Gotchas