Sending Blob Image Data through MQTT on ESP32

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

*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

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 set for your blob attribute?
  • Is anything appearing in the device’s live communication log when you try to report state?