Send UDP Datagrams from enc28j26 to pc

hello everyone,
i want to send data from arduino to my pc using enc28j60 .
For that i'm using ETHERCARD library in order to interface the enc28j60 with arduino, the wiring i'm using is the one provided in the library documentation when i test some code they work (so i don't have a problem with the wiring).
but when it comes to communication between PC and enc28j60 using UDP Datagrams it doesn't work even my compilation is fine and on the PC side i'm using a listener to print the incoming data but it doesn't print anything when i test the code
this is the code i'm using :slight_smile: #include <EtherCard.h>
#include <IPAddress.h>
static byte mymac[] = { 0x1A,0x2B,0x3C,0x4D,0x5E,0x6F };
byte Ethernet::buffer[700];
static uint32_t timer;

char payload[] = "123";
uint8_t nSourcePort = 1234;
uint8_t nDestinationPort = 1234;

void setup () {
Serial.begin(9600);

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");

ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);

ether.printIp("SRV: ", ether.hisip);
}

void loop () {

uint8_t ipDestinationAddress[IP_LEN];
ether.parseIp(ipDestinationAddress, "192.168.1.113");

if (millis() > timer) {
  timer = millis() + 5000;
 //static void sendUdp (char *data,uint8_t len,uint16_t sport, uint8_t *dip, uint16_t dport);

ether.sendUdp(payload, sizeof(payload), "1234", ipDestinationAddress, "1234");

}
}
i wonder if anyone could help me and thank you

you can use my EthernetENC library. see the Ethernet library UDP examples

"1234" is not an integer. Try: 1234

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.