would like to print a web page one variable sent by the arduino but I do not get it.
#include <SPI.h>
#include <Ethernet.h>
// MAC address for your controller
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xAA, 0xBB };
// Numeric IP of the server where your website is stored.
IPAddress server(192,168,1,66);
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,1,65);
// Initialize the Ethernet client library
EthernetClient client;
void setup()
{
// start serial connection
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
}
}//close setup
void loop()
{
//Here would go the code to get the temperature value of your sensor.
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Send data using GET variable
client.print("GET /localhost/AplicacaoWeb/enviarDados.php?temp=");
client.print(20);
client.println(" HTTP/1.0");
client.println("User-Agent: Arduino 1.0");
client.println();
//Printing in the serial monitor what is going on
Serial.println("Sucessful connection. Temperature sent");
}
else {
Serial.println("Connection failed");
}
client.stop();
client.flush();
}
output
Connection failed
connected
Sucessful connection. Temperature sent
connected
Sucessful connection. Temperature sent
connected
enviarDados.php
<?php echo $_GET["temp"]; ?>
any ideas?