Hola gente, estoy armando un proyecto con arduino uno, la idea es recolectar unos datos y mandarlos a un script de php y de ahí grabar en una DB. El problema es que cuando realizo el GET me da un error y no se como solucionarlo.
hay algunas lineas comentadas ya que por el momento todavía no esta conectado ningún sensor.
#include <SoftwareSerial.h>
//String ssid ="yourSSID";
//String password="yourPassword";
SoftwareSerial esp(10, 11);// RX, TX
String data;
String server = "192.168.10.102"; // www.example.com
String uri = "recibir.php?";// our example is /esppost.php
//int DHpin = 8;//sensor pin
//byte dat [5];
String temp ,hum, solicitud;
void setup() {
//pinMode (DHpin, OUTPUT);
esp.begin(9600);
Serial.begin(9600);
//reset();
//connectWifi();
}
void loop () {
//start_test ();
// convert the bit data to string form
//hum = String("80");
hum = "80";
//temp= String("25");
temp = "25";
data = "temperatura=" + temp + "&humedad=" + hum;// data sent must be under this form //name1=value1&name2=value2.
httppost();
delay(1000);
}
void httppost () {
esp.println("AT+CIPSTART=1,\"TCP\",\"" + server + "\",80");//start a TCP connection.
if( esp.find("OK")) {
Serial.println("TCP connection ready");
}
delay(1000);
String postRequest =
"GET " + uri + " HTTP/1.0\r\n" +
"Host: " + server + "\r\n" +
"Accept: *" + "/" + "*\r\n" +
"Content-Length: " + data.length() + "\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: keep-alive\r\n"+
"\r\n" + data;
String sendCmd = "AT+CIPSEND=1,";//determine the number of caracters to be sent.
esp.print(sendCmd);
esp.println(postRequest.length() );
delay(500);
if(esp.find(">")) {
Serial.println("Sending..");
esp.print(postRequest);
if( esp.find("SEND OK")) {
Serial.println("Packet sent");
while (esp.available()) {
String tmpResp = esp.readString();
Serial.println(tmpResp);
}
// close the connection
esp.println("AT+CIPCLOSE");
}
}
}
Y este es el error:
+IPD,1,514:HTTP/1.1 404 Not Found
Date: Tue, 01 Aug 2017 13:52:35 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 297
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /angular/recibir.php was not found on this server.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 192.168.10.102 Port 80</address>
</body></html>
dsde ya muchas gracias.
Saludos Jonatan