Compiling error: 'bye dns[]' declared as different kind of symbol

I am trying to build an automated watering system for my lucky bamboo plant. I am playing around with the original source code and have ran into a peculiar error. I have done quite a bit of googling and have come across a few discussions that suggest it may be an IDE related error.
Syntax reads:

sketch:51: error: 'byte dns[]' redeclared as different kind of symbol
\arduino-1.0.2-windows\arduino-1.0.2\libraries\Ethernet/Dhcp.h:64: error: previous decleration of '<anonymous enum> dns'

I tried running this code in IDE versions 1.0, 1.0.1, and 1.0.2 - the two earlier versions come out with a different kind of error. I’ve tried replacing the Ethernet library on 1.0.2 with an earlier version but that did not work. So I am sure there’s gotta be something wrong with the code. Any ideas?

#include <Ethernet.h>
#include <SPI.h>
#include <aJSON.h>
#include <SimpleTimer.h>


  Pin configuration
int moistureInputPin = 0;
int moistureOutputPinTop = 2;
int moistureOutputPinBottom = 3;
int valveOutputPin = 9;

  How often to check the plant needs watering
  and to send readings to the server
unsigned long pollMillis = 60000; // 1 min

  How dry the soil should get before watering.
  (Max) 1023 = Drier than the Atacama Desert
        400  = Damp
  (Min) 0    = Have you used copper instead of soil? 
// Watered value = 75-76

int waterAtMoisture = 1023 - 400;

  When the soil gets dry enough to warrant a watering,
  how many millis to open the valve for.
int waterForMillis = 3500;

  Cube Server IP
byte server[] = { 23, 21, 244, 111 };

  Local IP settings
byte mac[] = { 0x6E, 0x58, 0xB8, 0x2F, 0xF7, 0x89 };
byte ip[] = { 192, 168, 2, 20 }; 
byte subnet[] = { 255, 255, 255, 0 };
byte gateway[] = { 192, 168, 2, 1 };
byte dns[] = { 8, 8, 8, 8 };

EthernetClient client;
SimpleTimer timer;

void setup() {
  pinMode(valveOutputPin, OUTPUT);


  Ethernet.begin(mac, ip, dns, gateway, subnet);

  Serial.print("My IP address: ");

  timer.setInterval(pollMillis, poll);

void loop() {;

  Main function that is run once per poll
void poll() {
  Serial.print("Polling... ");

  //Using int for watered rather than boolean
  //as the cube server doesn't report metrics 
  //on booleans very well
  int moisture = getSoilMoisture();
  int watered = 0;


  if(moisture > waterAtMoisture) {
    watered = 1;

  postToServer(moisture, watered);

  Drives a current though two digital pins
  and reads the resistance through the
  analogue pin
int getSoilMoisture(){
  //Drive a current through the divider in one direction

  //Take a reading
  int reading = analogRead(moistureInputPin);

  //Reverse the current

  //Stop the current

  return reading;

  Gives the plant a two second blast of water
void waterThePlant() {
  digitalWrite(valveOutputPin, HIGH);
  digitalWrite(valveOutputPin, LOW);

  Posts a JSON document to the cube server 

  The JSON document describes the soil
  moisture and whether the plant was

    "data": {
      "moisture": 600,
      "watered": 0

  Using int rather than boolean for 'watered'
  as cube metric querying is limited with booleans 
void postToServer(int moisture, int watered) {
  while(!client.connected()) {
    if (client.connect(server, 80)) {
    } else {
      Serial.println("Connection failed");

  aJsonObject* rootJson = aJson.createArray();

  aJsonObject* event = aJson.createObject();
  aJson.addItemToArray(rootJson, event);
  aJson.addStringToObject(event, "type", "moisture");
  aJsonObject* data = aJson.createObject();
  aJson.addItemToObject(event, "data", data);
  aJson.addNumberToObject(data, "moisture", moisture);
  aJson.addNumberToObject(data, "watered", watered);

  char* moistureJsonStr = aJson.print(rootJson);

  client.println("POST /1.0/event/put HTTP/1.0");
  client.println("Content-Length: " + String(strlen(moistureJsonStr)));
  client.println("Connection: keep-alive");

I should also mention that I tried changing 'dns' to another name, but the (aJson) library I am using starts generating multiple other errors.

I would assume dns is delcared already in <Ethernet.h>, and it may not be a type byte. You should research that and check some examples rather than randomly “hacking” or guessing/assuming. :wink:

I’ve forgotten the exact syntax for initializing an already declared array, but you might be able to simply drop “byte” from that statement. i.e. dns[] = { 8, 8, 8, 8 };

Thank you for your input!

I am a complete newbie when it comes to programming…so this is pretty difficult at this stage of the game hehe

What do I need to look for to tell if dns is defined in the Ethernet.h file? If I change or remove ‘byte,’ IDE gives the declaration of array error.

This is my Ethernet.h

#ifndef ethernet_h
#define ethernet_h

#include <inttypes.h>
//#include "w5100.h"
#include "IPAddress.h"
#include "EthernetClient.h"
#include "EthernetServer.h"
#include "Dhcp.h"

#define MAX_SOCK_NUM 4

class EthernetClass {
  IPAddress _dnsServerAddress;
  DhcpClass* _dhcp;
  static uint8_t _state[MAX_SOCK_NUM];
  static uint16_t _server_port[MAX_SOCK_NUM];
  // Initialise the Ethernet shield to use the provided MAC address and gain the rest of the
  // configuration through DHCP.
  // Returns 0 if the DHCP configuration failed, and 1 if it succeeded
  int begin(uint8_t *mac_address);
  void begin(uint8_t *mac_address, IPAddress local_ip);
  void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server);
  void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
  void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
  int maintain();

  IPAddress localIP();
  IPAddress subnetMask();
  IPAddress gatewayIP();
  IPAddress dnsServerIP();

  friend class EthernetClient;
  friend class EthernetServer;

extern EthernetClass Ethernet;


I should also mention that I tried changing 'dns' to another name, but the (aJson) library I am using starts generating multiple other errors.

What other name? What other errors? The name "dns" is local to your sketch. You should be able to change it to anything you want.