#include <SPI.h>
#include <Ethernet.h>
char buffer[1000];
int sensorPin = A0; // select the input pin for the potentiometer
int sensorPin2 = A1;
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
int sensorValue2 = 0;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,177 };
byte server[] = { 192,168,1,185 }; // Google
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 80);
void setup() {
pinMode(ledPin, OUTPUT);
Ethernet.begin(mac, ip);
Serial.begin(9600);
digitalWrite(ledPin, HIGH);
delay(sensorValue);
digitalWrite(ledPin, LOW);
delay(sensorValue);
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected");
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop() {
sensorValue = analogRead(sensorPin);
sensorValue2 = analogRead(sensorPin2);
sprintf(buffer, "GET /arduino/connet.php?val1=%d&val2=%d HTTP/1.0",sensorValue ,sensorValue2);
client.println(buffer);
client.println(); }
this code insert only one line through GET. i dont undrestand why insert only one and not work loop :(
Most likely the connection closes...
char buffer[1000];
this code insert only one line through GET. i dont undrestand why insert only one and not work loop :(
1000 chars = 1000 Bytes. Arduino has only 2KiB of RAM memory (2048 Bytes), so you are allocating half of the memory it has. Change it to 70 and you'll save a lot of RAM.
I don't know what is the problem in your caso, but perhaps you are using all the RAM and Arduino is freezing.
You can also try:
sprintf(buffer, "GET /arduino/connet.php?val1=%d&val2=%d HTTP/1.0\r\n\r\n", sensorValue, sensorValue2);
client.print(buffer);