Some help with the GET/POST commands

Hey all,

I wouldn’t say I’m a beginner to programming, but I’m definitely a novice when it comes to working with Arduino and the Spark Core.

Just to give you an idea on what I’m working towards: I’m using the Core to connect to a weather rss feed(http://weather.yahooapis.com/forecastrss?w=2478307), get the temperature and current condition then displaying that information in color through LEDs.

It’s the first part of this process that I’m not too sure on(retrieving info from the site). Does anyone have any helpful resources on the GET/POST commands? I believe I need to be using them in this scenario, but I’m not quite sure on how to go about it. Usually I’m pretty good at just trial and error of seeing what code does what. Is there a way to get output from the Core(like println) without attaching an LCD to it?

Also, the parsing info problem. I found a nice library called TextFinder, that would do what I need if I were working through arduino, but I’m not. Is there a recommended application for opening library files?

Any points in the right direction would be much appreciated.

Thanks

I don’t have an answer for you, but I recall some similar conversations taking place in this thread that might help out some.

TCP Client not reading anything

Dave O

Hey thanks! Looks like someone in that thread is working on basically the same thing(I suppose that’s a good thing).

1 Like

Hi @ross,

No worries! I also posted about this here:

hi @Dave!

I tried your code, and i don’t know why but my core is stopping usually after the 4th loop.

This is my code:

#define LIB_DOMAIN "domain.com"
TCPClient client;

void setup() {
Serial.begin(9600); 
}

void loop() {
delay(5000);
client.connect(LIB_DOMAIN, 80);
client.println("GET /example.php?arg1=value&arg2=another HTTP/1.0");
client.println("Host: " LIB_DOMAIN);
client.println("Content-Length: 0");
client.println();
Serial.println("test v1.1"); 
}

I’m monitoring both the server (from the example.php) and through the Serial port, and after the first 3-4 attempts usually the core just stops doing it’s job. I can’t even update the firmware, can’t do anything with it. Usually it ends up with a hard reset :frowning:

Do you have any ideas what can be the issue? Any other -more stable- method to send variables to a server within 3-5-10seconds? (I need to push these as the actions will be triggered by the user, calling the core won’t be a solution at this project.)

Thank you,
Noten

I think it opens new socket every loop, so it hits limit after ~4 times. I’m not sure if as simple as delay(100) and client.stop() at end helps, or do you have to make if-else structure to reuse already estabilished connection.

1 Like

hey @weakset!

Not exactly sure which line solved it, but now it’s working as it should!
I added these at the end of the loop:
client.stop();
delay(100);

Thx! Cheers! :smile:

1 Like