Arduino Uno + W5500 + OMRON FQ2 smart camera /Ethernet Problem

Hello,
I am creating a project using:

  • Arduino Uno 3
  • Wiznet W5500 Ethernet module
  • OMRON FQ2 Smart Camera (communication via Ethernet)
    I need to send and receive informations via ethernet between Arduino and Smart Camera. I started by configurating the camera to specific TCP port and setting the informations that will be visible in the logs via ethernet. After that I used a PC TCP Client, connected to the IP and Port of the Camera, I did a few "inspections" (camera shots) and the logs appeard at the TCP client, so everything is just like it should be.

BUT now i need to do the same thing using Arduino, so (for the start it can be just receiving packages) via Ethernet and displaying them at the serial port or lcd. I am using the Ethernet2 library but it has only UDP client and it doesn't work for me. I was searching for other libraries/codes and I did not find anything that worked for me so I am asking for your help/advices :smiley:

I don't know if that information is important but I can set if the sensor will send logs in ASCII or BInary format. But still I think that i would connect to the port and maybe the logs would be crashed or something but still i would be connected.

Have you tried the Ethernet Library as that supports the 5500 as well as the 5100 and 5200 shields.

The Ethernet library documents the functions to make TCP calls to a server using the Client class, or to act as a server using the Server Class.

Arduino - Ethernet

As far I as know the Ethernet2 library supports 5500 (newer version of Ethernet library). I tried it but I'm not quite good in networking and must have some code to look at I'm not sure how to construct my own TCP client using this functions :confused:
PS
The library has only UDPT client example and I don't know how to change that to TCP.

What software did you use on the PC when you communicated with the camera? How did you use it, what port did you specify, ip address, terminal settings etc.
According to the userguide for the camera it should accept TCP or UDP, what happened when you tried UDP? Did you get any error message? if so what?

@countrypaul
I use OMRON TouchFinder PC, It's dedicated software for this cam. I can set TCP or UDP. On PC I use the program named "TCPIPBuilder" and It works (for TCP). I tried with other programms with UDP but it doesn't work for me (maybe because of me).
For TCP I specified the port numer (9876) and I used the camera ip adress (10.5.5.10).
I can send the screenshots later.

Which model of the FQ2 range are you using as I notice that not all implement the UDP option?

Post the code you have, tried and put it in a code block </> button on the reply window.

Okay i will send pictures of what you asking. I can switch between UDP and TCP in Omron Software, below there is a screen of TCP setting and working case when i do an inspection and in TCPIPbuilder i see the logs. In "Connection setup" the ip was set : 10.5.5.10 and port 9876 ( adress of FQ2). 10.5.5.101 is my network card ip and 65207 was set randomly. The code i tried:

#include <SPI.h>
#include <Ethernet2.h>

// network configuration.  gateway and subnet are optional.

 // the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0x00, 0x00, 0x0A, 0x75, 0x81, 0x0C };  
//the IP address for the shield:
byte ip[] = { 10, 5, 5, 10 };    
// the router's gateway address:
byte gateway[] = { 10, 5, 5, 10 };
// the subnet:
byte subnet[] = { 255, 255, 255, 0 };

// telnet defaults to port 23
EthernetServer server = EthernetServer(9876);

void setup()
{
  // initialize the ethernet device
  Ethernet.begin(mac, ip, gateway, subnet);

  // start listening for clients
  server.begin();
}

void loop()
{
  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  if (client == true) {
    // read bytes from the incoming client and write them back
    // to any clients connected to the server:
    server.write(client.read());
  }
}

Zrzut ekranu 2021-03-16 185744.png

Zrzut ekranu 2021-03-16 185744.png

The software you are using on the Arduino is a server not client. The software you have on the PC is client so can connect to the server on the camera - it should also be able to connect to the software on the Arduino (TCP only).

If you need the Arduino to connect to the camera you will have to use some client software such as you are using for echoing. That is you need to send to the Camera using client.write(buffer, len) or client.write(char).

As you have things, I think both the camera and the Arduino will simply wait for the other.

You have nothing on the Arduino to handle UDP at present, so it is not surprising that you cannot connect to it with UDP.

Thank you! I will try to make some code and write back if it is working
Maybe you know some example of a client that I can edit ?

Sure: Ethernet2/WebClient.ino at master · adafruit/Ethernet2 · GitHub

Zawislak:
Okay i will send pictures of what you asking. I can switch between UDP and TCP in Omron Software, below there is a screen of TCP setting and working case when i do an inspection and in TCPIPbuilder i see the logs. In "Connection setup" the ip was set : 10.5.5.10 and port 9876 ( adress of FQ2). 10.5.5.101 is my network card ip and 65207 was set randomly. The code i tried:

#include <SPI.h>

#include <Ethernet2.h>

