Some years back when Spark Core came out i made LCD temperature display that shows outside temperature.
Now i need to make some changes to code (trying to compile with 0.6.2 to spark core) and i get: “could not compile error” when i uncomment some code that is currently commented out. What causes that?
Code: https://go.particle.io/shared_apps/5a9a7e3c15004cd73c001224
-edit-
It seems that atof causes not to compile.
if(response.status == 200){
String web = response.body;
// Serial.println(response.body);
String aeg2 = web.substring(32,38);
String aeg1 = web.substring(30,32);
// int gmt = atof(aeg1.c_str());
// int tund = gmt + 3;
int tund = 3;
timeStr = "";
if(tund<10){timeStr += " ";}
timeStr += tund;
timeStr += aeg2;
timeStr += "";
int last = web.lastIndexOf('"');
int previous = web.lastIndexOf('"', last - 1 );
String result = web.substring(previous+1, last);
//hetkeTemp = atof(result.c_str());
update = 1;
}
It takes care of compiling when i change both instances to atoi.
But as i did last programming years ago and i was novice then at best i can’t make any sense out of those strings i’m trying to read.
Here’s what i want to do:
I want to read 2 values from Thingspeak site where i upload my outside temperature data.
Upper temp is current temp, in middle are daily min and max with timestamp. Bottom is time of last update.
Why it stopped working in first place is that thingspeak rearranged order few days ago. Field1 value used to be last and created_at was first if i recall correctly.
Can someone help me make changes that are needed so i can see what outside temperature is again?
One thing that i forgot to mention is that i’m running out of flash space. Current code is 98,1% used space.
Therefore i can’t really import any more library’s.
Judging by the code snippet you provided above, I’d suspect some potential for streamlining the code to reduce flash utilisation.
And if you want to do yourself something good, treat yourself to a Photon which does away with that problem without any alteration to the code
I use the Txt endpoints to drive all sorts of Javascript gauges on webpages.
However, when using JSON or XML, the ThingSpeak API can perform a good bit of data analysis and return “almost any” results you want. READ API Parameters
With @ScruffR 's suggestion of the JSON Library, you could reduce your CODE to a few lines by letting ThingSpeak’s API perform the workload.