Github Devices Community Docs Blog

Arduino Mega2560 with W5100 ethernet shield

I’ve build the latest OMG_VERSION “0.9.2” using VSC.
And I’m having a hard time to connecting to the router. (OpenWrt Chaos Calmer 15.05.1)
MQTT runs at 192.168.1.100:1883 But receives nothing from the W5100.
I don’t see DHCP lease entry.
I’ve tried the extra capacitor on reset pins.
I’ve tried different power supplies and USB/network cables.
There are no sensors just the Arduino and W5100
Also I tried with dns and gateway 0.0.0.0
What did I do wrong?

The device is ping-able tru my LAN at 192.168.1.99

lars@lars-desktop:~/MicroPython$ ping 192.168.1.99 -c 5
PING 192.168.1.99 (192.168.1.99) 56(84) bytes of data.
64 bytes from 192.168.1.99: icmp_seq=1 ttl=128 time=0.237 ms
64 bytes from 192.168.1.99: icmp_seq=2 ttl=128 time=0.477 ms
64 bytes from 192.168.1.99: icmp_seq=3 ttl=128 time=0.418 ms
64 bytes from 192.168.1.99: icmp_seq=4 ttl=128 time=0.308 ms
64 bytes from 192.168.1.99: icmp_seq=5 ttl=128 time=0.468 ms

--- 192.168.1.99 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4057ms
rtt min/avg/max/mdev = 0.237/0.381/0.477/0.096 ms

This is the serial monitor output:

Adv eth cfg
ip: 
192.168.1.99
Eth ok
1883
Connecting to MQTT by IP adress
192.168.1.100
Bosch BME280 Initialized - Result of .begin(): 0x0
No TSL2561 detected
TSL2561 Initialized. Printing detials now.
------------------------------------
Sensor:       TSL2561
Driver Ver:   1
Unique ID:    12345
Max Value:    17000.00 lux
Min Value:    1.00 lux
Resolution:   1.00 lux
------------------------------------

ACTUATOR_ONOFF_PIN
13
Set to OFF
ZactuatorONOFF setup done 
IR_EMITTER_PIN 
9
IR_RECEIVER_PIN 
2
ZgatewayIR setup done 
RF_EMITTER_PIN 
4
RF_RECEIVER_PIN 
1
RF setup ok
ZgatewayRFM69 initialization failed
ZgatewayRFM69 Listening and transmitting at
-1
FASTLED_DATA_PIN 
10
FASTLED_NUM_LEDS 
16
ZactuatorFASTLED setup done 
MQTT_MAX_PACKET_SIZE
1024
Setup OpenMQTTGateway end
client disconnected
eth disconnected
client disconnected
eth disconnected
client disconnected

…repeats for ever?

User_config.h:

     /*  
      OpenMQTTGateway  - ESP8266 or Arduino program for home automation 
       Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal  and a MQTT broker 
       Send and receiving command by MQTT
     
      This program enables to:
     - receive MQTT data from a topic and send signals corresponding to the received MQTT data
     - publish MQTT data to a different topic related to received signals
      
        Copyright: (c)Florian ROBERT
      
        This file is part of OpenMQTTGateway.
        
        OpenMQTTGateway is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        OpenMQTTGateway is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */
    #ifndef user_config_h
    #define user_config_h
    /*-------------------VERSION----------------------*/
    #define OMG_VERSION "0.9.2"

    /*-------------CONFIGURE WIFIMANAGER-------------(only ESP8266 & SONOFF RFBridge)*/
    /*
     * The following parameters are set during the WifiManager setup process:
     * - wifi_ssid
     * - wifi_password
     * - mqtt_user
     * - mqtt_pass
     * - mqtt_server
     * - mqtt_port
     * 
     * To completely disable WifiManager, define ESPWifiManualSetup.
     * If you do so, please don't forget to set these variables before compiling
     * 
     * Otherwise you can provide these credentials on the web interface after connecting 
     * to the access point with your password (SSID: WifiManager_ssid, password: WifiManager_password)
     */

    /*-------------DEFINE YOUR  NETWORK PARAMETERS BELOW----------------*/
    #if defined(ESP8266)||defined(ESP32)  // for nodemcu, weemos and esp8266
      //#define ESPWifiManualSetup true //uncomment you don't want to use wifimanager for your credential settings on ESP
    #endif

    #if defined(ESPWifiManualSetup) // for nodemcu, weemos and esp8266
      #define wifi_ssid "wifi ssid"
      #define wifi_password "wifi password"
    #else // for arduino + W5100
      const byte mac[] = {  0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95 }; //W5100 ethernet shield mac adress
    #endif

    #define WifiManager_password "your_password" //this is going to be the WPA2-PSK password for the initial setup access point 
    #define WifiManager_ssid "OpenMQTTGateway" //this is the network name of the initial setup access point
    #define WifiManager_ConfigPortalTimeOut 120
    #define WifiManager_TimeOut 5

    /*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
    //MQTT Parameters definition
    //#define mqtt_server_name "www.mqtt_broker.com" // instead of defining the server by its IP you can define it by its name, uncomment this line and set the correct MQTT server host name
    char mqtt_user[20] = "your_username"; // not compulsory only if your broker needs authentication
    char mqtt_pass[30] = "your_password"; // not compulsory only if your broker needs authentication
    char mqtt_server[40] = "192.168.1.100";
    char mqtt_port[6] = "1883";

    #ifndef Gateway_Name
      #define Gateway_Name "OpenMQTTGateway"
    #endif
    //uncomment the line below to integrate msg value into the subject when receiving
    //#define valueAsASubject true

    /*-------------DEFINE THE MODULES YOU WANT BELOW----------------*/
    //Addons and module management, comment the Z line

    #define ZgatewayRF     "RF"       //ESP8266, Arduino, ESP32
    //#define ZgatewayIR     "IR"       //ESP8266, Arduino,         Sonoff RF Bridge
    //#define ZgatewayLORA   "LORA"       //ESP8266, Arduino, ESP32
    //#define ZgatewayPilight "Pilight" //ESP8266, Arduino, ESP32
    //#define ZgatewayBT     "BT"       //ESP8266, ESP32
    //#define ZgatewayRF2    "RF2"      //ESP8266, Arduino, ESP32
    //#define ZgatewaySRFB   "SRFB"     //                          Sonoff RF Bridge
    //#define Zgateway2G     "2G"       //ESP8266, Arduino, ESP32
    //#define ZgatewayRFM69  "RFM69"    //ESP8266, Arduino, ESP32
    //#define ZactuatorONOFF "ONOFF"    //ESP8266, Arduino, ESP32,  Sonoff RF Bridge
    //#define ZsensorINA226  "INA226"   //ESP8266, Arduino, ESP32
    //#define ZsensorHCSR501 "HCSR501"  //ESP8266, Arduino, ESP32,  Sonoff RF Bridge
    //#define ZsensorADC     "ADC"      //ESP8266, Arduino, ESP32
    //#define ZsensorBH1750  "BH1750"   //ESP8266, Arduino, ESP32
    //#define ZsensorTSL2561 "TSL2561"  //ESP8266, Arduino, ESP32
    //#define ZsensorBME280  "BME280"   //ESP8266, Arduino, ESP32
    //#define ZsensorDHT     "DHT"      //ESP8266, Arduino, ESP32,  Sonoff RF Bridge
    //#define ZsensorGPIOKeyCode "GPIOKeyCode" //ESP8266, Arduino, ESP32
    //#define ZsensorGPIOInput "GPIOInput" //ESP8266, Arduino, ESP32
    //#define ZmqttDiscovery "HADiscovery"//ESP8266, Arduino, ESP32, Sonoff RF Bridge
    //#define ZactuatorFASTLED "FASTLED"  //ESP8266, Arduino, ESP32, Sonoff RF Bridge

    /*-------------DEFINE YOUR ADVANCED NETWORK PARAMETERS BELOW----------------*/
    //#define MDNS_SD //uncomment if you  want to use mdns for discovering automatically your ip server, please note that MDNS with ESP32 can cause the BLE to not work
    #define maxMQTTretry 4 //maximum MQTT connection attempts before going to wifi setup

    //set minimum quality of signal so it ignores AP's under that quality
    #define MinimumWifiSignalQuality 8

    // these values are only used if no dhcp configuration is available
    const byte ip[] = { 192, 168, 1, 99 }; //ip adress
    const byte gateway[] = { 192, 168, 1, 1 }; //ip adress, if first value is different from 0 advanced config network will be used and you should fill gateway & dns
    const byte Dns[] = { 192, 168, 1, 1 }; //ip adress, if first value is different from 0 advanced config network will be used and you should fill gateway & dns
    const byte subnet[] = { 255, 255, 255, 0 }; //ip adress

    /*-------------DEFINE YOUR MQTT ADVANCED PARAMETERS BELOW----------------*/
    #define Base_Topic "home/"
    #define version_Topic  Base_Topic Gateway_Name "/version"
    #define will_Topic  Base_Topic Gateway_Name "/LWT"
    #define will_QoS 0
    #define will_Retain true
    #define will_Message "offline"
    #define Gateway_AnnouncementMsg "online"

    #define jsonPublishing true //comment if you don't want to use Json  publishing  (one topic for all the parameters)
    //example home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4 {"rssi":-63,"servicedata":"fe0000000000000000000000000000000000000000"}
    #define jsonReceiving true //comment if you don't want to use Json  reception analysis

    //#define simplePublishing true //comment if you don't want to use simple publishing (one topic for one parameter)
    //example 
    // home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4/rssi -63.0
    // home/OpenMQTTGateway_ESP32_DEVKIT/BTtoMQTT/4XXXXXXXXXX4/servicedata fe0000000000000000000000000000000000000000
    #define simpleReceiving true //comment if you don't want to use old way reception analysis

    /*-------------DEFINE YOUR OTA PARAMETERS BELOW----------------*/
    #define ota_hostname Gateway_Name
    #define ota_password "OTAPASSWORD"
    #define ota_port 8266

    /*-------------DEFINE PINs FOR STATUS LEDs----------------*/
    #ifdef ESP8266
      #define led_receive 40
      #define led_send 42
      #define led_info 44
    #elif ESP32
      #define led_receive 40
      #define led_send 42
      #define led_info 44
    #elif __AVR_ATmega2560__ //arduino mega
      #define led_receive 40
      #define led_send 42
      #define led_info 44
    #else //arduino uno/nano
      #define led_receive 40
      #define led_send 42
      #define led_info 44
    #endif

    //      VCC   ------------D|-----------/\/\/\/\ -----------------  Arduino PIN
    //                        LED       Resistor 270-510R

    /*----------------------------OTHER PARAMETERS-----------------------------*/
    /*-------------------CHANGING THEM IS NOT COMPULSORY-----------------------*/
    /*----------------------------USER PARAMETERS-----------------------------*/
    #ifdef ZgatewaySRFB
      #define SERIAL_BAUD 19200
    #else
      #define SERIAL_BAUD 115200
    #endif
    /*--------------MQTT general topics-----------------*/
    // global MQTT subject listened by the gateway to execute commands (send RF, IR or others)
    #define subjectMQTTtoX  Base_Topic Gateway_Name "/commands/#"
    #define subjectMultiGTWKey "toMQTT"
    #define subjectGTWSendKey "MQTTto"

    //variables to avoid duplicates
    #define time_avoid_duplicate 3000 // if you want to avoid duplicate mqtt message received set this to > 0, the value is the time in milliseconds during which we don't publish duplicates

    #if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
      #define JSON_MSG_BUFFER 512 // Json message max buffer size, don't put 1024 or higher it is causing unexpected behaviour on ESP8266
    #else // boards with smaller memory
      #define JSON_MSG_BUFFER 64 // Json message max buffer size, don't put 1024 or higher it is causing unexpected behaviour on ESP8266
    #endif

    #define TimeBetweenReadingSYS 120000 // time between system readings (like memory)
    #define subjectSYStoMQTT  Base_Topic Gateway_Name "/SYStoMQTT"

    //#define subjectTRACEtoMQTT Base_Topic Gateway_Name "/log" //uncomment if you want to see traces on /log topic

    /*-------------------ACTIVATE TRACES----------------------*/
    #define TRACE 1  // commented =  trace off, uncommented = trace on

    #endif

Update:
I ruled out faulty hardware by running the example:
“DHCP Chat Server”

--- Miniterm on /dev/ttyUSB1  9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Trying to get an IP address using DHCP
My IP address: 192.168.1.126
We have a new client
working#kjhjkghkhkjgykjtest

Hello,

Are you using the last development version or the release one?

If GitHub clone = development and the .zip = release version.
Than I think I’m on the release version.
I followed a link “download the code from here”
There was a list of prebuild bins and ontop OMG 0.9.2 code.zip can’t find the page right now.

I’ll now try again with a recent GitHub clone.

Perhaps it a good idea to make a centralized:
“How to get started”
“How to setup VSC & platformio”
“How to obtain code”
“How to configure the code”

I found OMG quite interesting but I get confused with all the simultaneous info streams. Perhaps I’m stepping in OMG while it is in transition.

By the way I’m going for atmega with Pilight RF and RF2 GSM SMS if possible.

Hello,

Did you took a look to this documentation:
http://docs.openmqttgateway.com

You should download the code from the release page:

I’m going to test if there is an issue with the development branch for arduino.

Today I’ve tried the OpenMQTTGateway-development from github.
In platformio.ini I uncommented:

default_envs = atmega-all

In User_config.h I uncommented:

#define ZgatewayRF     "RF"       //ESP8266, Arduino, ESP32
#define ZgatewayRF2    "RF2"      //ESP8266, Arduino, ESP32

And chanced:

char mqtt_user[20] = “testuser”; // not compulsory only if your broker needs authentication
char mqtt_pass[30] = “testpassword”; // not compulsory only if your broker needs authentication
char mqtt_server[40] = “192.168.1.100”;
char mqtt_port[6] = “1883”;

Now the serial output is missing: client disconnected
But still no sign of atmega OpenMQTTGateway on my MQTT broker.
And no DHCP lease in my router log.
192.168.1.99 is still pingable (leds on w5100 blinks when I ping)

> Executing task in folder OpenMQTTGateway-development: platformio device monitor <

--- Miniterm on /dev/ttyUSB1  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Spl eth cfg
ip: 
192.168.1.99
Eth ok
1883
Connecting to MQTT by IP adress
192.168.1.100
Bosch BME280 Initialized - Result of .begin(): 0x0
No TSL2561 detected
TSL2561 Initialized. Printing detials now.
------------------------------------
Sensor:       TSL2561
Driver Ver:   1
Unique ID:    12345
Max Value:    17000.00 lux
Min Value:    1.00 lux
Resolution:   1.00 lux
------------------------------------

ACTUATOR_ONOFF_PIN
13
Set to OFF
ZactuatorONOFF setup done 
IR_EMITTER_PIN 
9
IR_RECEIVER_PIN 
2
ZgatewayIR setup done 
RF_EMITTER_PIN 
4
RF_RECEIVER_PIN 
1
RF setup ok
ZgatewayRFM69 initialization failed
ZgatewayRFM69 Listening and transmitting at
-1
FASTLED_DATA_PIN 
10
FASTLED_NUM_LEDS 
16
ZactuatorFASTLED setup done 
MQTT_MAX_PACKET_SIZE
1024
Setup OpenMQTTGateway end
eth disconnected
eth disconnected
eth disconnected
eth disconnected
Spl eth cfg
ip: 
192.168.1.99
Eth ok
1883
Connecting to MQTT by IP adress
192.168.1.100
Bosch BME280 Initialized - Result of .begin(): 0x0
No TSL2561 detected
TSL2561 Initialized. Printing detials now.
------------------------------------
Sensor:       TSL2561
Driver Ver:   1
Unique ID:    12345
Max Value:    17000.00 lux
Min Value:    1.00 lux
Resolution:   1.00 lux
------------------------------------

ACTUATOR_ONOFF_PIN
13
Set to OFF
ZactuatorONOFF setup done 
IR_EMITTER_PIN 
9
IR_RECEIVER_PIN 
2
ZgatewayIR setup done 
RF_EMITTER_PIN 
4
RF_RECEIVER_PIN 
1
RF setup ok
ZgatewayRFM69 initialization failed
ZgatewayRFM69 Listening and transmitting at
-1
FASTLED_DATA_PIN 
10
FASTLED_NUM_LEDS 
16
ZactuatorFASTLED setup done 
MQTT_MAX_PACKET_SIZE
1024
Setup OpenMQTTGateway end
eth disconnected
eth disconnected
eth disconnected
eth disconnected
eth disconnected
eth disconnected
eth disconnected

It’s a pity you did not try the official release from the link I gave above.

Indeed I found that the dev branch has an issue when using W5100, this issue doesn’t exist in the official releases.

I will push a correction soon for the dev branch.

Fix implemented:

1 Like

Thanks!!!

Yesterday I already tried the release version the zip from:
https://github.com/1technophile/OpenMQTTGateway/releases/download/v0.9.2/CODE-OpenMQTTGateway-V092.zip

I can try it again! If that helps? but first I’m try de developers again.

I’ve patched local files here and now:

Taaadaaa!!

1571858342: Received PINGREQ from mqtt_e31b877c.65a018
1571858342: Sending PINGRESP to mqtt_e31b877c.65a018
1571858349: Received PINGREQ from OpenMQTTGateway_ATMEGA_ALL
1571858349: Sending PINGRESP to OpenMQTTGateway_ATMEGA_ALL

Thank you for your quick response.

1 Like

So what is the solution? What patches are you talking about?

The bypass implementation by 1technophile. See link above.

Thanks, I didn’t get that your “I’ve patched local files” meant “I used his fix” :wink: