0% found this document useful (0 votes)
15 views2 pages

SCADA System for Electrical Grids

The document is an Arduino sketch that sets up an Ethernet server to monitor and control electrical grids. It reads current and temperature data from sensors, displays it on a web page, and allows users to turn grids on or off via buttons. The server responds to HTTP requests and refreshes the page every 5 seconds to show updated values.

Uploaded by

prince gagg
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

SCADA System for Electrical Grids

The document is an Arduino sketch that sets up an Ethernet server to monitor and control electrical grids. It reads current and temperature data from sensors, displays it on a web page, and allows users to turn grids on or off via buttons. The server responds to HTTP requests and refreshes the page every 5 seconds to show updated values.

Uploaded by

prince gagg
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <SPI.h> client.

println("<body style = 'background-


#include <Ethernet.h> image:url([Link]
vector-cartoon-power-lines-delivering-energy-
// Enter a MAC address and IP address for your standing-in-a-row-sketch-high-voltage-electric-
controller below. [Link])'>");
// The IP address will be dependent on your local //[Link]("<div ");
network: //[Link]("<img src
byte mac[] = { = [Link]
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED cartoon-power-lines-delivering-energy-standing-
}; in-a-row-sketch-high-voltage-electric-power-
IPAddress ip(192, 168, 1, 177); [Link]>");
// [Link]("<body
// Initialize the Ethernet server library bgcolor=lightblue>");
// with the IP address and port you want to use [Link]("<head>");
// (port 80 is default for HTTP): [Link]("<font color=black>");
EthernetServer server(80); [Link]("<center>");
String readString; [Link]("<h1>Electrical Grids Based
void setup() { SCADA System</h1>");
pinMode(6,OUTPUT); //Relay [Link]("</center>");
pinMode(7,OUTPUT); [Link]("</head>");
// Open serial communications and wait for port [Link]("<title>");
to open: [Link]("Electrical Grids");
[Link](9600); [Link]("</title>");

// start the Ethernet connection and the server: [Link]("<center>");


[Link](mac, ip); // we can see if there is Motion or not.
[Link](); [Link]("<p>");
[Link]("server is at "); [Link]("<table border=1 width=600>");
[Link]([Link]());
} [Link]("<tr>");
[Link]("<td align=center>");
[Link]("<font color=blue>");
void loop() { [Link]("<h3>Current in Grid 1:</h3>");
// listen for incoming clients [Link]("</td>");
EthernetClient client = [Link](); [Link]("<td align=center>");
if (client) { [Link]("<font color=blue>");
[Link]("new client"); [Link]("<h3>Current in Grid 2:</h3>");
// an http request ends with a blank line [Link]("</td>");
boolean currentLineIsBlank = true;
while ([Link]()) { [Link]("<td align=center>");
if ([Link]()) { [Link]("<font color=blue>");
char c = [Link](); [Link]("<h3>Temperature:</h3>");
if ([Link]() < 100) { [Link]("</td>");
readString += c;
} [Link]("</tr>");
[Link](c); [Link]("<tr>");
// if you've gotten to the end of the line [Link]("<td align=center>");
(received a newline [Link]("<font color = red size=10>");
// character) and the line is blank, the http float Grid1 = analogRead(0);
request has ended, Grid1=(Grid1*4.83);
// so you can send a reply Grid1=(Grid1/10); //10E Resistor
if (c == '\n' && currentLineIsBlank) { Grid1=(Grid1/1000); //conversion to Amp
// send a standard http response header [Link](Grid1);
[Link]("HTTP/1.1 200 OK"); [Link](" Amp");
[Link]("Content-Type: text/html"); [Link]("</td>");
[Link]("Connection: close"); // the
connection will be closed after completion of the [Link]("<td>");
response [Link]("<center>");
[Link]("Refresh: 5"); // refresh the [Link]("<font color = red size=10>");
page automatically every 5 sec float Grid2 = analogRead(1);
[Link](); Grid2=Grid2*4.83;
[Link]("<!DOCTYPE HTML>"); Grid2=(Grid2/10); //10E Resistor
//[Link]("<html>"); Grid2=(Grid2/1000);
[Link](Grid2); digitalWrite(6, LOW);
[Link](" Amp"); }
[Link]("</center>");
[Link]("</td>"); else{
if([Link]("?Grid2on") >0) //
[Link]("<td align=center>"); these are the snippets the Arduino is watching
[Link]("<font color = red size=10>"); for.
float temp = analogRead(5); {
temp=(temp*4.83)/10; digitalWrite(7, HIGH);
[Link](temp); }
[Link](" *C"); else{
[Link]("</td>"); if([Link]("?Grid2off") >0)
{
[Link]("</tr>"); digitalWrite(7, LOW);
[Link]("</table>"); }}}}
[Link]("<p>"); // close the connection:
[Link]("<FORM>"); readString="";
[Link]("<INPUT type=button value=Grid1- [Link]();
ON onClick=[Link]='/?Grid1on1\'>"); [Link]("client disconnected");
[Link]("<INPUT type=button value=Grid1- }
OFF onClick=[Link]='/?Grid1off1\'>"); }
[Link]("</FORM>");
[Link]("<FORM>");
[Link]("<INPUT type=button value=Grid2-
ON onClick=[Link]='/?Grid2on1\'>");
[Link]("<INPUT type=button value=Grid2-
OFF onClick=[Link]='/?Grid2off1\'>");
[Link]("</FORM>");

[Link]("<font color=blue>");
[Link]("<center>");
[Link]("<h1>By Prince, Renuka Chauhan,
Shreya Arun</h1>");
[Link]("</center>");

[Link]("</body>");
[Link]("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current
line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the
data
delay(1);

if([Link]("?Grid1on") >0) //
these are the snippets the Arduino is watching
for.
{
digitalWrite(6, HIGH);
}
else{
if([Link]("?Grid1off") >0)
{

Common questions

Powered by AI

The refresh functionality in the Arduino code is implemented using the HTTP header "Refresh: 5". This command is part of the HTTP response sent to connected clients and instructs their browsers to automatically refresh the web page every five seconds. This refresh mechanism ensures that the client’s web view is updated with the latest data readings from the Arduino, such as current and temperature measurements. It is particularly useful in real-time monitoring situations where dynamic data updates are crucial .

The analogRead function reads values from specified analog pins. In this code, it is used to measure the current in two grids (Grid 1 and Grid 2) and the temperature. The readings from the analog pins are multiplied by 4.83 for conversion purposes, then divided by 10 and 1000 to convert the raw readings into understandable metrics like Amperes for current and degrees Celsius for temperature. These values are then displayed on a dynamically generated web page, constructed as part of the HTTP response sent to the client. This visualization is formatted as a table within the HTML body, with readings labeled accordingly in the document .

The server bandwidth and client load significantly impact the performance of the Arduino web server. The Arduino has limited processing power and memory, so handling multiple clients or high client requests can lead to performance bottlenecks. The server must process each HTTP request and render HTML responses, which consumes memory and bandwidth. Delays in client response times or inability to handle concurrent connections efficiently can occur if the server is overloaded. This scenario is exacerbated by the hardcoded short refresh interval, causing frequent data requests from clients that can quickly saturate the available bandwidth, leading to increased latency and potential downtime .

The Arduino sketch provides a basic control mechanism for grid management but lacks specific safety address measures for electrical hazards. The sketch primarily offers an interface to toggle relays on or off without checks, safeguards, or emergency shutdown procedures typically associated with electrical control systems. Any hazards are left unaddressed, such as overloading circuits or ensuring safe relay operation; hence, additional layers of physical and software safety measures, like integrating sensors for detecting anomalies or implementing automatic cut-offs upon detecting unsafe conditions, would be necessary to mitigate these hazards in a real-world application .

The Arduino code could be modified to include data logging functionality by saving the grid current and temperature readings to an external storage device, such as an SD card, or by transmitting data to a remote server or cloud service for persistent storage. This requires incorporating additional libraries, such as the SD or SPI library for writing to an SD card. The loop function could append new readings to a file on the storage medium at regular intervals or upon major changes in values. Additionally, communicating via HTTP or MQTT to an API endpoint could facilitate logging into databases, allowing for more complex analysis like generating historical trends .

In the Arduino sketch, pinMode is used in the setup function to configure digital pins 6 and 7 as outputs, which is necessary because these pins are connected to relays controlling electrical grids. Setting the mode to OUTPUT ensures that these pins can be used to send voltage signals that will physically control the relays. After setting the pin mode, digitalWrite is used to either energize or de-energize the relays by setting the pins HIGH or LOW, respectively, allowing the Arduino to control whether the grid is turned on or off in response to HTTP requests. This digital control mechanism is essential for interacting with and manipulating external electrical devices .

The Arduino code listens for HTTP requests from a client and processes these requests to control electrical grids. When a client is connected, the code reads the incoming request and stores it in a string. If the request contains the snippet '?Grid1on', it turns on the power to Grid 1 by setting digital pin 6 to HIGH. Similarly, if the request contains '?Grid1off', it turns off Grid 1 by setting digital pin 6 to LOW. The same logic applies to Grid 2 using digital pin 7. These controls are implemented through HTML form elements that interact with the parameters specified in the HTTP request URL, which are detected using string indexing in the readString variable .

The Arduino sketch presents significant security challenges when controlling an electrical grid through a web interface. Firstly, the absence of authentication or encryption means that anyone with access to the network could send HTTP requests to control the grids. The fact that it uses plain text http (port 80) further exposes it to interception and unauthorized manipulation. Additionally, the use of fixed IP and MAC addresses can create vulnerabilities if these addresses are accessed or spoofed. Such implementations lack safeguards against potential denial of service or brute force attacks, making them unsafe for deployment in sensitive infrastructure without additional security layers such as HTTPS, firewalls, or secure socket layers .

Enhancements to the HTML content generated by the Arduino sketch could include more interactive elements and improved data visualization. Adding JavaScript for smooth dynamic updates without entire page refreshes could improve user experience. Implementing real-time dashboards with plots or graphs using libraries like Chart.js could visualize trends in grid current and temperature changes over time. Additionally, improving the HTML structure and styling using CSS could make the interface more user-friendly and intuitive, such as organizing data in responsive widgets and using color coding to indicate status changes or alerts .

The Ethernet server is initialized using the EthernetServer library with a specified IP address and port (default is port 80 for HTTP communications). Upon setup, the Ethernet.begin(mac, ip) command establishes a connection using the MAC and IP addresses provided in the code. The server.begin() method then starts the server, which is capable of listening for incoming client connections. The loop function continuously checks for available clients using server.available(). When a client connects, the server reads incoming HTTP requests and sends back an HTML document as a response. The server maintains this connection until the client sends a newline character that ends the HTTP request, at which point a response is sent back and the connection is terminated .

You might also like