Values not received in Ubidots

Two questions:
Question 1: I am using a BME280 sensor with an esp32 trying to send data to Ubidots using MQTT. Connection is fine, using the library UbidotsEsp32Mqtt.h. All readings normal.

Background: ESP is in deep sleep, wakes up, performs reading of temp and humidity, stores the values in variables. Correct values is saved, I run a function to send these values to Ubidots with the following code:

if (!ubidots.connected()) {
    ubidots.reconnect();
  }

  ubidots.add("temperature", tempToSend);
  ubidots.publish(DEVICE_LABEL);

  ubidots.add("humidity", humToSend);
  ubidots.publish(DEVICE_LABEL);

  /* Close MQTT client cleanly */
  ubidots.disconnect();

Problem is: only temp value is being sent, humidity value is not being sent at the same moment, just once in a while, or not at all.

Using ubidots.setDebug(true) it seems that the values are being published:
From Serial monitor:

15:38:32.172 -> publishing to TOPIC: 
15:38:32.172 -> /v2.0/devices/bme280
15:38:32.172 -> JSON dict: {"temperature": [{"value": 25.688}]}
15:38:32.172 -> publishing to TOPIC: 
15:38:32.172 -> /v2.0/devices/bme280
15:38:32.172 -> JSON dict: {"humidity": [{"value": 37.97}]}
15:38:42.215 -> ets Jun  8 2016 00:22:57

Question 2:
On another esp32 I run an hcsr04 sensor, which is in deep sleep, wakes up once in a while to read sensor and check it against a given value.
If the value is above a threshold, it is meant to send a value, and text. Following is my code simplified to test those two actions.

void sendMQTTmessage(int value, char* text) {
  if (!ubidots.connected()) {
    ubidots.reconnect();
  }

  ubidots.add("topic", value, text);
  ubidots.publish(DEVICE_LABEL);

  /* Close MQTT client cleanly */
  ubidots.disconnect();
}
if(reading > threshold) {
    //send MQTT
    value = reading;
    text= "Text!";  //test value 
    sendMQTTmessage(value, text);
    esp_deep_sleep_start();
  }

In this test Ubidots is not receiving anything, but if I completely remove everything associated with the “text” variable, and just sending the int value, it works just fine. I cannot get it to send a context. Any ideas what I am doing wrong?

I have checked the API labels in Ubidots countless times, for both devices and variables. They match the ones I put into my code.

I am able to answer this one, the function sendMQTTmessage expects as first input an int type, the reason you don’t get it to work with the text variable, is as it seems to be a char array or a String object. If you expect to receive ints, you must send ints, not floats or strings.

Bear in mind dots values may be int or float, if you need to send strings you must use the dots’ context.

Best

Thank your for answering, but I do not see how I am wrong? I have put the text variable in the desired field of the sendMQTTmessage function, where char* is expected?
The value variable containing the reading value is of type float, so I have not ecountered any problem there. The sendMQTTmessage is expecting first value to be int, and second to char*, which I believe coheres with the UbidotsEsp32Mqtt.h library. The ubidots.add function in the library is as follows:

void Ubidots::add(const char* variableLabel, float value, char* context) {
  add(variableLabel, value, context, NULL, NULL);
}

value = reading is a float value. I replaced input variable in sendMQTTmessage to be float to see if that changes anything, but there is still no change in the result. I do not really understand what I am doing wrong with the context variable. I can send value fine alone, but not with context. In the serial monitor it does seem to be sent using the Ubidots debugger (with context), but nothing is received in Ubidots, not even value.

My end goal would be to have text show up in a metric og html widget in ubidots, so I do not really need to send text using MQTT. A solution could be to just send 0, 1… eg. and somehow assign each number a string, so it will convert in Ubidots and “print out” the corresponding text to each number before displaying in the widget. But I have not yet found out a way to do that either.