sir,i making project create arduino based mini web-server using ethernet shield.i able establish connection using arduino web server and display on local web-server.but not able store on our own wamp server.the code wrote below read send data php page , storing our own web-server.
the sensor used dht11 (to read humidity , temperature data).
please help:-
#include <dhcp.h>
#include <dns.h>
#include <ethernet.h>
#include <ethernetclient.h>
#include <ethernetserver.h>
#include <ethernetudp.h>
#include <dht.h>
#include <ethernet.h>
#include <spi.h>
byte ip[] = { 169, 254, 103, 88 };
byte ip2[]= { 169, 254, 103, 98 };
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xee }; // reserved mac address
ethernetclient client;
//ipaddress ip(192,168,0,12);
#define dhtpin 2 // sensor pin
#define dhttype dht11 // sensor type - adafruit library offers support more models
dht dht(dhtpin, dhttype);
long previousmillis = 0;
unsigned long currentmillis = 0;
long interval = 250000; // reading interval
int t = 0; // temperature var
int h = 0; // humidity var
int i=5;
string data;
void setup() {
ethernet.begin(mac,ip2);
serial.begin(9600);
serial.println("configure ethernet using dhcp");
//int error = client.connect(ip2, 80);
// serial.println(client.connect(ip2, 80));
/* if (client.available()) {
serial.println(" configure ethernet using dhcp");
}
else{
serial.println("failed co");
}
serial.println("configure ethernet using dhcp");
*/
dht.begin();
delay(10000); // give sensor time start
h = (int) dht.readhumidity();
t = (int) dht.readtemperature();
data = "";
}
void loop(){
currentmillis = millis();
if(currentmillis - previousmillis > interval) { // read once per interval
previousmillis = currentmillis;
h = (int) dht.readhumidity();
t = (int) dht.readtemperature();
}
if (client.connect(ip,80)) { // replace server address
client.println("get /review1/add.php?temp1=");
client.print(t);
client.print("&hum1=");
client.print(h);
client.println(" http/1.1");
client.println("host: 169.254.103.88"); // server address here too
client.println("content-type: application/x-www-form-urlencoded");
client.print("content-length: ");
client.println(data.length());
client.println();
}
//else{
// serial.println("dfsdfd");
//}
if (client.connected()) {
client.stop(); // disconnect server
}
//delay(3000); // wait 5 minutes before sending again
}
the sensor used dht11 (to read humidity , temperature data).
please help:-
#include <dhcp.h>
#include <dns.h>
#include <ethernet.h>
#include <ethernetclient.h>
#include <ethernetserver.h>
#include <ethernetudp.h>
#include <dht.h>
#include <ethernet.h>
#include <spi.h>
byte ip[] = { 169, 254, 103, 88 };
byte ip2[]= { 169, 254, 103, 98 };
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xee }; // reserved mac address
ethernetclient client;
//ipaddress ip(192,168,0,12);
#define dhtpin 2 // sensor pin
#define dhttype dht11 // sensor type - adafruit library offers support more models
dht dht(dhtpin, dhttype);
long previousmillis = 0;
unsigned long currentmillis = 0;
long interval = 250000; // reading interval
int t = 0; // temperature var
int h = 0; // humidity var
int i=5;
string data;
void setup() {
ethernet.begin(mac,ip2);
serial.begin(9600);
serial.println("configure ethernet using dhcp");
//int error = client.connect(ip2, 80);
// serial.println(client.connect(ip2, 80));
/* if (client.available()) {
serial.println(" configure ethernet using dhcp");
}
else{
serial.println("failed co");
}
serial.println("configure ethernet using dhcp");
*/
dht.begin();
delay(10000); // give sensor time start
h = (int) dht.readhumidity();
t = (int) dht.readtemperature();
data = "";
}
void loop(){
currentmillis = millis();
if(currentmillis - previousmillis > interval) { // read once per interval
previousmillis = currentmillis;
h = (int) dht.readhumidity();
t = (int) dht.readtemperature();
}
if (client.connect(ip,80)) { // replace server address
client.println("get /review1/add.php?temp1=");
client.print(t);
client.print("&hum1=");
client.print(h);
client.println(" http/1.1");
client.println("host: 169.254.103.88"); // server address here too
client.println("content-type: application/x-www-form-urlencoded");
client.print("content-length: ");
client.println(data.length());
client.println();
}
//else{
// serial.println("dfsdfd");
//}
if (client.connected()) {
client.stop(); // disconnect server
}
//delay(3000); // wait 5 minutes before sending again
}
Arduino Forum > Using Arduino > Project Guidance > Problem in sending the data from arduino to our own database
arduino
Comments
Post a Comment