Hello
Some of you has experience with Ubidots and MQTT?
I do have a Feather MO Adalogger and a Fona808. Feather is based on Arduino Zero
I imported the libraries
#include <Adafruit_FONA.h>
#include <Adafruit_SleepyDog.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_FONA.h"
I have not imported Ubidots_Fona as Feather MO does not support SoftwareSerial. But I create a new function in Adafruit_Fona to collact the GPS coorditate as does Ubidots_Fona
void Adafruit_FONA::ubidotsAdd(char *variable_id, float value, char *ctext1) {
// http://forum.arduino.cc/index.php?topic=441449.new#new
Serial.print(F("Ubidots: "));
Serial.print(variable_id);
Serial.print(F(", ")); Serial.print(value);
Serial.print(F(", ")); Serial.println(ctext1);
Serial.print(F("CurrentValue: ")); Serial.println(currentValue);
// (val+currentValue)->varName = variable_id;
val[currentValue].varName = variable_id;
// (val+currentValue)->ctext = ctext1;
val[currentValue].ctext = ctext1;
// (val+currentValue)->varValue = value;
val[currentValue].varValue= value;
currentValue++;
if (currentValue > MAX_VALUES) {
currentValue = MAX_VALUES;
}
}
I need to send data to Ubidots and I want to use MQTT to do it.
Some of you has a experience with MQTT and Ubidots?
I can send data to Adafruit IO with MQTT, but I do not know how I have to foemat the value to be sent to Ubidots, and which port to use
Here is how I do to Adafruit IO
Connection:
sprintln(F("\nMQTT connection"),2);
sprintln(F("- - - - - - - - - - - - - - - - - -"),2);
if (!mqtt.connected()) {
// Now make the MQTT connection.
int8_t ret = mqtt.connect();
if (ret != 0) {
sprintln(mqtt.connectErrorString(ret),2);
}
sprintln(F("MQTT Connected!"),2);
}
else
{
sprintln(F("MQTT already Connected!"),2);
}
Send:
// data has the value 0,46.1234,7.9999,0
logLocation(data, location_feed, positionFromSd)
bool logLocation(char* data, Adafruit_MQTT_Publish& publishFeed, bool positionFromSd)
{
// char sendBuffer[120];
char path_file[SD_PATHSIZE+FILESIZE];
// memset(sendBuffer, 0, sizeof(sendBuffer));
//int index = 0;
get_Time(yyyy,mm,dd,hh,mn,sec,range);
// Start with '0,' to set the feed value. The value isn't really used so 0 is used as a placeholder.
//sprintf(sendBuffer,"%s,%g,%g,%g","0",latitude,longitude,altitude);
// Finally publish the string to the feed.
sprint(F("\nPublishing location: "),2);
sprintln(data,2);
if (!publishFeed.publish(data)) {
sprintln(F("MQTT Publish location failed!\n"),2);
return false;
}
else
{
sprintln(F("MQTT Publish succeeded!\n"),2);
return true;
}
}
Excepted if I wrongly copied the code, the above code work.
But now, how can I do it with Ubidots?
How can I format the string?
Which port to use.
Ubidots provide exemple for Practice, but I have not found exemple for Arduino (or Adafruit).
Some of you has an experience?
Feel you free to ask me for more detail
Many thank for your help