I am using FONA808 and Feather MO to log location to Adafruit IO:
I follow that tutotial https://learn.adafruit.com/geofencing-w ... ng-the-gps
I configure my Arduino IDE 1.6.5 as is described into the Feather MO tutoria.
All works excepted the function
Code: Select all
void logLocation(float latitude, float longitude, float altitude, Adafruit_MQTT_Publish& publishFeed) {
// Initialize a string buffer to hold the data that will be published.
char sendBuffer[120];
memset(sendBuffer, 0, sizeof(sendBuffer));
int index = 0;
// Start with '0,' to set the feed value. The value isn't really used so 0 is used as a placeholder.
sendBuffer[index++] = '0';
sendBuffer[index++] = ',';
// Now set latitude, longitude, altitude separated by commas.
dtostrf(latitude, 2, 6, &sendBuffer[index]);
//sprintf(&sendBuffer[index], "%.6f", latitude);
index += strlen(&sendBuffer[index]);
sendBuffer[index++] = ',';
dtostrf(longitude, 3, 6, &sendBuffer[index]);
//sprintf(&sendBuffer[index], "%6f", longitude);
index += strlen(&sendBuffer[index]);
sendBuffer[index++] = ',';
dtostrf(altitude, 2, 6, &sendBuffer[index]);
//sprintf(&sendBuffer[index], "%9.6f", altitude);
// Finally publish the string to the feed.
sprint(F("Publishing location: "),2);
sprintln(sendBuffer,2);
if (!publishFeed.publish(sendBuffer)) {
sprintln(F("Publish failed!"),2);
txFailures++;
}
else {
sprintln(F("Publish succeeded!"),2);
txFailures = 0;
}
}
Then, at the top of my sketch, I added stdlib.hmo808.ino: In function 'void logLocation(float, float, float, Adafruit_MQTT_Publish&)':
mo808:787: error: 'dtostrf' was not declared in this scope
'dtostrf' was not declared in this scope
Code: Select all
#include <Adafruit_FONA.h>
// For Adafruit IO
#include <Adafruit_MQTT.h>
#include <Adafruit_MQTT_FONA.h>
#include <stdlib.h> // because dtostrf()
Is there a way to use dtostrf()?
I tried to use sprintf insetad, but sprintf does not store the value and it display this:
MQTT
Publishing location: 0,,,
Thnak for your advises