Project:Trash Tracker

From CoMakingSpace Wiki

ProjectInfoBox

Trash Tracker

Plastic-trash-with-tracker.jpeg
Status: Done
Release Date: 23.03.2025
Initiator: Erik
Materials Used: Generic BLE beacon (we use Tile Trackers), one for each garbage bin;

one ESP32

Tools Used: Computer needed to flash the ESP32
Software Used: Espresense, HomeAssistant
Approx. Cost: 67.77€ for 3x Tile Mate (2022)

You probably know about our Trash situation in the space. In order to keep our space clean, it is necessary to bring the trash out so it can be collected.

However, this key step is often missed, because during Friday Making Hours, no one thinks about Thursday the next week and even if someone does, it is hard to know which Trash must be brought out.

In order to motivate and remind ourselves, we recently introduced a sign (Project:Müllampel) which blinks at a specific time. The Trash Tracker helps us make the sign smarter and let it only blink while needed, as well as give us the possibility to communicate on Slack and in the Telegram Group that the Trash is still inside.

Concept

The concept is that each garbage bin has a specific BLE beacon and therefore MAC address which is frequently broadcasted by each tracker. The broadcasted signal can then be detected by any Bluetooth enabled device. In our case, we simply use an ESP32 with a software called Espresense. Espresence simply collects statistics about the broadcasted signals and tries to determine a distance for each signal. The statistics are then pushed to an MQTT broker and collected in your HomeAssistant instance. There, with the help of the MQTT room presence integration, we can automate other things based on the state of each garbage bin (for example, toggle the Project:Müllampel or send reminders via Slack).

A screenshot of the web interface of a ESPresense instance running on an ESP32. Three Tile trackers with their distance and RSSI are displayed.
ESPresense running on an ESP32 tracking 3 Tile BLE beacons
the way from our backdoor to the trash can pickup/storage spot

What makes this project quite straightforward and helps with one of the biggest problems in Bluetooth distance measurement is the fact that our pickup spot is quite far away from the Workshop. This simplifies distance measurement, because we only need to look if there is a signal at all and not how strong it is. Simply put: If we see the broadcasted signal from one tracker, it is in the Workshop or close by. If we do not detect a signal, the trash is either at the pickup spot or has been stolen.

Home Assistant integration

Trashtracker-homeassistant-sensor-view.png

As already said, with the help of MQTT room presence add-on, we can use Home Assistant to further integrate the tracking into our setup.

Trashtracker-homeassistant-list-sensors.png

For that we need to integrate the data from MQTT as a sensor. Unfortunately, the MQTT room integration can only be configured via YAML in the configuration.yaml file.

  # tracker for the trash
  # each garbage bin has one unique tracker
sensor:
  - platform: mqtt_room
    unique_id: sensor.trash_rest
    device_id: "tile:d24a9fe7fc86"
    name: 'TrashTracker Restmuell'
    state_topic: 'espresense/devices/tile:d24a9fe7fc86'
    timeout: 10
    away_timeout: 120
  - platform: mqtt_room
    unique_id: sensor.trash_plastik
    device_id: "tile:d1ebaa8a68da"
    name: 'TrashTracker Plastikmuell'
    state_topic: 'espresense/devices/tile:d1ebaa8a68da'
    timeout: 10
    away_timeout: 120
  - platform: mqtt_room
    unique_id: sensor.trash_papier
    device_id: "tile:c7a6a7f007d2"
    name: 'TrashTracker Papiermuell'
    state_topic: 'espresense/devices/tile:c7a6a7f007d2'
    timeout: 10
    away_timeout: 120
Screenshot showing the web interface of Home Assistant displaying three entities for each garbage bin stating either "Home" or "Away"
Screenshot of the "sensors" for the garbage bins in Home Assistant

To further ease the use of the sensors in Home Assistant, we can then create a Template for each sensor:


Trashtracker-template-binary-sensor.png

Screenshot showing a state change for the paper trash tracker in Home Assistant
Screenshot showing a state change for the paper trash tracker in Home Assistant

With the following expression:

Trashtracker-template-homeassistant-expression.png

These templates can then be used in automations if their state changes.