diff --git a/ampel-firmware/mqtt.cpp b/ampel-firmware/mqtt.cpp
index e300bafdec77bdf507c6c503f1ffb34f88fac593..3f1ea47954bd0b33a8d9fcdfaa8bea8edcef47a8 100644
--- a/ampel-firmware/mqtt.cpp
+++ b/ampel-firmware/mqtt.cpp
@@ -24,9 +24,7 @@ namespace config {
 #  include <WiFiClientSecure.h>
 #endif
 
-//TODO: Find better way. Only one of both will be used
-WiFiClientSecure secureClient;
-WiFiClient espClient;
+WiFiClient *espClient;
 
 PubSubClient mqttClient;
 
@@ -46,11 +44,13 @@ namespace mqtt {
     if (config::mqtt_encryption) {
       // The sensor doesn't check the fingerprint of the MQTT broker, because otherwise this fingerprint should be updated
       // on the sensor every 3 months. The connection can still be encrypted, though:
-      secureClient.setInsecure(); // If not available for ESP32, please update Arduino IDE / PlatformIO
-      mqttClient.setClient(secureClient);
+      WiFiClientSecure *secureClient = new WiFiClientSecure();
+      secureClient->setInsecure();
+      espClient = secureClient;
     } else {
-      mqttClient.setClient(espClient);
+      espClient = new WiFiClient();
     }
+    mqttClient.setClient(*espClient);
 
     mqttClient.setServer(config::mqtt_server, config::mqtt_port);