Goodmorning everyone, I'm Long.
I have a project : 2 PLC connect to ESP and show data in the website.
I connected every PLC to ESP. So now, I want to connect 2 PLC to 1 ESP at the same time. But I don't know what should I do? Any ideas?
Thanks guys.
This is the code I using to connect ESP and PLC:
include "Settimino.h"
include <ethernet.h>
include <esp8266wifi.h>
define S7WIFI
IPAddress PLC(192,168,1,102);
S7Client Client (_S7WIFI);
bool Connect()
{
int Result=Client.ConnectTo(PLC,0,2);
Serial.print("Connecting to ");Serial.println(PLC);
if (Result==0)
{
Serial.print("Connected PLC ! PDU Length = ");Serial.println(Client.GetPDULength());
}
else
Serial.println("Connection error");
return Result==0;
}</esp8266wifi.h></ethernet.h>
"Client" is in the "Settimo.h" library and decribe like that: " Client *TCPClient; ".
Goodmorning everyone, I'm Long.
I have a project : 2 PLC connect to ESP and show data in the website.
I connected every PLC to ESP. So now, I want to connect 2 PLC to 1 ESP at the same time. But I don't know what should I do? Any ideas?
Thanks guys.
This is the code I using to connect ESP and PLC:
include "Settimino.h"
include <ethernet.h>
include <esp8266wifi.h>
define S7WIFI
IPAddress PLC(192,168,1,102);
S7Client Client (_S7WIFI);
bool Connect()
{
int Result=Client.ConnectTo(PLC,0,2);
Serial.print("Connecting to ");Serial.println(PLC);
if (Result==0)
{
Serial.print("Connected PLC ! PDU Length = ");Serial.println(Client.GetPDULength());
}
else
Serial.println("Connection error");
return Result==0;
}</esp8266wifi.h></ethernet.h>
"Client" is in the "Settimo.h" library and decribe like that: " Client *TCPClient; ".
//----------------------------------------------------------------------------------------------------
I think it's simple: create Client_1 and using "Client_1.ConnectTo(PLC,0,2); like this:
include "Settimino.h"
include<ethernet.h>
include <esp8266wifi.h>
define S7WIFI
IPAddress PLC(192,168,1,102);
IPAddress PLC_1(192,168,1,55); // i create one client
S7Client Client (_S7WIFI);
S7Client Client_1 (_S7WIFI); // i create one client
bool Connect()
{
int Result=Client.ConnectTo(PLC,0,2);
Serial.print("Connecting to ");Serial.println(PLC);
if (Result==0)
{
Serial.print("Connected PLC ! PDU Length = ");Serial.println(Client.GetPDULength());
}
else
Serial.println("Connection error");
return Result==0;
//------------
int Result1=Client_1.ConnectTo(PLC_1,0,2);
Serial.print("Connecting to ");Serial.println(PLC_1);
if (Result==0)
{
Serial.print("Connected PLC 1 ! PDU Length = ");Serial.println(Client.GetPDULength());
}
else
Serial.println("Connection error");
return Result==0;
}</esp8266wifi.h></ethernet.h>
But it's not work
I attached my project below.
Hope your ideas.
Last edit: Long Nguyen 2019-08-26
Nobody help me ? So sad.