Hey guys, i'm quite troubled by this problem im having with my Arduino Uno + Wifi shield set up. I created a scale and i'm trying to send values from the arduino to my database everytime i press the push button. However, after about 3-4 times of successfully sending the value, the next value would not send and it'd give me "No Socket Available". I've tried multiple things that some of the members on the board have suggested like adding a delay after sending the values, or using client.flush but still the problem persist.
Any help would be much appreciated!!
Here are portions of the code im using to send the HTTP request
void readData(float offset)
{
Serial.println("Reading the weight....");
delay(1000);
int sensorvalue = analogRead(A0);
Serial.print("THE OFFSET VOLTAGE IS ");
Serial.println(offset,8);
float voltage = sensorvalue*(5/1023.0);
Serial.print("the voltage is ");
Serial.println(voltage,8);
float grams = (voltage - offset)/0.0039664;
Serial.print("the grams is ");
Serial.println(grams);
//MAKE HTTP REQUEST@!@@!
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected to server");
delay(1000);
Serial.println("Sending weight to database... please wait");
delay(1000);
client.print("GET /recipes/scaledata/");
client.print(grams);
client.println(" HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
delay(1000);
}
else
Serial.println("Connection failed.");
void loop() {
// if there are incoming bytes available
// from the server, read them and print them:
while(client.connected()) {
while (client.available()&&status) {
char c = client.read();
Serial.write(c);
delay(1000);
}
}
client.stop();
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting from server.");
client.flush();
client.stop();
// do nothing forevermore:
while(true);
}
}
Thanks ![]()