Arduino to Server

Hi I am having trouble to my Arduino Project. My computer, where my Web and MySqL Server i running, has an IP address of

Arduino Code:

#include <EtherCard.h>

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;

char website[] PROGMEM = "";

static void my_callback (byte status, word off, word len) {
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);

void setup () {

  if (ether.begin(sizeof Ethernet::buffer, mymac,22) == 0) 
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
  ether.printIp("SRV: ", ether.hisip);

void loop () {
  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.print("<<< REQ ");
    ether.hisport = 80;//to access  local host
    itoa(myInt, myIntAsString, 10);
    ether.browseUrl(PSTR("/write_data.php?"), "value=ghghgh", website, my_callback);

PHP Code:

$dbconnect= mysqli_connect($server,$dbusername,$dbpassword); 
$dbselect= mysqli_select_db($dbconnect,"sensor");
$sql="insert into sensor.mydata values ('".$myvariable."')"; 

With this. it says DNS Failed @ server.
I am using Arduino MEGA 2560 and ENC28J60

1 Like

My computer, where my Web and MySqL Server i running, has an IP address of

What is the router address, then?

char website[] PROGMEM = "";

So, why are you using some other address?

Why are you having to do a DNS lookup (Domain Name Services) when you already KNOW the IP address that DNS is supposed to return?