Look for in our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

Ethernet test on M-Duino PLUS version

Introduction


In this post it is showed how to test Ethernet communication on M-Duino PLUS version


Requirements

Ethernet PLC:           MDuino Family Products


Ethernet2 Library:             Arduino Ethernet2.h library


Software


Connecting an M-Duino to a router through Ethernet and uploading the test sketch, the M-Duino is able to complete the test.  

Next is showed the code:

#include <Ethernet2.h>
#include <SPI.h>
byte _mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEA };
byte _ip[] = {10, 20, 30, 15};
byte _server[] = {216, 58, 201, 132};

/////////////////////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600L);
  Serial.println("mduino-plus Ethernet test started");
  Ethernet.begin(_mac, _ip);
  Serial.print("IP: ");
  Serial.println(Ethernet.localIP());
}

////////////////////////////////////////////////////////////////////////////
void loop() {
EthernetClient client;
if (client.connect(_server, 80)) {
  Serial.println("Ethernet OK");
  client.stop();
} else {
  Serial.println("Ethernet FAIL");
}

delay(5000);
}

See also:

 
Uploading a sketch to a PLC using ethernet (Part 1):   Uploading an sketch to a PLC using Ethernet - Step 1- Ariadne Bootloader

Uploading a sketch to a PLC using ethernet (Part 2):  Uploading a sketch to a PLC using Ethernet - Step 2 - binary file

Uploading a sketch to a PLC using ethernet (Part 3):  Uploading a sketch using Ethernet - step 3- TFTP CLIENT