Mega 2560 Pro + W5100 + NRF24 Gateway



  • Hi,
    Now before you point me at all the relevant threads:
    https://forum.mysensors.org/topic/1245/building-an-ethernet-gateway-on-an-arduino-mega
    https://forum.mysensors.org/topic/4680/mysensors-2-0-ethernet-gateway-atmega-w5100-restart-all-time/9
    https://forum.mysensors.org/topic/4668/ethernet-gateway-on-arduino-mega-2056-issues/14

    I have read all of these and I am totally confused and feeling a bit dumb. I have a Mega 2560 Pro board and an NRF24 module - I wired this up the same as a number of other similar setups I have with the NRF hooked up as follows:

    49 CE
    50 MISO
    51 MOSI
    52 SCK
    53 CSN

    If I simply load a repeater node sketch to this it works perfectly. So then I come along and hook up the W5100 - this must be where I am wrong or do not understand something because there seems to be conflicting information, anyway it is hooked up as follows:

    10 SS/CS
    11 MOSI/SI
    12 MIOS/SO
    13 SCK

    Now I am trying to load the GatewayW5100MQTTClient.ino - i have changed the following:

    #ifndef MY_RF24_CE_PIN
    #define MY_RF24_CE_PIN 49
    #endif
    #ifndef MY_RF24_CS_PIN
    #define MY_RF24_CS_PIN 53
    #endif
    

    I have tried with this code Enabled and disabled with the following:

    #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
    

    It seems I cannot get a IP address and the system just loops

    0 MCO:BGN:INIT GW,CP=R-NGA---,VER=2.3.0
    304 GWT:TPC:IP=0.0.0.0
    1305 MCO:BGN:STP
    1307 MCO:REG:NOT NEEDED
    1309 MCO:BGN:INIT OK,TSP=NA
    1612 GWT:TPC:IP=255.255.255.255
    2615 GWT:RMQ:MQTT RECONNECT
    2918 GWT:TPC:IP=255.255.255.255
    3921 GWT:RMQ:MQTT RECONNECT
    4225 GWT:TPC:IP=255.255.255.255
    

    Is there a definitive guide on how to hook up and configure the MEGA as a gateway with the W5100 module. I can see people taking about A0-A2 pins and others talking about 14-16 and mixes of the above but I an just looking for a working solution. Please help!



  • @itbeyond You did not indicate if you are using a W5100 module or a W5100 Ethernet Shield.

    Normally i use standard Mysensors gateways and use MQTT for other devices.
    However i have just tried using the example sketch GatewayW5100MQTTClient.ino from the mySensors Library.

    Plugging in a Ethernet Shield (That uses the ICSP connector) to a mega board.
    Connecting the NRF24L01 :
    5 NRF module SOFT SPI CE Orange
    6 NRF module SOFT SPI CS Yellow
    14 NRF module SOFT SPI SCK Green
    15 NRF module SOFT SPI MOSI Blue
    16 NRF module SOFT SPI MISO Purple

    and entering my MQTT details it connected immediately.

    Testing a W5100 module connected to
    52 Ethernet SCK
    51 Ethernet MOSI
    50 Ethernet MiSO
    10 Ethernet SS/CS
    also works

    It should be noted that digital pin 14 is the Same as A0 on a Uno/ Mini Pro but a separate pin on the Mega
    likewise digital pin 15 = A1, and digital pin 16 = A2, but on only on Uno's etc

    If you are planing on using the gateway as a sensor as well then i should move the NRF connections to other digital pins to allow the pins 14-16 to be available for hardware serial communication.



  • @hard-shovel thanks very much clear and concise. I was having some trouble using 50, 51,52 & 10 so went for the ICSP header - I am using a module not a sheild as the 2560 Pro is not a shield type module alt text

    But it has headers at the end for the ICSP port and it is as easy to use those as the 50 and so on. I also had some trouble with the 5V supply to the module when I pulled it from the 5V lines on the module but the 5v port on the ICSP worked. I am now soldering all this up and will provide a 2amp power supply at 5v to run the high powered radio module I am installing, this will power the ethernet and mega. I have built an additional power supply for the 3.3v to the radio from this supply.

    BTW: Is it normal to see connect/re-connect sequences or is this still a power supply problem as I am testing via the usb connection to the computer at the moment?

    88620 GWT:RMQ:MQTT CONNECTED
    88623 GWT:TPS:TOPIC=mys1-out/0/255/0/0/18,MSG SENT
    118932 GWT:TPC:IP=192.168.100.63
    119936 GWT:RMQ:MQTT RECONNECT
    120244 GWT:TPC:IP=192.168.100.63
    121247 GWT:RMQ:MQTT RECONNECT
    136553 GWT:TPC:IP=192.168.100.63
    137556 GWT:RMQ:MQTT RECONNECT
    137563 GWT:RMQ:MQTT CONNECTED
    137566 GWT:TPS:TOPIC=mys1-out/0/255/0/0/18,MSG SENT
    


  • I would just like to conclude this post and again thanks to @hard-shovel for the connection information. I have now setup the hard wired unit and the connect/reconnects went away. The gateway connected directly to the broker I had setup on the openHab RPi running mosquitto and it started SENDING topics from my already running network. I am now working on the openHab configuration of the items but have already received a number of items from mySensors to openHab. I will play with sending data shortly once I work out my upgrade path from Vera some more and test the way you need to setup nodes on openHab.



  • @itbeyond Good news that it working and the Reconnect problem solved, intermittent connections can be nightmare to locate.
    You should have fun with OpenHab getting used to its quirks and fables.



  • Im jealous! Im stuck on the gateway not receiving messages.


Log in to reply
 

Suggested Topics

  • 3
  • 8
  • 2
  • 5
  • 6

62
Online

11.4k
Users

11.1k
Topics

112.7k
Posts