I'm using the Ethernet Shield 2 in a project along with the Uno. I am trying to read in strings from a software called Epson RC+, a software meant for programming Epson robots. I've tried several configurations but the Arduino will not connect to the port the controller is opening. I've been able to write to other programs, however, such as tcping and PuTTY, but after trying to emulate the same configurations in the IDE it still doesn't work.
I've set the Epson controller as the server, the configurations are as follows:
IP address: 127.0.0.1
IP mask: 2555.255.255.0
IP gateway: 127.0.0.2
It has opened port 2000 and is writing to an IP address of 127.0.0.1 (as I understand it, when opening ports as a server, you want to write to your own IP. This has worked when writing to other software).
Here is my Arduino code, sorry if it seems sloppy, I have code for other hardware commented out:
#include "Adafruit_FONA.h" // Cloud connectivity
#define SIMCOM_7000
#include <Ethernet.h> // Robot connectivity
#include <SPI.h>
char URL[150]; // buffer for dweet URL
char imei[16] = {0}; //IMEI number of shield
Adafruit_FONA_LTE fona = Adafruit_FONA_LTE(); // basically our LTE variable
#define FONA_PWRKEY 6
//unsigned int imeiLen = fona.getIMEI(imei); // get imei number
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(127, 0, 0, 2);
byte mac[] = { 0xA8, 0x61, 0x0A, 0xAE, 0x6E, 0x7C }; // physical address of shield, this should be on the sticker on the back of the shield
IPAddress ip(127, 0, 0, 200); // IP address of shield, only different from robot at 4th argument
IPAddress epsonIP(127, 0, 0, 1);// IP address of robot
EthernetClient client;
void setup()
{
Ethernet.begin(mac, ip, gateway, subnet);
Serial.begin(9600);
Serial.println("connecting...");
delay(500);
if (client.connect(epsonIP, 2000)){
Serial.println("connected to robot");
} else {
Serial.println("failed");
}
// // startup LTE shield
// fona.powerOn(FONA_PWRKEY); // power on
// fona.setFunctionality(1); // this needs to be set to 1
// fona.setNetworkSettings(F("teal")); // our handy dandy SIM card
// fona.setPreferredLTEMode(1); // Use LTE CAT-M only, not NB-IoT
}
void loop()
{
// if an incoming client connects, there will be bytes available to read:
if (client.connected() == true) {
Serial.println(client.read());
}
// if (client.available()) {
// String line = client.readString();
//
// #ifdef SIMCOM_7000
// Serial.println("sending data to dweet...");
// sprintf(URL, "dweet.io/dweet/for/%s?temp=%s&batt=%s", imei, line);
//
// if (!fona.postData("GET", URL))
// Serial.println(F("Failed to complete HTTP GET..."));
//
// #endif
// }
//
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}
When I open the serial monitor, the output is always:
connecting...
failed
disconnecting.
This has been stumping me for a while, would appreciate any help. Thanks in advance.