Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. MQTT ethernet gateway Works great for 3+ hours then stops

MQTT ethernet gateway Works great for 3+ hours then stops

Scheduled Pinned Locked Moved Troubleshooting
24 Posts 6 Posters 15.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pit007
    wrote on last edited by pit007
    #21

    Have you try to init the ENC all ~2 hours or by detecting the connection lost ? (brute force style, but better as powerdown all with a relais)

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GuyP
      wrote on last edited by
      #22

      Well it's very simple to detect if the network has gone away.

      In the processEthernetMessage() function, it checks

      if (client) {

      if there's a client connection then the network must be working. If not then either the network has stopped or nothing is connected. Well OpenHAB always maintains a connection.

      So I've just added the

      } else {

      part to say the connection has gone. I also setup a timeout by counting the micros() since boot. so it's not constantly firing the reboot.

      I then raise digital pin 3 which is linked to my 555 timer circuit, which causes the power cycle.

      unsigned long resetCounter = micros();
      int rebootAborted = 0;
      
      void processEthernetMessages() {
      	char inputString[MQTT_MAX_PACKET_SIZE] = "";
      	uint8_t inputSize = 0;
      	EthernetClient client = server.available();
      	if (client) {
                      resetCounter=micros();
                      if (rebootAborted) {
                        Serial.println("Rebooting Aborted");
                        rebootAborted = 0;
                      }
      		while (client.available()) {
      			char inChar = client.read();
      			inputString[inputSize] = inChar;
      			inputSize++;
      		}
      #ifdef TCPDUMP
      		Serial.print("<<");
      		char buf[4];
      		for (uint8_t a=0; a<inputSize; a++) { sprintf(buf,"%02X ", (uint8_t)inputString[a]); Serial.print(buf); } Serial.println("");
      #endif
      		gw.processMQTTMessage(inputString, inputSize);
      	} else {
                if ((micros() - resetCounter) >= 100000000 && !client.connected() && !rebootAborted) {
                    rebootAborted = 1;
                    Serial.println("Rebooting");
                    pinMode(3,OUTPUT);
                    digitalWrite(3,HIGH);
                    delay(100);
                    digitalWrite(3,LOW);
                }
             }
      }
      
      1 Reply Last reply
      0
      • P Offline
        P Offline
        pit007
        wrote on last edited by pit007
        #23

        Yes - noooo :-) Right - you are able to detect the connection loss (good to know) but why do you not trigger the NE555, but to re-init the ENC28. Have you try if it response via SPI ?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          GuyP
          wrote on last edited by
          #24

          It completely locks up.. I tried to talk with at the same point but it doesn't seem to listen to anything

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          14

          Online

          12.1k

          Users

          11.2k

          Topics

          113.4k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular