esphome / esphome/feature-requests

RP2040: MQTT client support for Raspberry Pi Pico W

Open
#1,966 12 comments 53 reactions 0 assignees View on GitHub
component: mqtt component: rp2040
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you have/What new integration you would like**

I would like to see MQTT client support for ESPHome on the Raspberry Pi Pico W platform.

The existing MQTT client only supports the ESP8266 and ESP32 platforms.

- https://github.com/OttoWinter/async-mqtt-client

Previously, attempts to build ESPHome with MQTT for Raspberry Pi Pico W failed with compilation errors.

```
# file: picodebug.yaml
esphome:
name: picodebug
build_path: /tmp/.esphome

rp2040:
board: rpipicow
framework:
platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git

logger:
api:
password: ""
ota:
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

mqtt:
broker: 192.0.2.1
```

- the JSON component wants a free_heap number but it's hardware specific and only available for ESP8266/ESP32
- the MQTT library similarly only support ESP8266/ESP32

Example:

```
Compiling /tmp/.esphome/.pioenvs/picodebug/src/esphome/components/json/json_util.cpp.o
src/esphome/components/json/json_util.cpp: In function 'std::string esphome::json::build_json(const json_build_t&)':
src/esphome/components/json/json_util.cpp:29:34: error: 'free_heap' was not declared in this scope
29 | size_t request_size = std::min(free_heap, (size_t) 512);
| ^~~~~~
```
- see https://github.com/esphome/esphome/blob/dev/esphome/components/json/json_util.cpp#L19-L29

...and:

```
Compiling /tmp/.esphome/.pioenvs/picodebug/src/esphome/components/mqtt/custom_mqtt_device.cpp.o
In file included from /tmp/.esphome/.piolibdeps/picodebug/AsyncMqttClient-esphome/src/AsyncMqttClient.h:4,
from src/esphome/components/mqtt/mqtt_backend_arduino.h:6,
from src/esphome/components/mqtt/mqtt_client.h:15,
from src/esphome/components/mqtt/custom_mqtt_device.h:7,
from src/esphome/components/mqtt/custom_mqtt_device.cpp:1:
/tmp/.esphome/.piolibdeps/picodebug/AsyncMqttClient-esphome/src/AsyncMqttClient.hpp:14:2: error: #error Platform not supported
14 | #error Platform not supported
```

- see https://github.com/OttoWinter/async-mqtt-client/blob/master/src/AsyncMqttClient.hpp#L8-L15

The MQTT component has since been disabled for the RP2040 platform:

- https://github.com/esphome/esphome/pull/4025

**Please describe your use case for this integration and alternatives you've tried:**

I would like to send sensor data over MQTT for recording outside of Home Assistant (HA) as well as do signalling with other services available only over MQTT.

**Additional context**

It might be worth considering that there are open discussions on the topic of MQTT clients:

- https://github.com/esphome/feature-requests/issues/811

NOTE: Signal your interest in this feature with the "thumbs up" on this post. No need to spam the issue thread with "me too" comments (they cause unnecessary email notifications).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.