// network configuration.  gateway and subnet are optional.

// the media access control (ethernet hardware) address for the shield:
byte mac = { 0x00, 0x00, 0x0A, 0x75, 0x81, 0x0C };  
//the IP address for the shield:
byte ip = { 10, 5, 5, 10 };    
// the router's gateway address:
byte gateway = { 10, 5, 5, 10 };
// the subnet:
byte subnet = { 255, 255, 255, 0 };

// telnet defaults to port 23
EthernetServer server = EthernetServer(9876);

void setup()
{
 // initialize the ethernet device
 Ethernet.begin(mac, ip, gateway, subnet);

// start listening for clients
 server.begin();
}

void loop()
{
 // if an incoming client connects, there will be bytes available to read:
 EthernetClient client = server.available();
 if (client == true) {
   // read bytes from the incoming client and write them back
   // to any clients connected to the server:
   server.write(client.read());
 }
}







![Zrzut ekranu 2021-03-16 185744.png|556x223](upload://ws1oCHNmEZDPBJE0hQnRIp1d1AL.png)

![DZIALA.png|2502x915](upload://jsWALjIS1TUiYGj3fK6akSUgKOd.jpeg)

Okay so that's my code:

#include <Ethernet2.h>
#include <SPI.h>

  byte mac[] = { 0xBC, 0x5F, 0xF4, 0xD2, 0xDC, 0x2A }; //Mac of the camera
  byte ip[] = { 10, 5, 5, 101 }; //ip of pc ethernet card
  byte server[] = { 10, 5, 5, 10 }; //ip of server (camera)
  int tcp_port = 9876; //port of the server (camerA)
  EthernetClient client;

void setup() {
 
Ethernet.begin(mac, ip);
Serial.begin(9600);
delay(1000);
Serial.println("Connecting...");

if (client.connect(server, tcp_port)) { 
  Serial.println("Connected");
  client.println();
} else{
  Serial.println("Error");
}
}
void loop() {

if (client.available()) {
  if(Serial.available()) {
    char s = Serial.read();
    client.write(s); 
    char c = client.read();
    Serial.print(c);
  }
}
if (!client.connected()) {
  Serial.println();
  Serial.println("Disconecting.");
  client.stop();
  for(;;);
}
}

I tried with mac adress of my ethernet card also (which one should it be?).
I get the messages:
13:54:54.851 -> Connecting...
13:54:54.897 -> Error
13:54:54.897 ->
13:54:54.897 -> Disconecting
Any thoughts?

If the ip address you are using on your Arduino is the same as that of the PC then you will get an error. The Arduino needs its own ip address on the same subnet.

Okay and how about the MAC? Because that should be the mac of w5500( arduino module) but if i don't have any assigned to that ( no info on the board) i should give some random one that probably is not taken?
And with the ip adress same question i should just type some random ip on the same subnet which is not used?
Okay I understand that and I tried it but nothing changes.

For the MAC address if there is just the one Arduino on the network many people use DE AD BE EF FE ED - you need to choose one that is valid and does not conflict with anything else on the network.

With the IP address you can chose a random ip in the same subnet, so the the first part should be 10, 5, 5. One you have started the Arduino on your chosen ip address you should be able to ping it from your PC, in a command prompt type
$ ping 10.5.5.nn where nn is the part you chose. If you get no reply the problem could be something wrong on the Arduino - so let us know.

Okay here's the picture. I can add that i tried again with TCPIPBuilder and everything is working properly.
I am starting to think t(if the code is ok) that it is something with my arduino.
I have uno3 +w5500 module SPI.

Okay quick update, I am pinging the arduino:
But still error.

What changed, other than ip address, to get ping working?

Do you know why did .101 reply when you tried to ping .11

.101 is my ethernet card ip
I changed ip adress and reconected the wires from W5500 (probably that was the issue).
But now it should work and i have no idea what to change more :smiley:

This does appear very strange, but based on your tests I am not yet convinced that the Arduino is the problem - though I can't say what is.

How is everything connected, the PC, Camera and Arduino, are they all wired into an Ethernet switch, or into a router, is other equipment also connected, if so how many other devices?

Is this summary of the current state correct:

  1. The PC can ping the Arduino and the PC can operate the camera using TCPBuilder.
  2. The Arduino cannot connect to the camera using the sketch posted in reply #16.

I have seen strange problems before when for example an Arduino connected to a Cisco switch would not connect to another machine, but would if they used a "cheap" switch. Also two Arduinos cannot talk to each other directly as there appeared to be a bug in the Ethernet autospeed negotiation.

Can you try this sketch Arduino Playground - ICMP Ping Library and see if you can then ping the PC and the Camera from the arduino? This should help determine if there is communication over ethernet to PC & Camera or if there is some other limitation, for example a firewall dropping the ICMP packets.