Skip to content

Sending UDP datagrams from Arduino with EtherCard library to concrete IP #431

@vbgrigorevuser

Description

@vbgrigorevuser

I've checked that my arduino and shield worked, but my python server can't get arduino udp.

`#include <EtherCard.h>

static byte mymac[] = { 0x1A,0x2B,0x3C,0x4D,0x5E,0x6F };
byte Ethernet::buffer[700];
static uint32_t timer;

const int dstPort PROGMEM = 1234;

const int srcPort PROGMEM = 4321;

uint8_t ipDestinationAddress[IP_LEN];

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

// if (!ether.dnsLookup(website))
// Serial.println("DNS failed");

ether.parseIp(ipDestinationAddress, "<xx.xx.xx.xx>");

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

char textToSend[] = "test 123";

void loop () {
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(textToSend, sizeof(textToSend), srcPort, ipDestinationAddress, dstPort );
}
}`

Instead of <xx.xx.xx.xx> I have white ip for my server, port-forwarding done, but I still can't get udps from arduino. I see udp in wireshark too.

I've tested, that through internet from remove vps I can reach my server (python server, client), but from arduino it still does not work. Help me please!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions