Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFi shield issue: client.connect(server, 80) #24

Open
agdl opened this issue Jul 12, 2016 · 0 comments
Open

WiFi shield issue: client.connect(server, 80) #24

agdl opened this issue Jul 12, 2016 · 0 comments
Assignees

Comments

@agdl
Copy link
Member

agdl commented Jul 12, 2016

From @piyali1988 on January 3, 2015 0:6

client.connect(server, 80); is not working. Here is the code:

include <SPI.h>

include <WiFi.h>

include <WiFiClient.h>

include <WiFiServer.h>

undef int

undef abs

undef double

undef float

undef round

int SensorIn1 = 1;
int led_pin = 13;

char devid[] = "v90EC98310145483";

int del=100; // Amount of seconds delay between posting to google docs.

char postmsg[100];
int k=0;
int temp_av = 0;
char server[] = "api.pushingbox.com";
char ssid[] = "**_";
char pass[] = "_
";
WiFiClient client;

void setup()
{
Serial.begin(9600);
WiFi.begin(ssid, pass);
delay(1000);
Serial.println("connecting...");
}

void loop(){

int val;
val = analogRead(SensorIn1);
Serial.println(val);

// Post to Google Form.............................................
if (client.connect(server, 80))
{
k=0;
Serial.println("connected");
sprintf(postmsg,"GET /pushingbox?devid=%c&status=%d HTTP/1.1",devid,val);
client.println(postmsg);
client.println("Host: api.pushingbox.com");
client.println("Connection: close");
client.println();

Serial.println(postmsg);
Serial.println("Host: api.pushingbox.com");
Serial.println("Connection: close");
Serial.println();

 delay(1000);
 client.stop();

}
delay(1000);

if (!client.connected())
{
Serial.println();
Serial.println("disconnecting.");
client.stop();
k==1;
return;
}
}

The output I receive is
connecting....
456
disconnecting.
563
disconnecting.
and so on..
I have tried using different servers and accordingly selected the port numbers (eg 80, 443 etc) but the it never connects to the server. Kindly help.

Copied from original issue: arduino/Arduino#2531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants