Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

  • Explore the new navigation for even easier access to your community.
  • Bookmark and use our new, easy-to-remember address (community.se.com).
  • Get ready for more content and an improved experience.

Contact SchneiderCommunity.Support@se.com if you have any questions.

Close
Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
84673members
354017posts

Esp8266 wifi sensor to Citect SCADA

AVEVA Plant SCADA Forum

A support forum for AVEVA Plant SCADA (formerly Citect SCADA). Share new and exciting product information, connect, learn, and collaborate with the ecosystem of Plant SCADA Users. AVEVA Plant SCADA a reliable, flexible and high-performance Supervisory Control and Data Acquisition software solution for industrial process customers. This forum is to connect, share, learn and collaborate new and exciting product information. Feel free to join and share to your Ecosystem of Plant SCADA Users.

Cheetahunter
Crewman
Crewman
0 Likes
6
2446

Esp8266 wifi sensor to Citect SCADA

Hi 

Do you know  if its possible to get data from esp8266 by wifi to citect scada?

if yes how to?

Tags (1)
6 Replies 6
BevanWeiss
Spock
Spock
0 Likes
0
2421

Re: Esp8266 wifi sensor to Citect SCADA

I don't believe Citect has a native driver for this, so you will likely need to involve an external application also.

 

I'd recommend investigating node-red, here's google result 1 for 'node-red esp8266 tutorial'

https://randomnerdtutorials.com/esp8266-and-node-red-with-mqtt/

 

Once you get the data into node-red, then you should be able to use OPC (server), or even perhaps ModbusTCP (server) or another such interface to present your data for consumption by Citect.

Citect itself would then be an OPC client / ModbusTCP client etc.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Tags (1)
Eric_Coudurier
Lt. Commander Lt. Commander
Lt. Commander
4
2399

Re: Esp8266 wifi sensor to Citect SCADA

Hello,

 

The ESP8266 can be programmed using the Arduino framework (https://www.arduino.cc/en/Main/Software), so you can find Modbus library for this module:
https://www.arduino.cc/en/ArduinoModbus/ArduinoModbus

Then use the standard Modnet driver or OFS driver from Citect SCADA to connect to the ESP8266.

 

Tags (1)
Cheetahunter
Crewman
Crewman
0 Likes
3
2365

Re: Esp8266 wifi sensor to Citect SCADA

Thanks

I have managed to make the connection with citect with modbus code on my esp sending temperature data .

 

if someone wants I will post the code for esp here.

Tags (1)
Eric_Coudurier
Lt. Commander Lt. Commander
Lt. Commander
0 Likes
0
2360

Re: Esp8266 wifi sensor to Citect SCADA

Hello,

 

Yes I am interested, if you can publish the code, that will be cool.

Tags (1)
mohammadreza
Cadet
0 Likes
1
1444

Re: Esp8266 wifi sensor to Citect SCADA

Please send me the codes if possible, thanks

Tags (1)
Cheetahunter
Crewman
Crewman
0 Likes
0
1386

Re: Esp8266 wifi sensor to Citect SCADA

this is the code for sending temperature with esp8266 by Wifi to Citect

you need to define the port in citect with the same ip as your esp to get the connection with modbus protocol.

 

 

//ESP8266 reads Ds18b20 temperature probe connected to D4 pin(=2) and sends the data via modbus to Citect
//in Citect : need to define new port with ESPs IP (P502)
#include <ESP8266WiFi.h>


#include <OneWire.h>
#include <DallasTemperature.h>

// GPIO where the DS18B20 is connected to
const int oneWireBus = 2;
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);


//Static IP address configuration
IPAddress staticIP(10, 10, 93, 50); //ESP static ip
IPAddress gateway(10, 10, 93, 1); //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0); //Subnet mask
IPAddress dns(8, 8, 8, 8); //DNS

const char* ssid = "YOUR SSID";
const char* password = "PASSWORD";

int scansl=0;
int scans2=0;
int ModbusTCP_port = 502;

//////// Required for Modbus TCP / IP /// Requerido para Modbus TCP/IP /////////
#define maxInputRegister 20
#define maxHoldingRegister 20

#define MB_FC_NONE 0
#define MB_FC_READ_REGISTERS 3 //implemented
#define MB_FC_WRITE_REGISTER 6 //implemented
#define MB_FC_WRITE_MULTIPLE_REGISTERS 16 //implemented
//
// MODBUS Error Codes
//
#define MB_EC_NONE 0
#define MB_EC_ILLEGAL_FUNCTION 1
#define MB_EC_ILLEGAL_DATA_ADDRESS 2
#define MB_EC_ILLEGAL_DATA_VALUE 3
#define MB_EC_SLAVE_DEVICE_FAILURE 4
//
// MODBUS MBAP offsets
//
#define MB_TCP_TID 0
#define MB_TCP_PID 2
#define MB_TCP_LEN 4
#define MB_TCP_UID 6
#define MB_TCP_FUNC 7
#define MB_TCP_REGISTER_START 8
#define MB_TCP_REGISTER_NUMBER 10

byte ByteArray[260];
unsigned int MBHoldingRegister[maxHoldingRegister];

//////////////////////////////////////////////////////////////////////////

WiFiServer MBServer(ModbusTCP_port);


void setup() {
Serial.begin(115200);
sensors.begin();

delay(100) ;
WiFi.mode(WIFI_STA);
WiFi.config(staticIP, subnet, gateway, dns);
WiFi.begin(ssid, password);
int scans=0;
delay(100) ;
Serial.println(".");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
scans++;
if (scans==100) {
ESP.restart();
}
}
MBServer.begin();
Serial.println("Connected ");
Serial.print("ESP8266 Slave Modbus TCP/IP ");
Serial.print(WiFi.localIP());
Serial.print(":");
Serial.println(String(ModbusTCP_port));
Serial.println("Modbus TCP/IP Online");

}


