[SOLVED] Ethernet shield WS5200 connection

I use an arduino mega with ethernetshield WS5200 connected to a router (DHCP).

While the ethernet shield works fine in another sketch, I cannot get it working with blink.

I guess I do not use the right parameters.

This works in another sketch:


#include <EthernetV2_0.h>
#define W5200_CS 10
#define SDCARD_CS 4

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);//

//setup
Ethernet.begin(mac, ip);

I tried different Blynk examples and tried with different parameters but with no result…

Very likely stupid beginner errors.

What would be the right parameters?

Thanks

Please post full code that doesn’t work for you and please use formatting.

Sorry. I hope this will be better…

This is the sketch I used:

#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[] = "9e90d10c9d5c4afb90ad4b65ce4d7xxx";

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 (192,168,1,177);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 192,168,0,   1);
IPAddress subnet_mask(255, 255, 255,   0);

#define W5200_CS  10
#define SDCARD_CS 4

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

  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();
}

And the answer from the serial monitor:

[0] Blynk v.0.4.0. on Arduino Mega
[0] Using static IP
[1300] IP:179.3.250.128
[5001] Connecting to blynk-cloud.com:8442
[10002] Connecting to blynk-cloud.com:8442

I think that I may have solve the issue.

With the Ethernet shield WS5200, the libraries were not correct. This seems to connect, still have to test it with an app…

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <EthernetV2_0.h>   // for ethernet shield WS5200
#include <BlynkSimpleEthernetV2_0.h>  //  for ethernet shield WS5200

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

#define W5200_CS  10
#define SDCARD_CS 4

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

  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,1,100), 8888);
}

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

Indeed now it works perfectly…

You just used wrong example. :slight_smile: