Here is my latest attempt but it still doesn't work.
database name = 1stClassElec and the table is temp_1
#include <SPI.h>
#include <WString.h>
#include <Ethernet.h>
#define READING_PIN 0
/*
Simple Ethernet Test
Arduino server outputs simple text to browser
The circuit:
* Arduino Duemilanove
* Arduino Ethernet shield
* Basic FTDI breakout 5V
*LED connected to GND and digital pin 4 via resistor
By Minde
http://www.sciencprog.com/
*/
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x11, 0xAC }; //physical mac address
byte ip[] = { 192, 168, 1, 19 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(80); //server port
byte sampledata=50; //some sample data - outputs 2 (ascii = 50 DEC)
//int ledPin = 4; // LED pin
//char link[]="http://www.scienceprog.com/"; //link data
String readString = String(30); //string for fetching data from address
//boolean LEDON = false; //LED status flag
//#################################################
double R1 = 10000.0; //resistance put in parallel
double V_IN = 5.0;
double A = 1.129148e-3;
double B = 2.34125e-4;
double C = 8.76741e-8;
double K = 9.5; // mW/dec C – dissipation factor
double SteinhartHart(double R)
{
// calculate temperature
double logR = log(R);
double logR3 = logR * logR * logR;
return 1.0 / (A + B * logR + C * logR3 );
}
//#################################################
void setup(){
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
//Set pin 4 to output
// pinMode(ledPin, OUTPUT);
//enable serial datada print
Serial.begin(9600);
}
void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
//#############################################
double adc_raw = analogRead(READING_PIN);
//Serial.println(adc_raw);
double V = adc_raw / 1024 * V_IN;
//calculate resistance
double R_th = (R1 * V ) / (V_IN - V);
double kelvin = SteinhartHart(R_th) - V*V/(K * R_th);
int celsius = kelvin - 273.15;//was double but changed to int to remove decimal places
Serial.println();
client.print("Temp.");
client.print(" is ");
client.print(celsius);
client.println(".C");
client.print("POST /http://192.168.1.20/ard_log/update_db.php?temp=");
Serial.print("GET /ard_log/update_db.php?temp=");
client.print(celsius);
Serial.print(celsius);
client.println(" HTTP/1.1");
Serial.println(" HTTP/1.1");
client.println("Host: http://192.168.1.20");
Serial.println("Host: http://192.168.1.20");
client.println("User-Agent: Arduino");
Serial.println("User-Agent: Arduino");
client.println("Accept: text/html");
Serial.println("Accept: text/html");
client.println();
delay(1000);
//##############################################
//clearing string for next read
readString="";
//stopping client
client.stop();
}
}
}