# Sending Blob Image Data through MQTT on ESP32

**URL:** https://forums.losant.com/t/sending-blob-image-data-through-mqtt-on-esp32/5208
**Category:** Help
**Tags:** mqtt, device
**Created:** [August 9, 2023, 1:36am UTC](https://forums.losant.com/t/sending-blob-image-data-through-mqtt-on-esp32/5208 "2023-08-09T01:36:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Eric\_Wang1](https://avatars.discourse-cdn.com/v4/letter/e/9fc29f/32.png) [@Eric\_Wang1](https://forums.losant.com/u/Eric_Wang1)
#### Post date: [August 9, 2023, 1:36am UTC](https://forums.losant.com/t/sending-blob-image-data-through-mqtt-on-esp32/5208/1 "2023-08-09T01:36:23Z")

</div>

Hi,

I am trying to send image data from my ESP32 CAM to losant using the Blob attribute. However, I could not get it working properly.

This is my current code

```auto
*camera_fb_t *fb = esp_camera_fb_get();*
* *
* if (!fb) {*
* Serial.println("Failed to get camera frame buffer");*
* return;*
* }*

* char *input = (char *)fb->buf;*
* char output[base64_enc_len(3)];*
* String imageFile = "";*

* *
* for (int i=0;i<fb->len;i++) {*
* base64_encode(output, (input++), 3);*
* if (i%3==0) imageFile += String(output);*
* }*

* StaticJsonDocument<204800> jsonBuffer;*
* JsonObject root = jsonBuffer.to<JsonObject>();*

* root["camera"] = imageFile;*
* device.sendState(root);*

```

Could anyone help me with this please? Thank you very much.

Regards,  
Eric

---

<div class="post-metadata">

### Author: ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)
#### Post date: [August 9, 2023, 12:54pm UTC](https://forums.losant.com/t/sending-blob-image-data-through-mqtt-on-esp32/5208/2 "2023-08-09T12:54:32Z")

</div>

Hi @Eric_Wang1, and welcome to the Losant forums!

I’m unfamiliar with that particular library so I’ll focus on the usual debugging techniques:

- Can you log out the encoded image on the device?
- Any errors being logged device-side?
- What is the [content-type](https://docs.losant.com/devices/blobs/#content-types) set for your blob attribute?
- Is anything appearing in the [device’s live communication log](https://docs.losant.com/devices/overview/#device-communication-log) when you try to report state?
