Go Down

Topic: Leonardo connect W5100 not work (Read 8122 times) previous topic - next topic

billop

Mar 25, 2020, 07:45 am Last Edit: Mar 25, 2020, 07:50 am by billop
Hi Everyone,
I'm try connect W5100 ethernet board, but it's not send message.


Ethernet program as blew:
#define W5100
#include "SocketIOClient.h"
#include "Ethernet.h"
#include "SPI.h"


SocketIOClient client;

byte mac[] = { 0xAA, 0x00, 0xBE, 0xEF, 0xFE, 0xEE };
char hostname[] = "192.168.0.164";
int port = 5438;

extern String RID;
extern String Rname;
extern String Rcontent;

unsigned long previousMillis = 0;
long interval = 10000;
void setup() {
pinMode(10, OUTPUT);    //for some ethernet shield on the mega : disables the SD and enables the W5100
 digitalWrite(10, HIGH);
Serial.begin(9600);
Ethernet.begin(mac);

if (!client.connect(hostname, port))
Serial.println(F("Not connected."));
if (client.connected())
{
client.send("connection", "message", "Connected !!!!");
}
else
{
Serial.println("Connection Error");
while(1);
}
delay(1000);
}

void loop()
{
 pinMode(10, OUTPUT);    //for some ethernet shield on the mega : disables the SD and enables the W5100
 digitalWrite(10, HIGH);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval)
{
 previousMillis = currentMillis;
 //client.heartbeat(0);
 client.send("atime", "message", "Time please?");
}
if (client.monitor())
{
Serial.println(RID);
if (RID == "atime" && Rname == "time")
{
Serial.print("Time is ");
Serial.println(Rcontent);
}
}
}


Serial port output as blew:

Go Up