# Envió de datos de influxdb y publicarlo en MQTT

**URL:** <https://community.influxdata.com/t/envio-de-datos-de-influxdb-y-publicarlo-en-mqtt/33511>\
**Category:** InfluxDB 2\
**Tags:** influxdb, telegraf, flux, mqtt\
**Created:** [March 11, 2024, 2:25pm UTC](https://community.influxdata.com/t/envio-de-datos-de-influxdb-y-publicarlo-en-mqtt/33511 "2024-03-11T14:25:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabianMol](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fabianmol/32/15237_2.png) [@fabianMol](https://community.influxdata.com/u/fabianMol)\
**Post date:** [March 11, 2024, 2:25pm UTC](https://community.influxdata.com/t/envio-de-datos-de-influxdb-y-publicarlo-en-mqtt/33511/1 "2024-03-11T14:25:49Z")

</div>

Hello

I am a beginner in influxdb and I am trying to send data that I have in a bucket to an MQTT, I have tried with telegraf and it did not work, so I am trying with the experimental function of mqtt.publish but I get an error.

could not execute task run: runtime error @9:8-22:6: map: failed to evaluate map function: Dialer.Dial called on an error dependency

Este es mi codigo

import “experimental/mqtt”

option task = {name: “EnvioDataToMqtt”, every: 1m, offset: 0m}

from(bucket: “recepcionDatos”)  
|\> range(start: -1h)  
|\> filter(fn: (r) =\> r.\_measurement == “medida”)  
|\> filter(fn: (r) =\> r.\_field == “value”)  
|\> map(  
fn: (r) =\>  
({r with sent:  
mqtt.publish(  
broker: “tcp://miservidor:18083”,  
topic: “dataInflux/prueba”,  
message: string(v: r.\_value),  
clientid: “mqttx”,  
password: 02342321223113",  
qos: 0,  
username: “publicador”,  
),  
}),  
)

I would be very grateful if you could tell me what other way there is to send this information.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [March 11, 2024, 8:18pm UTC](https://community.influxdata.com/t/envio-de-datos-de-influxdb-y-publicarlo-en-mqtt/33511/2 "2024-03-11T20:18:21Z")

</div>

Hello @fabianMol,  
You can use the mqtt.to() function:

> **[Experimental mqtt.to() function | Flux Documentation](https://docs.influxdata.com/flux/v0/stdlib/experimental/mqtt/to/)**
>
> mqtt.to() outputs data from a stream of tables to an MQTT broker using MQTT protocol.

Have you tried that?

---

<div class="post-metadata">

**Author:** ![fabianMol](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fabianmol/32/15237_2.png) [@fabianMol](https://community.influxdata.com/u/fabianMol)\
**Post date:** [March 12, 2024, 1:34pm UTC](https://community.influxdata.com/t/envio-de-datos-de-influxdb-y-publicarlo-en-mqtt/33511/3 "2024-03-12T13:34:51Z")

</div>

> [@Anaisdg](#):
>
> Have you tried that?

Yes, I already tried it and it didn’t work, in a forum I read that these functions were broken

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [March 26, 2024, 11:08pm UTC](https://community.influxdata.com/t/envio-de-datos-de-influxdb-y-publicarlo-en-mqtt/33511/4 "2024-03-26T23:08:10Z")

</div>

Hello @fabianMol,  
It should still work. The docs show functionality in InfluxDB 2.7.
