Good day,
I need Arduino register the data in the database through the GET method.
The Arduino copilou but does not send parameters, php's right to use parameters manually because it registers in the bank, if anyone can help me would be very grateful.
the following codes:
ARDUINO :
#include <SPI.h>
#include <Ethernet.h>
#include "EmonLib.h"
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0D, 0x96, 0xB4 };
byte ip[] = { 192,168,1,3 }; // my local host
char server[]={"192.168.1.1"};// internet provedor
EthernetClient client;
// Definicion de pines
EnergyMonitor emon1;
//Tensao da rede eletrica
int rede = 111.1;
//Pino do sensor SCT
int pino_sct = 2;
void setup()
{
Serial.begin(9600);
emon1.current(pino_sct, 29);
Ethernet.begin(mac, ip); // inicializa ethernet shield
delay(1000); // espera 1 segundo despues de inicializar
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
void loop()
{
double Irms = emon1.calcIrms(1480);
Serial.print(Irms); // Escribe en el puerto serial para monitorear
Serial.print(" Corrente");
Serial.println("Conectando..");
if (client.connect(server, 80)) { // Se conecta al servidor
client.print("GET http://192.168.1.3/arduino.php?Irms="); // Envia los datos utilizando GET
client.print(Irms);
client.println(" HTTP/1.0");
client.println("User-Agent: Arduino 1.0");
client.println();
Serial.println("Conexion exitosa");
}
else
{
Serial.println("Falla en la conexion");
}
if (client.connected()) {}
else {
Serial.println("Desconectado");
}
client.stop();
client.flush();
delay(3000); // espera 15 segundos antes de volver a sensar la temperatura
}
PHP - ERROR LINE 11 Notice: Undefined index: Irms in C:\wamp\www\arduino.php on line 11
<?php //poner en htdocs de XAMPP, nombrado archivo.php $mysql_servidor = "192.168.1.3"; $mysql_base = "test"; $mysql_usuario = "root"; $mysql_clave = ""; date_default_timezone_set("America/Santiago"); $hora = time(); $fechaRegistro="".date("d-m-Y H:i:s", $hora); $valor = htmlspecialchars($_GET["Irms"],ENT_QUOTES); echo "".$fechaRegistro."---".$valor; // Valida que esten presente todos los parametros if (($fechaRegistro!="") and ($valor!="")) { mysql_connect($mysql_servidor,$mysql_usuario,$mysql_clave) or die("Imposible conectarse al servidor."); mysql_select_db($mysql_base) or die("Imposible abrir Base de datos"); $sql = "insert into teste (corrente, potencia) values ('$fechaRegistro','$valor')"; mysql_query($sql); }else { echo "paso por aqui"; } ?>Thanks, Victor
OBS : If you do not understand something is because I am using a translator, I'm from Brazil and do not speak English.