[SOLVED] Help with Mega 2560 and W5100 - just does not connect!

Ive read a few threads, but cant work out where my problem is - i hope that someone could help point out to me where it is going wrong…

i have a Sainsmart Mega 2560 R3 and a red mini W5100 Ethernet board && Ethernet is to my NETGEAR CG3100 modem router

i have W5100 connected to Mega:

5V to 5V
GND to GND
MI to 50
MO to 51
CK to 52
SS to 10

is this all correct?

i uploaded the Blynk Arduino_Ethernet example and this is what is output:

[0] Blynk v0.3.4
[0] Getting IP...

when i try the Blynk Arduino_Ethernet_Manual sketch, this is the serial output:

[0] Using static IP
[0] Blynk v0.3.4
[1300] My IP: 255.0.0.0
[5001] Connecting to 10.0.0.10:8442
[10002] Connecting to 10.0.0.10:8442
[15003] Connecting to 10.0.0.10:8442
[20004] Connecting to 10.0.0.10:8442
[25005] Connecting to 10.0.0.10:8442

the LEDs on the W5100 are this:

PWR LED is solid
LINK LED occasional flashes
SPD is solid
FDX is solid
COL is not lit
Rx flashes often
Tx does not flash at all

this is my LAN section:

i have tried two separate W5100 modules and two separate Mega modules, 3 Ethernet cables and i am sure my hardware is fine. can anyone help me to work out why i can t connect?

Could you please show your sketch?

/**************************************************************
 * 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.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 *
 * This example shows how to use Arduino Ethernet shield (W5100)
 * to connect your project to Blynk.
 * Feel free to apply it to any other example. It's simple!
 *
 * NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
 *       DON'T use them in your sketch directly!
 *
 **************************************************************/

#define BLYNK_DEBUG
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#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[] = "xxx";

void setup()
{
  Serial.begin(9600);
 //Blynk.begin(auth);
  // You can also specify server.
  // For more options, see BoardsAndShields/Arduino_Ethernet_Manual example
  //Blynk.begin(auth, "your_server.com", 8442);
  Blynk.begin(auth, IPAddress(192,168,0,177), 8442);
}

void loop()
{
  Blynk.run();
}


and

/**************************************************************
 * 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.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example shows how to configure static IP with Ethernet.
 * Be sure to check ordinary Ethernet example first!!!
 *
 * NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
 *       DON'T use them in your sketch directly!
 *
 **************************************************************/

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#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[] = "xxx";

IPAddress server_ip (192, 168, 0, 1);

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip (192, 168, 0, 177);
IPAddress dns_ip     (192, 168, 0, 1);
IPAddress gateway_ip (192, 168, 0, 1);
IPAddress subnet_mask(255, 255, 255,   0);

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, server_ip, 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // Or like this:
  //Blynk.begin(auth, "blynk-cloud.com", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

void loop()
{
  Blynk.run();
}

when i ping the IP address (192.168.0.177) it says “destination host unreachable”

does that mean anything?

You are calling Blynk.begin with your router as the server’s address. Try the text in the comments below that line instead and see what happens (e.g. “blynk-cloud.com” instead of server_ip.)

RD7

For me, it’s much easier to use the Arduino_Ethernet example and just paste in the Auth Key that was sent to my email via the smartphone app. I then add a button widget in the app and set it to “switch”, and assign it to pin 13, or any other pin I have an LED or relay connected to and once I click the play button on the top of the app, I can toggle the LEDs or relays till my heart’s content. It really is that simple and is what has captivated my attention when I think of the things I can now easily do with my Megas. Blynk rocks!!!

1 Like

thanks for your reply, but no, still no good.

um - do the spaces in the addresses matter?

[0] Blynk v0.3.4
[0] Using static IP
[1300] My IP: 192.80.199.0
[5001] Connecting to blynk-cloud.com:8442
[10002] Connecting to blynk-cloud.com:8442
[15003] Connecting to blynk-cloud.com:8442

for me - that doesn’t work:

[0] Blynk v0.3.4
[0] Getting IP...

that’s why i posted this thread to get some help working out why…

yes, for sure!!!

i have multiple blynk projects working over WiFI via ESP8266 - i want to use a MEGA to get all the GPIOs - it is very frustrating that i cant connect via Ethernet to use the Mega…

THIS schematic shows SS to be on D53, not 10. Can you check to see if this caused problems?

2 Likes

CS pin has to be on 53! It’s default in the library. I use this pins:

 * 50         = (MI)SO Ethernet
 * 51         = (MO)SI Ethernet
 * 52         = SCK Ethernet
 * 53         = CS Ethernet

I also document this in my sketch. Comes in handy every now and than :wink:

1 Like

sorry - i was using this tutorial: https://arduino-info.wikispaces.com/ethernet

where is this library?

