Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Base64 MQTT ERROR: data missing required value
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Base64 MQTT ERROR: data missing required value

by regenerativa on Tue Aug 25, 2020 6:26 pm

I'm trying to send a photo from ESP32CAM to Adafruit IO:

- History on Adafruit IO feed is turned OFF
- Image is formatted to 600x800, JPEG
- Image is converted to base64 string < 104200
- Data is sent using cameraFeed -> save(image)

After sending, Adafruit IO says: "MQTT ERROR: error saving data on xxx/feeds/image, data missing required value"

Code Below:

*********

#include "esp_camera.h"
#include <base64.h>
#include "ioconfig.h" //Adafruit IO and Wifi

#define CAMERA_MODEL_AI_THINKER // Has PSRAM

//Setup MQTT Feed
AdafruitIO_Feed *cameraFeed = io.feed("camera");

void setup() {
Serial.begin(9600);
delay(3000);
Serial.setDebugOutput(true);
Serial.println();
Serial.println("CAMERA TEST");
Serial.println();

#include "camera_pins.h"
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 10000000; // was at 20
config.pixel_format = PIXFORMAT_JPEG;
config.frame_size = FRAMESIZE_SVGA; //800 x 600 necessary for Adafruit IO
config.jpeg_quality = 12;
config.fb_count = 1;

// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}

//Connect to io.adafruit.com
Serial.print("Connecting to WiFi & MQTT Server");
io.connect();

//wait for a connection
while (io.status() < AIO_CONNECTED)
{
Serial.print(".");
delay(3000);
}

//We are connected
Serial.println();
Serial.println(io.statusText());
Serial.println();
Serial.println("Taking picture");
delay(1000);

}

void loop() {

//io.run() is required for all Adafruit IO sketches
io.run();
delay(5000);

// Capture picture
camera_fb_t * fb = NULL;
fb = esp_camera_fb_get();

if(!fb) {
Serial.println("Camera capture failed");
return;
}

size_t size = fb->len;
String image = base64::encode((uint8_t *) fb->buf, fb->len);
Serial.println(image);
Serial.println("Uploading to Adafruit IO");
delay(5000);

unsigned int length();
if (image.length()>102400) {
Serial.println("Image size too big");
return;
}

//send data to Adafruit IO feeds
cameraFeed->save(image);
delay(30000);

}


Thanks!

regenerativa
 
Posts: 3
Joined: Tue Aug 25, 2020 3:45 pm

Re: Base64 MQTT ERROR: data missing required value

by brubell on Wed Aug 26, 2020 12:32 pm

You may want to try increasing the maxbuffer size

https://github.com/adafruit/Adafruit_MQ ... QTT.h#L110

brubell
 
Posts: 1079
Joined: Fri Jul 17, 2015 10:33 pm

Re: Base64 MQTT ERROR: data missing required value

by regenerativa on Thu Aug 27, 2020 2:55 pm

Thanks for your reply!

How would I go about doing this?

*Sorry total noob here

regenerativa
 
Posts: 3
Joined: Tue Aug 25, 2020 3:45 pm

Re: Base64 MQTT ERROR: data missing required value

by brubell on Fri Aug 28, 2020 10:13 am

There's an identical discussion going on over on this thread: viewtopic.php?f=56&t=163931&p=826417#p826417

I'll continue troubleshooting over there to keep the discussion in one place.

brubell
 
Posts: 1079
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.