go ahead and continue

I have this project that shows three odds on the display and on the net.
I would like to open contacts to achieve the predefined values. I do not know how to proceed.I attach the project.

arduino_karjack.txt (3.57 KB)

/*
  Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A1 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 modified 02 Sept 2015
 by Arturo Guadalupi

 */

#include <SPI.h>
#include <Ethernet.h>
#include <EmonLib.h>


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 152);


EnergyMonitor emon1;//pin del sensore SCT su A1
EnergyMonitor emon2;
int pin1 = 0; //energia FV
int pin2 = 1;//energia prelevata
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 85 is default for HTTP):
EthernetServer server(80);

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  emon1.current(pin1,18);  // Current: input pin, calibration.
  emon2.current(pin2,18); 
  while (!Serial) {
 
    ; // wait for serial port to connect. Needed for native USB port only
  }



  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  double Irms = emon1.calcIrms(1480);// Calculate Irms only
  double Irms1 = emon2.calcIrms(1480);
  double w = Irms*230;//calcolo potenza
  double w1 = Irms1*230; 
  double w2 = w-w1; 
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 1");  // refresh the page automatically every 1 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
           {
            
            client.print(" prodotta  ");
            client.print(w);
            client.println("
");
            client.print(" utilizzata  ");
            client.print(w1);
            client.println("
");
            client.print(" disponibile  ");
            client.print(w2);
            
            client.println("
");
          }
          client.println("</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);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

I have this project that shows three odds on the display and on the net.

No evens?

What the heck was this supposed to say?

int pin1 = 0; //energia FV
int pin2 = 1;//energia prelevata
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 85 is default for HTTP):
EthernetServer server(80);

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  emon1.current(pin1,18);  // Current: input pin, calibration.
  emon2.current(pin2,18);

Are pin1 and pin2 analog or digital pins?

          // output the value of each analog input pin

That is NOT what the code does.

  double Irms = emon1.calcIrms(1480);// Calculate Irms only
  double Irms1 = emon2.calcIrms(1480);

Why are the emon instances numbered 1 and 2, while the Irms instances are numbered nothing and 1? 1 and 2 make sense. nothing and 1 do not.

  double w = Irms*230;//calcolo potenza
  double w1 = Irms1*230; 
  double w2 = w-w1;

Completely meaningless names.

I would like to open contacts to achieve the predefined values.

I have no idea what this means? Open contacts on what? What predefined values?