ethernet shiled code error

I couldn’t configure my code according to ethernet module. I use this module for the first time, I would appreciate if you help.

//Communication protocol : For mode state in binary; 77-> AUTOMATIC, 78->MANUEL, 79 -> UNKNOWN STATE
//Communication protocol : For counting state; 67-> add +1 to counting
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

// Enter the IP address for Arduino, as mentioned we will use 192.168.0.16
// Be careful to use , insetead of . when you enter the address here
byte ip[] = {192, 168, 160, 35 }; // ip in lan assigned to arduino
byte gateway[] = {192, 168, 160, 2 }; // internet access via router
byte subnet[] = {255, 255, 255, 0 }; //subnet mask
// Initialize the Ethernet server library
EthernetServer server(80);
EthernetClient client;
#define pinManuel A0
#define pinAutomatic A1
#define pinMengeneStart A3


enum machineState { automatic = 0, manuel = 1, unknown = 2 };

machineState retVal;

static unsigned int voltageThresh = 805;
static unsigned int voltageMax = 1123;

unsigned int uinPulseCounter;
unsigned int uinTimeDifference;
unsigned int uinOldTime;
unsigned int uinFirstTime;

float fMengeneVal;
bool mbSignalState;
char ModeState;
char CountSend;
bool mbTimerRun;

void setup()
{

  //Start with unknown mode
  retVal = unknown;

  //Set mode state with char
  ModeState = { 'M' };

  //Set sending protocol to 'C'
  CountSend = { 'C' };

  //Timer run false
  mbTimerRun = false;

  //Start communication
  Serial.begin(9600);
  // start the Ethernet connection and the server:
  Ethernet.begin(mac,ip,gateway,gateway,subnet);
  server.begin();
  Serial.print("Arduino server IP address: ");
  Serial.println(Ethernet.localIP());

}
void loop()
{
 EthernetClient client = server.available();  // Listen for incoming clients

 if (client) {

   // When a client sends a request to a webserver, that request ends with a blank line
   boolean currentLineIsBlank = true;
   while (client.connected()) {


     // We send the HTTP response code to the client so it knows that we will send him HTML data
     // and to refresh the webpage every 5 seconds
     client.println("HTTP/1.1 200 OK");
     client.println("Content-Type: text/html");
     client.println("Connection: close");
     client.println("Refresh: 5");
     client.println();

     fMengeneVal = analogRead(pinMengeneStart);

     if (fMengeneVal >= voltageThresh && fMengeneVal < voltageMax)
     {

       Serial.print(CountSend);
       Serial.print("\n");
       Serial.print(ModeState + CheckWhichMode());
       Serial.print("\n");
       // Serial.print("Mengene Volt:");
       //Serial.print(fMengeneVal);
       //Serial.print("\n");

       CountPulse();
       Serial.print("Ürün Sayısı:");
       Serial.print(uinPulseCounter);
       Serial.print("\n");
     }
   }

 }
}


int CheckWhichMode()
{
 float manuelVal = analogRead(pinManuel);
 float automaticVal = analogRead(pinAutomatic);

 if ( manuelVal < voltageMax && manuelVal >= voltageThresh )
 {
   retVal = manuel;
   return retVal;
 }
 else if ( automaticVal < voltageMax && automaticVal >= voltageThresh )
 {
   retVal = automatic;
   return retVal;
 }
 else
 {
   retVal = unknown;
   return retVal;
 }

}

void CountPulse()
{
 uinFirstTime = millis();
 mbSignalState = true;

 uinFirstTime = uinFirstTime - uinOldTime;

 Serial.print("Enjeksiyon süresi:");
 Serial.print(uinFirstTime);
 Serial.print("\n");
 uinFirstTime = millis();


 while (mbSignalState)
 {
   delay(10);
   if (analogRead(pinMengeneStart) < voltageThresh) {
     mbSignalState = false;
   }
 }
 uinOldTime = millis();

 uinTimeDifference = uinOldTime - uinFirstTime ;
 {

   fMengeneVal = analogRead(pinMengeneStart);

   // Serial.print("Mengene Volt:");
   //Serial.print(fMengeneVal);
   //Serial.print("\n");

   Serial.print("Robot çevrimi:");
   Serial.print(uinTimeDifference);
   Serial.print("\n");

   uinPulseCounter++;
 }
 {

module? is it with an enc28j60?

EthernetClient client = server.available();  // Listen for incoming clients
if (client) {
  while (client.connected()) {
    if (client.available()) {
      char c = client.read();

      // This line is used to send communication information between Arduino and your browser over Serial Monitor
      Serial.write(c);
      // When the request has ended send the client a reply
      if (c == '\n' && currentLineIsBlank) {

      case 1:
        // Here we write HTML data (for the page itself) which will be sent to the client.
        // The HTML includes Javascript which fills the data
        client.println("<!DOCTYPE HTML>");
        client.println("<html>");
        client.println("<head>");
        client.println("<title>Arduino sensor data</title>");
        client.println("<script>");
        client.println("window.onload=function rfsh(){");
        client.println("document.getElementById('value').innerHTML =");
        client.print(CountSend);
        client.println(";}");
        client.println("</script>");
        client.println("</head>");
        client.println("<body>");
        client.println("
");
        client.println("<h1>Count Send:</h1> ");
        client.println("<p id='value'></p>");
        client.println("</body>");
        client.println("</html>");
        break;
        if (c == '\n') {
          // Check if a new line is started
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // If a new line was not strated
          currentLineIsBlank = false;
        }
      }
    }
  }
  {
EthernetClient client = server.available();  // Listen for incoming clients
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char d = client.read();

        // This line is used to send communication information between Arduino and your browser over Serial Monitor
        Serial.write(d);
        // When the request has ended send the client a reply
        if (d == '\n' && currentLineIsBlank) {

        case 2:
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println("<head>");
          client.println("<title>Arduino sensor data</title>");
          client.println("<script>");
          client.println("window.onload=function rfsh(){");
          client.println("document.getElementById('value').innerHTML =");
          client.print(ModeState + CheckWhichMode());
          client.println(";}");
          client.println("</script>");
          client.println("</head>");
          client.println("<body>");
          client.println("
");
          client.println("<h1>Mode:</h1> ");
          client.println("<p id='value'></p>");
          client.println("</body>");
          client.println("</html>");
          break;
          if (d == '\n') {
            // Check if a new line is started
            currentLineIsBlank = true;
          }
          else if (d != '\r') {
            // If a new line was not strated
            currentLineIsBlank = false;
          }
        }
      }
    }
    {
EthernetClient client = server.available();  // Listen for incoming clients
    if (client) {
      while (client.connected()) {
        if (client.available()) {
          char e = client.read();

          // This line is used to send communication information between Arduino and your browser over Serial Monitor
          Serial.write(e);
          // When the request has ended send the client a reply
          if (e == '\n' && currentLineIsBlank) {

          case 3:
            client.println("<!DOCTYPE HTML>");
            client.println("<html>");
            client.println("<head>");
            client.println("<title>Arduino sensor data</title>");
            client.println("<script>");
            client.println("window.onload=function rfsh(){");
            client.println("document.getElementById('value').innerHTML =");
            client.print(uinPulseCounter);
            client.println(";}");
            client.println("</script>");
            client.println("</head>");
            client.println("<body>");
            client.println("
");
            client.println("<h1>Ürün sayısı:</h1> ");
            client.println("<p id='value'></p>");
            client.println("</body>");
            client.println("</html>");
            break;
            if (e == '\n') {
              // Check if a new line is started
              currentLineIsBlank = true;
            }
            else if (e != '\r') {
              // If a new line was not strated
              currentLineIsBlank = false;
            }
          }
        }
      }
      {
EthernetClient client = server.available();  // Listen for incoming clients
      if (client) {
        while (client.connected()) {
          if (client.available()) {
            char f = client.read();

            // This line is used to send communication information between Arduino and your browser over Serial Monitor
            Serial.write(f);
            // When the request has ended send the client a reply
            if (f == '\n' && currentLineIsBlank) {

            case 4:
              client.println("<!DOCTYPE HTML>");
              client.println("<html>");
              client.println("<head>");
              client.println("<title>Arduino sensor data</title>");
              client.println("<script>");
              client.println("window.onload=function rfsh(){");
              client.println("document.getElementById('value').innerHTML =");
              client.print(uinFirstTime);
              client.println(";}");
              client.println("</script>");
              client.println("</head>");
              client.println("<body>");
              client.println("
");
              client.println("<h1>Enjeksiyon süresi:</h1> ");
              client.println("<p id='value'></p>");
              client.println("</body>");
              client.println("</html>");
              break;
              if (f == '\n') {
                // Check if a new line is started
                currentLineIsBlank = true;
              }
              else if (f != '\r') {
                // If a new line was not strated
                currentLineIsBlank = false;
              }
            }
          }
        }
        {
EthernetClient client = server.available();  // Listen for incoming clients
        if (client) {
          while (client.connected()) {
            if (client.available()) {
              char g = client.read();

              // This line is used to send communication information between Arduino and your browser over Serial Monitor
              Serial.write(g);
              // When the request has ended send the client a reply
              if (g == '\n' && currentLineIsBlank) {

              case 5:
                client.println("<!DOCTYPE HTML>");
                client.println("<html>");
                client.println("<head>");
                client.println("<title>Arduino sensor data</title>");
                client.println("<script>");
                client.println("window.onload=function rfsh(){");
                client.println("document.getElementById('value').innerHTML =");
                client.print(uinTimeDifference);
                client.println(";}");
                client.println("</script>");
                client.println("</head>");
                client.println("<body>");
                client.println("
");
                client.println("<h1>Robot süresi:</h1> ");
                client.println("<p id='value'></p>");
                client.println("</body>");
                client.println("</html>");
                break;
                if (g == '\n') {
                  // Check if a new line is started
                  currentLineIsBlank = true;
                }
                else if (g != '\r') {
                  // If a new line was not strated
                  currentLineIsBlank = false;
                }
              }
            }
          }


          // Give the client some time to recieve the data (1ms)
          delay(100);
          // In the end close the connection
          client.stop();
        }

Yes, I'm using the enc28j60 module. But if it's not appropriate, I can change it. I have not done such an application before.

The Ethernet library is for use with the W5100, W5200, and W5500 Ethernet modules. It is not compatible with your ENC28J60.

For that, you can use this library:

or this one:

UIPEthernet has the same API as the Ethernet library, so the changes you would need to make to your sketch are minimal.

Well thank you, I am changing it immediately. but I can’t compile the code. This is not the reason. Can you help find the error in the code?

When you encounter an error you'll see a button on the right side of the orange bar in the Arduino IDE "Copy error messages" (or the icon that looks like two pieces of paper in the Arduino Web Editor). Click that button. Paste the error in a reply here using code tags.

If the text exceeds the forum's 9000 character limit, save it to a .txt file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

I have attached my working code and the code I am trying to configure. I want to do is display my employee code in a program like sql using ethernet module.

I want to process this template in sql. To do this, I need to display it in sql or html first.
Thanks for be interested.

enc28j60.txt (12.6 KB)

program.txt (2.58 KB)

pert: When you encounter an error you'll see a button on the right side of the orange bar in the Arduino IDE "Copy error messages" (or the icon that looks like two pieces of paper in the Arduino Web Editor). Click that button. Paste the error in a reply here using code tags.

If the text exceeds the forum's 9000 character limit, save it to a .txt file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

C:\Users\pc\OneDrive\Belgeler\Arduino\29.01\29.01.ino: In function ‘void loop()’:

C:\Users\pc\OneDrive\Belgeler\Arduino\29.01\29.01.ino:74:13: warning: unused variable ‘currentLineIsBlank’ [-Wunused-variable]

boolean currentLineIsBlank = true;

^~~~~~~~~~~~~~~~~~

C:\Users\pc\OneDrive\Belgeler\Arduino\29.01\29.01.ino: In function ‘void CountPulse()’:

C:\Users\pc\OneDrive\Belgeler\Arduino\29.01\29.01.ino:149:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

if (analogRead(pinMengeneStart) < voltageThresh) {


29.01:180:26: error: 'currentLineIsBlank' was not declared in this scope

if (c == '\n' && currentLineIsBlank) {

^~~~~~~~~~~~~~~~~~

29.01:182:9: error: case label '1' not within a switch statement

case 1:

^~~~

29.01:224:28: error: 'currentLineIsBlank' was not declared in this scope

if (d == '\n' && currentLineIsBlank) {

^~~~~~~~~~~~~~~~~~

29.01:226:11: error: case label '2' not within a switch statement

case 2:

^~~~

29.01:266:30: error: 'currentLineIsBlank' was not declared in this scope

if (e == '\n' && currentLineIsBlank) {

^~~~~~~~~~~~~~~~~~

29.01:268:13: error: case label '3' not within a switch statement

case 3:

^~~~

29.01:308:32: error: 'currentLineIsBlank' was not declared in this scope

if (f == '\n' && currentLineIsBlank) {

^~~~~~~~~~~~~~~~~~

29.01:310:15: error: case label '4' not within a switch statement

case 4:

^~~~

29.01:350:34: error: 'currentLineIsBlank' was not declared in this scope

if (g == '\n' && currentLineIsBlank) {

^~~~~~~~~~~~~~~~~~

29.01:352:17: error: case label '5' not within a switch statement

case 5:

^~~~

29.01:388:11: error: expected '}' at end of input

}

^

29.01:388:11: error: expected '}' at end of input

29.01:388:11: error: expected '}' at end of input

29.01:388:11: error: expected '}' at end of input

29.01:388:11: error: expected '}' at end of input

29.01:388:11: error: expected '}' at end of input

29.01:388:11: error: expected '}' at end of input

29.01:388:11: error: expected '}' at end of input

29.01:388:11: error: expected '}' at end of input

29.01:388:11: error: expected '}' at end of input

"SPI.h" için birden fazla library bulundu
Kullanılıyor: C:\Program
"Ethernet.h" için birden fazla library bulundu
Kullanılıyor: C:\Program
Şu dizinde 1.0 sürümündeki SPI kütüphanesi kullanılıyor: C:\Program Files
Şu dizinde 2.0.0 sürümündeki Ethernet kütüphanesi kullanılıyor: C:\Program Files
exit status 1
'currentLineIsBlank' was not declared in this scope

erknl1903: ``` 29.01:180:26: error: 'currentLineIsBlank' was not declared in this scope

        if (c == '\n' && currentLineIsBlank) {

                          ^~~~~~~~~~~~~~~~~~

As the error message says, 'currentLineIsBlank' was not declared in this scope. You declared a variable named currentLineIsBlank in your loop function, that makes the variable local to loop(). You can't use it in another function. Please read up on scope: https://www.arduino.cc/reference/en/language/variables/variable-scope--qualifiers/scope/

erknl1903: 29.01:182:9: error: case label '1' not within a switch statement

case 1:

^~~~

As the error says, case label '1' is not within a switch statement. Please read up on switch statements: https://www.arduino.cc/reference/en/language/structure/control-structure/switchcase/

erknl1903: 29.01:388:11: error: expected '}' at end of input

}

^

As the error says, you are missing many closing braces.

A very helpful troubleshooting tool is the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor). If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace.

Look, you're trying to run before you have learned to crawl. As expected, you've tripped and landed right on your face. It's time for you to step way back and learn the basics of the Arduino programming language. I know you want to get right to your project, but you're just going to end up with a lot of frustration, confusion, and wasted time with this approach.

As a result of the changes I made, I was able to compile my program. If I have time, I will start learning from the simplest point. But I don’t have the time now, I should get a successful result in a short time.

I ran my program, checked to see if it was ping, and saw it came. but i could not find the image i want on html screen.

son30.01.txt (14.3 KB)

    while (client.connected()) {

Why do you send the same content (header and body) over and over again while the client is still connected?

Try to replace the "while" by a "if" and place a client.close(); at the end of the body transfer.

https://i.hizliresim.com/9YM60k.jpg

Post pictures to the forum, we don't open images from temporary storage servers.

Where exactly do I need to add, can you show me ? Do you think this is the reason why other data did not come? I don't know how far I am from what I am trying to do.

Meanwhile, "Your work used under the program’s 20090 bytes (62%) storage. Maximum 32256 bytes.
Global variables use up to 1717 bytes (83%) of memory. There are 331 bytes of space left for local variables. Up to 2048 bytes can be used. Low memory available can cause stability problems. ‘’
Does this cause me trouble in the future? Should I change the arduino model? Can I use wiznet 5100 instead of enc28j60?

Does this cause me trouble in the future? Should I change the arduino model? Can I use wiznet 5100 instead of enc28j60?

It might cause you trouble, you're using over 80% of your total memory (RAM) for global variables. You can save some memory by using the F() macro for the print() and println() calls with constant strings. But the ENC28j60 uses a lot of memory for it's buffers, so changing the hardware to a WizNet5100 based board saves you a lot of memory.

Well. I will make the changes and come back. I hope I see you here again.

https://github.com/UIPEthernet/UIPEthernet/issues/41

pylon: But the ENC28j60 uses a lot of memory for it's buffers, so changing the hardware to a WizNet5100 based board saves you a lot of memory.

what buffers? everything happens in the memory of the enc28j60