void loop() {

Serial.println("1");
// Check if a client has connected // Modbus TCP/IP
WiFiClient client = MBServer.available();
Serial.println("2");
if (!client) {
Serial.println("3");
return;
}

Serial.println("4");
boolean flagClientConnected = 0;
byte byteFN = MB_FC_NONE;
int Start;
int WordDataLength;
int ByteDataLength;
int MessageLength;

// Modbus TCP/IP
while (client.connected()) {
Serial.println("5");
if(client.available())
{
Serial.println("6");
flagClientConnected = 1;
int i = 0;
while(client.available())
{
Serial.println("7");
ByteArray[i] = client.read();
i++;
}
Serial.println("8");
client.flush();

 

///// code here --- codigo aqui

///////// Holding Register [0] A [9] = 10 Holding Registers Escritura
///////// Holding Register [0] A [9] = 10 Holding Registers Writing 40001-40010


MBHoldingRegister[0] = readDSTemperatureC();
// MBHoldingRegister[0] = 20;
Serial.println("9");
// MBHoldingRegister[1] = 1;
// MBHoldingRegister[2] = 2;
// MBHoldingRegister[3] = 4;
// MBHoldingRegister[4] = 5;
// MBHoldingRegister[5] = 6;
// MBHoldingRegister[6] = 7;
// MBHoldingRegister[7] = 8;
// MBHoldingRegister[8] = 9;
// MBHoldingRegister[9] = 10;

 


///////// Holding Register [10] A [19] = 10 Holding Registers Lectura
///// Holding Register [10] A [19] = 10 Holding Registers Reading

int Temporal[10];

Temporal[0] = MBHoldingRegister[10];
Temporal[1] = MBHoldingRegister[11];
Temporal[2] = MBHoldingRegister[12];
Temporal[3] = MBHoldingRegister[13];
Temporal[4] = MBHoldingRegister[14];
Temporal[5] = MBHoldingRegister[15];
Temporal[6] = MBHoldingRegister[16];
Temporal[7] = MBHoldingRegister[17];
Temporal[8] = MBHoldingRegister[18];
Temporal[9] = MBHoldingRegister[19];

/// Enable Output 14
digitalWrite(14, MBHoldingRegister[14] );


//// debug

for (int i = 0; i < 10; i++) {

Serial.print("[");
Serial.print(i);
Serial.print("] ");
Serial.print(Temporal[i]);
Serial.println("10");
}
Serial.println("");

Serial.println("11");


//// end code - fin

//// rutine Modbus TCP
byteFN = ByteArray[MB_TCP_FUNC];
Start = word(ByteArray[MB_TCP_REGISTER_START],ByteArray[MB_TCP_REGISTER_START+1]);
WordDataLength = word(ByteArray[MB_TCP_REGISTER_NUMBER],ByteArray[MB_TCP_REGISTER_NUMBER+1]);
}

// Handle request

switch(byteFN) {
case MB_FC_NONE:
break;

case MB_FC_READ_REGISTERS: // 03 Read Holding Registers
ByteDataLength = WordDataLength * 2;
ByteArray[5] = ByteDataLength + 3; //Number of bytes after this one.
ByteArray[8] = ByteDataLength; //Number of bytes after this one (or number of bytes of data).
for(int i = 0; i < WordDataLength; i++)
{
ByteArray[ 9 + i * 2] = highByte(MBHoldingRegister[Start + i]);
ByteArray[10 + i * 2] = lowByte(MBHoldingRegister[Start + i]);
}
MessageLength = ByteDataLength + 9;
client.write((const uint8_t *)ByteArray,MessageLength);

byteFN = MB_FC_NONE;

break;


case MB_FC_WRITE_REGISTER: // 06 Write Holding Register
MBHoldingRegister[Start] = word(ByteArray[MB_TCP_REGISTER_NUMBER],ByteArray[MB_TCP_REGISTER_NUMBER+1]);
ByteArray[5] = 6; //Number of bytes after this one.
MessageLength = 12;
client.write((const uint8_t *)ByteArray,MessageLength);
byteFN = MB_FC_NONE;
break;

case MB_FC_WRITE_MULTIPLE_REGISTERS: //16 Write Holding Registers
ByteDataLength = WordDataLength * 2;
ByteArray[5] = ByteDataLength + 3; //Number of bytes after this one.
for(int i = 0; i < WordDataLength; i++)
{
MBHoldingRegister[Start + i] = word(ByteArray[ 13 + i * 2],ByteArray[14 + i * 2]);
}
MessageLength = 12;
client.write((const uint8_t *)ByteArray,MessageLength);
byteFN = MB_FC_NONE;

break;
}
// scansl++;
// Serial.println(scansl);
// if (scansl==100000) {
// ESP.restart();
//}
Serial.println("12");
}
Serial.println("13");

if (WiFi.status() != WL_CONNECTED) {
ESP.restart();
}
scans2++;
Serial.println(scans2);
if ((client.connected()==0)&&(scans2>50000)) {
ESP.restart();
}

Serial.println("14");
}

 

int readDSTemperatureC() {
// Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);

if(tempC == -127.00){
Serial.println("Failed to read from DS18B20 sensor");
// return "--";
} else {
Serial.print("Temperature Celsius: ");
Serial.println(tempC);
}
return tempC*10;
}

Tags (3)