the sketch i see shows:

 * NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
 *       DON'T use them in your sketch directly!

but i thought this was for a Uno maybe?

anyways, i have put the W5100 ‘SS’ wire to the ‘53’ pin on the Mega but still not working…

BUT it does look like my IP is the one i coded!!! so this is progress!

[0] Using static IP
[0] Blynk v0.3.4
[1300] My IP: 0.0.0.0
[5001] Connecting to 192.168.0.1:8442
[10002] Connecting to 192.168.0.1:8442
[15003] Connecting to 192.168.0.1:8442

where is this available?

BTW - my Tx light on the W5100 never blinks, only the Rx light???

Rx light only probably means you have a bad cable. Have you tried another? Your remark on the pins is correct. The lower ones are for the uno. With thr library I mean the Blynk ethernet library :slight_smile:

i have looked in the .h Ethernet library, but cant find mention on pins?

can you be more precise where i can find it?

i have tried 3 x cables, 2 x W5100 modules and 2 x 2560 modules…

( i mean the Rx light on the W5100, not the Mega)

is it one of my router setting that is the problem???

as @myggle says - it should just work!

I just loaded and ran the Arduino_Ethernet_Manual sketch to see if I can get stuck too, but no, I was still able to cycle my relays. Are both of your w5100’s a sainsmart red mini? I primarily use an Ethermega, but I also have a chinese Mega clone with a counterfeit Ethernet shield and they both work just fine. I’m at a loss why you can’t get through.

/**************************************************************
 * 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.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example shows how to configure static IP with Ethernet.
 * Be sure to check ordinary Ethernet example first!!!
 *
 * NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
 *       DON'T use them in your sketch directly!
 *
 **************************************************************/

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#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[] = "MyAuthKey";

IPAddress server_ip (10, 0, 0, 10);

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 10,   0,   0,  20);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 10,   0,   0,   1);
IPAddress subnet_mask(255, 255, 255,   0);

void setup()
{
  Serial.begin(9600);
  //Blynk.begin(auth, server_ip, 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // Or like this:
  Blynk.begin(auth, "cloud.blynk.cc", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

void loop()
{
  Blynk.run();
}


[0] Blynk v0.3.3
[0] Using static IP
[1300] My IP: 10.0.0.20
[5001] Connecting to cloud.blynk.cc:8442
[17881] Ready (ping: 38ms).

1 Like

thanks for checking :slight_smile:

no they are from Banggood… i actually have two blue ‘shields’ coming from eBay supposedly - these have been ‘sent’ for a while, but i ordered the red ones as the blue eBay ones were taking so long! maybe i’ll be reposting here if the blue shields ever arrive…

yeah, i have never had a problem with non-genuine stuff… (except FTDI adapters!!!)

i just ordered a new AC1900 router… it will be here by Friday… (wont really need Ethernet if this thing is as good as it says!!!)

My chinese boards took over a month to arrive.

Also, in my notes that I keep for research done, On pin 53 (SS), I have written the following;

Pin 53 - Ethernet hardware SS (must be set to output for SPI to work)

Can you try;

pinMode(53, OUTPUT);
1 Like

thanks, i tried that, but no good

shows:

[0] Blynk v0.3.4
[0] Using static IP
[1300] My IP: 0.0.0.0
[5001] Connecting to blynk-cloud.com:8442

but i moved the connections to the ICSP header and made some progress,

i see My IP as the one i set:

[0] Blynk v0.3.4
[0] Using static IP
[1300] My IP: 192.168.0.177
[5001] Connecting to blynk-cloud.com:8442

but still no connect…

Will you try the Arduino Ethernet sketch again with just the Auth key, and no IP or MAC configurations now that you’re on the ICSP header?

1 Like

:frowning: here’s output (SS @ pin 10):

[0] Blynk v0.3.4
[0] Getting IP...
[60464] DHCP Failed!

:frowning: here’s output (SS @ pin 53):

[0] Blynk v0.3.4
[0] Getting IP...

so does DHCP issues indicate router? or hardware??

FKN HARDWARE!!!

i decided to check hardware, since last time i checked - i probably didn’t have a good software, but now i was sure my software should be OK, i changed the Mega board, then the W5100 board, then just said “sure, why not, change the cable (again!)

then bang!

[0] Blynk v0.3.4
[0] Getting IP...
[2524] My IP: 192.168.0.146
[5001] Connecting to blynk-cloud.com:8442
[5349] <msg 2,1,32
<XXX
[5584] >msg 0,1,200
[5585] Ready (ping: 234ms).
[5586] <msg 17,1,96

surely this is good serial output!!!

yes - this is the serial i wanted to see!!!

>vw21
[241833] >msg 20,128,6
>vw20
[244206] >msg 20,132,6
>vw1

thank you Michael!!! :heart_eyes:

1 Like