# Unable to data to Esp32

**URL:** <https://discourse.nodered.org/t/unable-to-data-to-esp32/46228>\
**Category:** General\
**Created:** [25 May 2021 18:44 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228 "2021-05-25T18:44:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![saqib](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@saqib](https://discourse.nodered.org/u/saqib)\
**Post date:** [25 May 2021 18:44 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/1 "2021-05-25T18:44:32Z")

</div>

Hello Everyone I am working on a project in which i have to take user input(numeric value) and send it to esp32 using mosquitto mqtt broker. can anyone guide me how to do that and how to parse the data in esp32? i have done receiving part and its working perfectly but unable to send the data., kindly guide me..

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [25 May 2021 19:40 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/2 "2021-05-25T19:40:35Z")

</div>

have you tried a google search 'esp32 mqtt tutorial'?

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [25 May 2021 19:47 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/3 "2021-05-25T19:47:52Z")

</div>

You might want to share what you have done so far as well.

---

<div class="post-metadata">

**Author:** ![saqib](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@saqib](https://discourse.nodered.org/u/saqib)\
**Post date:** [25 May 2021 19:56 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/4 "2021-05-25T19:56:12Z")

</div>

Yes i have checked almost all tutorials but no one is sending user input to esp32 they are just doing the receiving part

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [25 May 2021 20:00 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/5 "2021-05-25T20:00:50Z")

</div>

> [@saqib](#):
>
> Yes i have checked almost all tutorials

There are hundreds of examples - search Google for mqtt esp32

Check out the function named `messageReceived` in this one...  
"ESP32 MQTT Tutorial - [valvers.com](http://valvers.com)" [ESP32 MQTT Tutorial - valvers.com](https://www.valvers.com/open-software/arduino/esp32-mqtt-tutorial/)

---

<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:** [25 May 2021 20:43 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/6 "2021-05-25T20:43:59Z")

</div>

> [@saqib](#):
>
> send it to esp32 using mosquitto mqtt broker.

You don't send data from one mqtt client to another. You send it to the broker from one client, and the other client subscribes to the topic in order that the broker sends it the data. What you need to google for is how to subscribe to an mqtt broker from an esp32.

---

<div class="post-metadata">

**Author:** ![molesworth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/molesworth/32/11748_2.png) [@molesworth](https://discourse.nodered.org/u/molesworth)\
**Post date:** [25 May 2021 22:40 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/7 "2021-05-25T22:40:48Z")

</div>

I'm using ESP8266 devices which are very similar to the ESP32, and there are several MQTT libraries available. I found @knolleary's "pubsubclient" ([GitHub - knolleary/pubsubclient: A client library for the Arduino Ethernet Shield that provides support for MQTT.](https://github.com/knolleary/pubsubclient)) very easy to work with, and have had no problems sending and receiving packets using it.

For parsing packets that will depend on your message format, but in my case I use JSON for all messages and include cJSON ([GitHub - DaveGamble/cJSON: Ultralightweight JSON parser in ANSI C](https://github.com/DaveGamble/cJSON)) in my ESP8266 build. It's small, fast and handles all the basic JSON structures I need.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [26 May 2021 03:14 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/8 "2021-05-26T03:14:46Z")

</div>

Another very useful library is... **ArduinoJson** especially if you need to serialise or deserialise MQTT data.  
Make sure you get the latest version (6.18.0) as it makes dealing with data a 'breeze'.

> **[ArduinoJson: Efficient JSON serialization for embedded C++](https://arduinojson.org/)**
>
> ArduinoJson is a JSON library for Arduino, IoT, and any embedded C++ project. It supports JSON serialization, JSON deserialization, MessagePack, streams, and fixed memory allocation. It has a simple API, it’s easy to use, and it’s trusted by...

> **[bblanchon/ArduinoJson](https://github.com/bblanchon/ArduinoJson)**
>
> 📟 JSON library for Arduino and embedded C++. Simple and efficient.

---

<div class="post-metadata">

**Author:** ![saqib](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@saqib](https://discourse.nodered.org/u/saqib)\
**Post date:** [26 May 2021 06:18 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/9 "2021-05-26T06:18:40Z")

</div>

Thank you Everyone for your kind response, I have successfully received the data in esp32.. data is in json format need to parse only i will look in for json libraries. thankyou anyways

---

<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:** [25 July 2021 06:19 UTC](https://discourse.nodered.org/t/unable-to-data-to-esp32/46228/10 "2021-07-25T06:19:05Z")

</div>

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