Hi, I have a question regarding the Mrk 1010 wifi board together with the float to string conversion. I tried to convert the float to sting using the dtostrf () function, but it's still not working. Its keep on showing the error as (expected constructor and desctructor).......something like this. I have been trying to find out this error for past few weeks already. Nothing works out.
The error problem occurs when we upload the code to the board. When we try to verify/run the code it's fine. Below is the code I used. Can anyone help me to figure this out?
This will at least compile and give an idea of the correct syntax, does not have any code to actually print the results, and I don't have a SAMD board handy for testing.
#include "avr/dtostrf.h"
const int sensorin = A0;
const int sensorin1 = A1;
int mVamps = 100;
float V = 0;
float Vrms = 0;
float Amps = 0;
char Vchar[6];
char Vrmschar[6];
char Ampschar[6];
float getVPP() { //function to allow sketch to compile
return (0.1 * random(100));
}
void service()
{
V = getVPP();
Vrms = (V / 2.0) * 0.707;
Amps = (Vrms * 1000) / mVamps;
dtostrf(V, 3, 2, Vchar);
dtostrf(Vrms, 3, 2, Vrmschar);
dtostrf(Amps, 3, 2, Ampschar);
}
void SubmitData()
{
char json[20];
strcpy(json, "\",\"Amps\":\"");
strcat(json, Ampschar);
//this should do the same thing as the strcpy() and strcat()
sprintf(json, "\",\"Amps\":\"%3.2f", Amps);
}
void setup() {
}
void loop() {
}