Hello!
I’m a newby and already got the GPS working to give me the location of my e-bike every 30 seconds. Now I wanted to add the reading of it’s battery level through an analog read, but I’m getting this error: “invalid conversion from ‘int32_t {aka long int}’ to ‘const char*’ [-fpermissive]”. Any help please?
Here’s the code:
#include <AssetTrackerRK.h>
#include "AssetTrackerRK.h"
int transmittingData = 1;
long lastPublish = 0;
int delaySeconds = 30;
const int BikeBattRead = A0;
AssetTracker t = AssetTracker();
FuelGauge fuel;
void setup() {
t.begin();
pinMode(BikeBattRead, INPUT);
t.gpsOn();
Serial.begin(9600);
Particle.function("tmode", transmitMode);
Particle.function("LiPo", LiPoStatus);
Particle.function("gps", gpsPublish);
Particle.function("BikeBatt", BBPublish);
Particle.keepAlive(30);
}
void loop() {
t.updateGPS();
if(millis()-lastPublish > delaySeconds*1000){
lastPublish = millis();
Particle.publish("BB", analogRead(BikeBattRead), 60, PRIVATE);
Serial.println(t.preNMEA());
if(t.gpsFix()){
if(transmittingData){
Particle.publish("G", t.readLatLon(), 60, PRIVATE);
}
Serial.println(t.readLatLon());
}
}
}
int transmitMode(String command){
transmittingData = atoi(command);
return 1;
}
int gpsPublish(String command){
if(t.gpsFix()){
Particle.publish("G", t.readLatLon(), 60, PRIVATE);
return 1;
}
else { return 0; }
}
int LiPoStatus(String command){
Particle.publish("L",
"v:" + String::format("%.2f",fuel.getVCell()) +
",c:" + String::format("%.2f",fuel.getSoC()),
60, PRIVATE
);
if(fuel.getSoC()>10){ return 1;}
else { return 0;}
}
int BBPublish(String command){
Particle.publish("BB",
analogRead(BikeBattRead), 60, PRIVATE);
}
It’s right in the “analogRead(BikeBattRead)” commands that I get the error.
Please help me out.