ENC28j60+ Ethercard + MYSQL + PHP

Estou fazendo meu TCC onde eu envio a temperatura e a umidade para um banco de dados MySQL usando a biblioteca Ethercard GitHub - njh/EtherCard: EtherCard is an IPv4 driver for the ENC28J60 chip, compatible with Arduino IDE unica biblioteca que eu consegui fazer funcionar com o Arduíno mega 2560 e o ethernet shild ENC28j60, o php e o banco de dados estão funcionando, o único problema é quando executa a serial escreve "falha no DNS"
serial teste
ethernet controller ok
ip192.168.0.110
gatway192.168.0.1
servidor0.0.0.0
falha no dns
49.57.50.46
servidor0.0.0.0
sensor lido com sucesso
30.70
46.00
codigo

#include <bufferfiller.h>
#include <enc28j60.h>
#include <EtherCard.h>
#include <net.h>
#include <stash.h>

#include <DHT.h>
#include <DHT_U.h>
#include <SPI.h>

#define DHTPIN A0       
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);



float h;
float t;

char scriptData[50];

static byte mymac[]={0x74,0x69,0x69,0x2d,0x30,0x31};
byte Ethernet::buffer[500];

const char website[] PROGMEM = "192.168.0.107";
static byte myip[]={192,168,0,110};
static byte gwip[]={192,168,0,1};

static uint32_t timer;
Stash stash;
static void my_callback (byte status, word off, word len) {
//  Serial.println(">>>");
  Ethernet::buffer[off+300] = 0;
 // Serial.print((const char*) Ethernet::buffer + off);
  Serial.println("...");
}


void setup() {
 Serial.begin(9600);
 Serial.println("serial teste");
 if(ether.begin(sizeof Ethernet::buffer, mymac, 53)==0)
    Serial.println("conexao falhou");
 else
     Serial.println("ethernet controller ok");
 ether.staticSetup(myip, gwip);
 ether.printIp("ip",ether.myip);
  ether.printIp("gatway",ether.gwip);
 ether.printIp("servidor",ether.dnsip);
 if(!ether.dnsLookup(website))
    Serial.println("falha no dns");
 ether.printIp(ether.hisip,"192.168.0.107");
 ether.printIp("servidor", ether.hisip);
 
 dht.begin(); //inicializa o sensor DHT11
 
}

void loop() {
     h = dht.readHumidity();
  // Lê a umidade
   t = dht.readTemperature();
  // Lê a temperatura em Celsius

  if (isnan(t) || isnan(h)) 
  {
    Serial.println("Failed to read from DHT");
  } 
  else
  {
    Serial.println("sensor lido com sucesso");
    Serial.println(t);
    Serial.println(h);

   ether.packetLoop(ether.packetReceive());
 
   if (millis() > timer) {
    timer = millis() + 5000;
    ether.persistTcpConnection(true);

         sprintf(scriptData, "temperatura=%d&umidade=%d", t, h);
      ether.browseUrl(PSTR("/arduino.php"),scriptData,  website, my_callback);
    

 }
  }
  delay (2000);
}

php
' ' '

Bloco de Citação

<?php
   $conn= new mysqli("localhost" , "root", "","arduino");

   if($conn-> connect_errno){
      echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
  exit();
   }
   $temperatura = $_GET['temperatura'];
   $umidade = $_GET['umidade'];
   if($temperatura == null || $umidade == null){
      echo "valor nullo";
   }

   else{
   	$sql = "INSERT INTO tcc (temperatura,umidade)
      VALUES ('$temperatura', '$umidade')";
   

 if ($conn->query($sql) === TRUE) {
  echo "New record created successfully";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}
}
?>

alguém sabe como resolver ?

Não tendo equipamento para criar este sistema para testar:
Pode ser porque 0.0.0.0 não é um servidor DNS válido?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.