and this pde file with a function called GetWebData
float PanelTemp; float PoolTemp; int ControllerMode; int SetTempInc; int PanelCriticalTemp; long CumulativePumpRuntime; int PumpsOnOff; String StatusText;
And all I am trying to do is to pass this string 10.0,11.0,1,2,3,1234567,6,"This is a test" into the pde file so it will print on the screen!
Can I bugger get this to work. The problem is in the fact there are absolutely no bog basic idiot proof tutorials on how to do this. even pomax's jumps around and doesnt provide zip files with the working code for you to hack at
and get the data into this simple test sketch which i will run in processing.js
float PanelTemp; float PoolTemp; int ControllerMode; int SetTempInc; int PanelCriticalTemp; long CumulativePumpRuntime; int PumpsOnOff; String StatusText;
I can't use any libraries as its going to be javascript and I dont understand enough about javascript to properly format the code.
I have been playing around with formatting the data based on a local CSV file version. I would prefer to grab the CSV from the web server but it seems I can't do that with loadStrings() as it only works for a local file (Or file on the same domain).
It looks like I am being forced to use JSON as that seems to be the only method to get data from a remote web server but the learning curve seems horrendously steep. I can't even make head nor tail of POMAX's guide and I have looked all over the web and can't find anything simpler. They all assume more knowledge of javascript than I have and none of them have a working zip file containing all the code and a sample JSON file to play with.
Seems I have to create some javascript code to pass the object to the processing js pde. Im really surprised that there arent more working examples out there
Can anyone help with the javascript code to take the feed above and put it into my sketch. Once i have a working example I will understand far more what I am doing
I hope someone can show me the error of my ways. It's a simple problem. I have written a sketch which takes input from the Arduino and sends it to thingspeak. I am making a post using a /GET command via client.write.
The program runs for a few hours then give out of memory. It starts off using around 25Mb, the gradually increased until I get an out of memory error
I am certain I haven't done anything silly like loading images in the draw loop.
It seems my problem is caused by creating a lot of new instances of the myClient object. Initially I had declared it in the setup routine and whilst I thought this would work fine I found that it would run once and then give a
So I moved it to a function called void UpdateThingSpeak() and called it from the main loop. The code is all below
Now I get the problem where I am out of memory after a few hours. I have tried everything I can think of. Issuing a
myClient.stop();
myClient=null;
myClient = new Client(this, Server,80);
In the hope that if the old client was stopped and set to null the System.gc() would release the memory.
Please could someone help. I'm sure they will tell me I am doing something very stupid
As It doesnt seem to let me add all the code I have just included the bit with the problem
P.S Its just the bit which creates the new client in the UpdateThingSpeak() function, unless someone can spot something else obvious
Many many thanks
void UpdateThingSpeak() // Formats the output and sends it as a GET request to the ThingSpeak servers { url = ("GET /update?key="+APIKey+"&field1="+PanelTemp+"&field2="+PoolTemp+"&field3="+ControllerMode+"&field4="+SetTempInc+"&field5="+PanelCriticalTemp+"&field6="+CumulativePumpRuntime+"&field7="+PumpsOnOff+"&status="+StatusText+"\n");
if (myClient!=null) { myClient.write(url); // myClient.stop(); // myClient=null; // Destroy the object to allow System.gc() to release the memory myClient = new Client(this, Server,80); // Create a new Client connection to the ThingSpeak Server } }