# Send txt file to Esp32?

**URL:** <https://discourse.nodered.org/t/send-txt-file-to-esp32/48425>\
**Category:** General\
**Created:** [14 July 2021 19:24 UTC](https://discourse.nodered.org/t/send-txt-file-to-esp32/48425 "2021-07-14T19:24:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuisPereira](https://avatars.discourse-cdn.com/v4/letter/l/9d8465/32.png) [@LuisPereira](https://discourse.nodered.org/u/LuisPereira)\
**Post date:** [14 July 2021 19:24 UTC](https://discourse.nodered.org/t/send-txt-file-to-esp32/48425/1 "2021-07-14T19:24:13Z")

</div>

Hi

I need to receive some data in a ESP32, at the moment i have this data in a txt file in a SD card connected to the esp32, so everytime it reads the sd card it get the information it needs for the day, its like a set of configurations for the day. But soon I'll need to have this data being fed remotely, and I can not acess the router where the esp32 will be to do any port forwarding, so I'm guessing that in esp32 could act as client only and fetch this data from a node red mqtt or http server, or, the esp32 as a server and I manage to send a txt file from the node red to esp32 (it could be txt file or any other format as long as it can carry 5KB). But having the esp32 as a server would require do some port forwarding in its router (at least thats the only way I can think), and I don't have access to that.  
So, does anyone nows a way to send data like this from node ed to esp32? Most information I find is the other way around (from esp32 to node red).

Thank you.

Cheers, Luís Pereira.

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [14 July 2021 21:33 UTC](https://discourse.nodered.org/t/send-txt-file-to-esp32/48425/2 "2021-07-14T21:33:13Z")

</div>

Install a MQTT client on the ESP32 and subscribe to a topic that would contain the data you need to send it.

> **[ESP32 MQTT Publish Subscribe with Arduino IDE | Random Nerd Tutorials](https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/)**
>
> This project shows how to use MQTT communication protocol with the ESP32 to publish messages and subscribe to topics. We’ll publish readings from a BME280 sensor and control an output. The ESP32 we’ll be programmed using Arduino IDE.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 July 2021 06:22 UTC](https://discourse.nodered.org/t/send-txt-file-to-esp32/48425/3 "2021-07-15T06:22:38Z")

</div>

I think that if @LuisPereira needs to get data _into_ the esp from the internet without port forwarding then the esp will have to subscribe to an mqtt broker that is outside the esp local network. Then node red can publish to that broker and the esp can pick it up.

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [15 July 2021 07:20 UTC](https://discourse.nodered.org/t/send-txt-file-to-esp32/48425/4 "2021-07-15T07:20:03Z")

</div>

Yes, @LuisPereira I was understanding the ESP was the only item (of concern) that was behind this inaccessible router.

As long as the ESP can reach the internet, the ESP should still be able to connect to another network (that you can control) containing the broker, as long as you can supply a public IP/port for the ESP client to link to.

---

<div class="post-metadata">

**Author:** ![LuisPereira](https://avatars.discourse-cdn.com/v4/letter/l/9d8465/32.png) [@LuisPereira](https://discourse.nodered.org/u/LuisPereira)\
**Post date:** [15 July 2021 10:07 UTC](https://discourse.nodered.org/t/send-txt-file-to-esp32/48425/5 "2021-07-15T10:07:16Z")

</div>

Thank you for your answers. Yes it seems feasible, I already got a RPI with nodered running, I'll just I have to pratice a few examples until I manage how to send a .txt 5KB data trough MQTT payload.  
Regarding the server access, I'll probably set a public IP on No-IP platform for the RPI (Node red server) and that way the ESP32 can access it from anywhere.

Again, thank you!  
Cheers, Luís Pereira.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 July 2021 11:10 UTC](https://discourse.nodered.org/t/send-txt-file-to-esp32/48425/6 "2021-07-15T11:10:46Z")

</div>

> [@LuisPereira](#):
>
> how to send a .txt 5KB data trough MQTT payload

You should able to put the whole of the text in the payload and publish it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 September 2021 11:11 UTC](https://discourse.nodered.org/t/send-txt-file-to-esp32/48425/7 "2021-09-13T11:11:23Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
