Arduino_Mega_Ethernetshield

Hello , IM Using Arduino Mega 2560 and ethernetshield w5100 ,
i used blynk to connect them over internet ( Im new here) my trouble is everytime i try to connect them i get that error in serial monitor ([0] Getting IP… [60731] DHCP Failed!)
The code im using is as following:

/*************************************************************
  Download latest Blynk library here:


  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.



  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  NOTE:
  BlynkTimer provides SimpleTimer functionality:
    http://playground.arduino.cc/Code/SimpleTimer

  App project setup:
    Value Display widget attached to Virtual Pin V5
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "hGZtKPzpd1mXylysOrUTtSxLPTG_gR_K";

#define W5100_CS  10
#define SDCARD_CS 4

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth);
/*   You can also specify server:
  Blynk.begin(auth, "blynk-cloud.com", 80);
  Blynk.begin(auth, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second*/
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
} 

Please edit your post to add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

1 Like

like that?

Yes.

Arduino Ethernet shields can be very temperamental. Sometimes they will only work when plugged directly into the router, other times only when plugged into a switch. Sometimes they won’t work at all!

You could try this sketch, and provide all the connection details including an IP address for the shield, your Gateway and DNS server details etc.

I persisted with Ethernet shields for a while before eventually seeing the light and choosing better hardware…

Pete.

Arduino tells me this when i used your code
‘’’
Error compiling for board Arduino/Genuino Mega or Mega 2560
‘’’

It compiles fine for me.
The Arduino IDE (version 1.8.10) says:

Sketch uses 18230 bytes (7%) of program storage space. Maximum is 253952 bytes.
Global variables use 552 bytes (6%) of dynamic memory, leaving 7640 bytes for local variables. Maximum is 8192 bytes.

Try restarting you PC. If that doesn’t work then it’s probably an issue with your IDE installation.

Pete.

Sorry but those aren’t backticks. Google back ticks for your particular keyboard. It took me a long time to find them on my iPhone.

:scream::scream::scream::scream::scream: old topic. For some reason it popped up unread and I don’t have the power to CLOSE it.

:rofl: :rofl: :rofl: