Ethernet-MQTT GW problem



  • Hi,
    I'm getting desperate with my gw. Two days ago a lightning blasted my house and MyS network. Gw destroyed, so I built a new one to figure out which nodes might be alive. I built an exact replica. The lightning also took out my network switch and router. Both bought new and are working well. New ethernet wires too.

    Below is my sketch for my gw, log output. The hardware is ProMini5V, W5100 module (with resistor on pins at bottom: https://forum.arduino.cc/index.php?topic=351477.msg3215306#msg3215306), NRF24+PA+LNA. And lots of caps and a voltage regulator mcp1700-3200.
    I have checked the parameters of my router and also checked with computer that ethernet lines actually work.

     /**
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     *
     * DESCRIPTION
     * The W5100 MQTT gateway sends radio network (or locally attached sensors) data to your MQTT broker.
     * The node also listens to MY_MQTT_TOPIC_PREFIX and sends out those messages to the radio network
     */
    
    #define MY_DEBUG
    #define MY_RADIO_RF24
    #define MY_GATEWAY_MQTT_CLIENT
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "domoticz/in/MyMQTT"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "domoticz/out/MyMQTT"
    #define MY_MQTT_CLIENT_ID "mysensors-1"
    
    // Enable Soft SPI for NRF radio (note different radio wiring is required)
    // The W5100 ethernet module seems to have a hard time co-operate with
    // radio on the same spi bus.
    #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
    #define MY_SOFTSPI
    #define MY_SOFT_SPI_SCK_PIN 14
    #define MY_SOFT_SPI_MISO_PIN 16
    #define MY_SOFT_SPI_MOSI_PIN 15
    #endif
    
    // When W5100 is connected we have to move CE/CSN pins for NRF radio
    #ifndef MY_RF24_CE_PIN
    #define MY_RF24_CE_PIN 5
    #endif
    #ifndef MY_RF24_CS_PIN
    #define MY_RF24_CS_PIN 6
    #endif
    
    //#define MY_RF24_IRQ_PIN 2
    //#define MY_RX_MESSAGE_BUFFER_FEATURE
    
    // Enable these if your MQTT broker requires usenrame/password
    #define MY_MQTT_USER "xxxxxxx"
    #define MY_MQTT_PASSWORD "yyyyyyyyy"
    
    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
    #define MY_IP_ADDRESS 192,168,0,201
    //#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
    
    // If using static ip you need to define Gateway and Subnet address as well
    #define MY_IP_GATEWAY_ADDRESS 192,168,0,1      // Router IP
    #define MY_IP_SUBNET_ADDRESS 255,255,255,0
    
    // MQTT broker ip address or url. Define one or the other.
    //#define MY_CONTROLLER_URL_ADDRESS "m20.cloudmqtt.com"
    #define MY_CONTROLLER_IP_ADDRESS 192, 168, 0, 100
    
    // The MQTT broker port to to open
    #define MY_PORT 1883
    
    /*
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    //#define MY_INCLUSION_BUTTON_FEATURE
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60
    // Digital pin used for inclusion mode button
    //#define MY_INCLUSION_MODE_BUTTON_PIN  3
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
    */
    
    #include <Ethernet.h>
    #include <MySensors.h>
    
    void setup()
    {
    
    }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("MQTT_GW2", "v13072019");
    }
    
    
    void loop()
    {
    
    }
    
    MCO:BGN:INIT GW,CP=RNNGA---,REL=255,VER=2.3.1
    4 TSM:INIT
    5 TSF:WUR:MS=0
    11 TSM:INIT:TSP OK
    13 TSM:INIT:GW MODE
    15 TSM:READY:ID=0,PAR=0,DIS=0
    17 MCO:REG:NOT NEEDED
    579 GWT:TPC:IP=0.0.0.0
    1582 MCO:BGN:STP
    1584 MCO:BGN:INIT OK,TSP=1
    2146 GWT:TPC:IP=0.0.0.0
    3148 GWT:RMQ:MQTT RECONNECT
    3151 TSM:READY:NWD REQ
    3188 TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    3756 GWT:TPC:IP=0.0.0.0
    4757 GWT:RMQ:MQTT RECONNECT
    5320 GWT:TPC:IP=0.0.0.0
    6323 GWT:RMQ:MQTT RECONNECT
    6886 GWT:TPC:IP=0.0.0.0
    7888 GWT:RMQ:MQTT RECONNECT
    8451 GWT:TPC:IP=0.0.0.0
    9453 GWT:RMQ:MQTT RECONNECT
    10016 GWT:TPC:IP=0.0.0.0
    11019 GWT:RMQ:MQTT RECONNECT
    11582 GWT:TPC:IP=0.0.0.0
    12583 GWT:RMQ:MQTT RECONNECT
    13147 GWT:TPC:IP=0.0.0.0
    14149 GWT:RMQ:MQTT RECONNECT
    14712 GWT:TPC:IP=0.0.0.0
    15715 GWT:RMQ:MQTT RECONNECT
    16278 GWT:TPC:IP=0.0.0.0
    17281 GWT:RMQ:MQTT RECONNECT
    17844 GWT:TPC:IP=0.0.0.0
    18846 GWT:RMQ:MQTT RECONNECT
    

    Also I have checked my connections three times. And verified that my Mosquitto is listening and ready.

    I need fresh ideas. My whole system is pretty dead in the water.



  • @masmat Check if You can connect to the broker from another computer. Check if You can ping your gateway from another computer.



  • The Mosquitto is running on RPi, it can be ssh:d easily. Mosquitto service is running and listening.
    My router's setup page doesn't show gw as a client (nothing on 192.168.0.201) so I cant connect to it. I connected the ethernet cable directly to the router but the result is the same. The W5100 module lights up fine and the blinking etc seems proper but it's not connecting I think. The ip=0.0.0.0 seems strange.

    Exact same behavior when cable is disconnected..



  • Maybe spi wiring to the ethernet module od bad ?



  • @rozpruwacz Got lucky and found an extra W5100 without the 100ohm resistors. Also disabled the static ip (I set it from the routers ip table instead).

    Now, it seems the gw is breathing..


Log in to reply
 

Suggested Topics

11
Online

11.4k
Users

11.1k
Topics

112.7k
Posts