ESP32 DIY Weather Station MQTT Discovery Problems

This is my first post, so I apologize in advance if it’s in the wrong place.

I couldn’t find a weather station, which handled APRS and Home Assistant, so I started this project. Plus it gives me an excuse to learn circuits and C++.

Home Assistant works great when I manually put the mqtt entries in configuration.yaml. (Except the time, but that’s another issue). I would like it to be discovered, so if I send a board to someone less technologically inclined it automagically works. Plus it’s the principle of figuring it out and learning something new.

MQTT Discovery - Home Assistant has gotten me most of the way. I’m probably overlooking something obvious that’s documented.

The original code can be found in the following link. I apologize for the code, it’s my first C++ program. (yeah I haven’t even done hello world). The config json is at the bottom of example_settings.h

I am getting timeouts from Mosquitto. I’ve tried increasing the keepalive to a bit over 5 minutes and still get it. I only need it to report every 5 minutes. I plan on eventually turning the wifi off between broadcasts to save on battery.
Client WeatherStation has exceeded timeout, disconnecting.

Below shows MQTT Explorer’s view of the configs

Below is the temp config MQTT Explorer is seeing
homeassistant/sensor/WeatherStation/state

{
  "dev": {
    "name": "WeatherStation",
    "mf": "Darty",
    "sw": "0.1",
    "ml": "Prototype",
    "sa": "Outside",
    "ids": [
      "Prototype"
    ]
  },
  "unique_id": "WeatherStation_temp",
  "device_class": "temperature",
  "name": "Outside Temperature",
  "unit_of_meas": "°F",
  "value_template": "{{ value_json.Temp }}",
  "object_id": "sensor.WeatherStation_temp",
  "avty_t": "homeassistant/sensor/WeatherStation/LWT",
  "pl_avail": "Online",
  "pl_not_avail": "Offline",
  "state_topic": "homeassistant/sensor/WeatherStation/state",
  "force_update": true
}

homeassistant/sensor/WeatherStation/state

{
  "device": "WeatherStation",
  "Time": "2022-05-26T03:58:30",
  "Temp": 68,
  "RH": 55,
  "Pres": 9780,
  "wDir": 180,
  "wSpd": 0,
  "wGust": 0,
  "rLstHr": 0,
  "rMidngt": 0,
  "rLst24hrs": 0,
  "SoilMoisture": 0,
  "Battery": 101
}
1 Like