💬 Building an Ethernet Gateway


  • Admin

    This thread contains comments for the article "Building an Ethernet Gateway" posted on MySensors.org.



  • i have this problem:

    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;!TSM:RADIO:FAIL
    0;255;3;0;9;!TSM:FAILURE
    0;255;3;0;9;TSM:PDT
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;!TSM:RADIO:FAIL
    0;255;3;0;9;!TSM:FAILURE
    0;255;3;0;9;TSM:PDT
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;!TSM:RADIO:FAIL
    0;255;3;0;9;!TSM:FAILURE
    0;255;3;0;9;TSM:PDT
    

    i use ENC28J60 module . arduino nano + nrf24 + 4.7uf
    this code:

    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // When ENC28J60 is connected we have to move CE/CSN pins for NRF radio
    #define MY_RF24_CE_PIN 5
    #define MY_RF24_CS_PIN 6
    
    // Enable gateway ethernet module type 
    #define MY_GATEWAY_ENC28J60
    
    // Gateway IP address
    #define MY_IP_ADDRESS 192,168,0,110
    
    // The port to keep open on node server mode / or port to contact in client mode
    #define MY_PORT 5003   
    
    // Controller ip address. Enables client mode (default is "server" mode). 
    // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. 
    //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254   
    
    // The MAC address can be anything you want but should be unique on your network.
    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
    // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
    
    // Flash leds on rx/tx/err
    #define MY_LEDS_BLINKING_FEATURE
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // 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 
    
    #define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
    #define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN  9  // the PCB, on board LED
    
    #include <SPI.h>
    #include <UIPEthernet.h>
    #include <MySensors.h>
    
    
    void setup()
    {
    }
    
    void loop() {
    }```


  • Would like to use MQTT gateway using RFM69. The RFM69 cannot be used with W5100 because of soft-spi, is this still the case? Can it then be used with ENC28J60?


  • Hardware Contributor

    @gvorster
    hello, i'm working on rfm69 (refactorization and adding features), which will support softspi and w5100, and uses a lot less memory. might be available soon.



  • @scalz said:

    @gvorster
    hello, i'm working on rfm69 (refactorization and adding features), which will support softspi and w5100, and uses a lot less memory. might be available soon.

    Great, looking forward to it!



  • Hi, i i try compile GatewayW5100.ino on this page then result is compiler error:

    Arduino: 1.6.12 (Windows 10), Board: "Arduino Nano, ATmega328"

    In file included from C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:23:0,

                 from C:\Users\M\Documents\Arduino\libraries\MySensors-master/MySensors.h:261,
    
                 from C:\Users\M\AppData\Local\Temp\arduino_modified_sketch_502474\sketch_oct22a.ino:116:
    

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:34:31: error: 'SPI_MODE0' was not declared in this scope

    #define MY_RF24_SPI_DATA_MODE SPI_MODE0

                               ^
    

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:76: note: in expansion of macro 'MY_RF24_SPI_DATA_MODE'

    SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                            ^
    

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:97: error: template argument 4 is invalid

    SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                                                 ^
    

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:103: error: invalid type in declaration before ';' token

    SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                                                       ^
    

    In file included from C:\Users\M\Documents\Arduino\libraries\MySensors-master/MySensors.h:261:0,

                 from C:\Users\M\AppData\Local\Temp\arduino_modified_sketch_502474\sketch_oct22a.ino:116:
    

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'uint8_t RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool)':

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:44:24: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

    uint8_t status = _SPI.transfer( cmd );

                        ^
    

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:47:18: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

    status = _SPI.transfer( NOP );
    
                  ^
    

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:49:24: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

    } else status = _SPI.transfer(*current++);

                        ^
    

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'bool RF24_initialize()':

    C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:261:7: error: request for member 'begin' in '_SPI', which is of non-class type 'int'

    _SPI.begin();

       ^
    

    exit status 1
    Error compiling for board Arduino Nano.

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    Could you please help?

    Thanks.


  • Mod

    If anyone answers @Marek-Běluša, please answer in https://forum.mysensors.org/topic/5159/ethernet-gateway-compile-error/ to avoid working in two different threads. Do not answer here.

    @Marek-Běluša please do not post the same question in more than one place.



  • I've spent hours and hours to get the W5100 Ethernet Module working on my Arduino Nano board and unfortunately without success. I'm using the MySensors version 2.0 with the Arduino AVR Boards 1.6.15 installed. I don't understand the issue at all. I cannot ping W5100 should, not if I use a static IP or if I configure to use DHCP. I've tested it with and without the NRF24L01 Radio connected and no luck. I've checked the wires already 10 times. This is the wire-ring info:
    W5100 <=> Arduino Nano
    VDD <=> Pin 27 / +5V
    NSS <=> Pin 13 / D10
    MOSI <=> Pin 14 / D11
    GND <=> Pin 4
    SCK <=> Pin 16 / D13
    MISO <=> Pin 15 / D12

    Is this the correct wire configuration? What else can I do to debug this?

    On the W5100 I see the link led blinking on a regular basis almost at the same time as the Rx led, but I read that this HW issue and doesn't influence the behaviour of the ethernet board. Is this correct? If not, how to resolve this?

    Looking forward to hints and tips as I'm completely lost on this topic.


  • Mod

    @rbighouse have you seen the wiring guide in the page linked in the first post in this thread?



  • @mfalkvidd yes I've read that, even multiple times. I've check the wiring 10 times as well and cannot find a difference. Also changed to another W5100 board as well as a different Arduino Uno board to make sure it is not a board issue. The problem stays the same. What I've noticed as a difference is that my W5100 runs on 5V and not on 3.3V as indicated in the wiring table. Connecting the W5100 with 3.3V doesn't start (boot up) the board.



  • Just thought I'd mention that I've had good experience with adding a capacitor between GND and VCC for the ethernet module as well.
    Same approach as for wiring the radio. https://www.mysensors.org/build/connect_radio

    Previously had problems with GW disconnecting (Eth: disconnect) which is now reduced.



  • Same problem like Reza, same error messages AND I USING ethernet shield, ARDUINO MEGA AND nrf24



  • And using ARDUINO 1 the same problem.
    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;!TSM:RADIO:FAIL
    0;255;3;0;9;!TSM:FAILURE
    0;255;3;0;9;TSM:PDT
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;!TSM:RADIO:FAIL
    0;255;3;0;9;!TSM:FAILURE
    0;255;3;0;9;TSM:PDT



  • Had lots of issues getting this to work. The issue seems to be with the ethernet part, as I only have an ethernet board attached I removed the lines for the radio and the pin redirection. Still the code kept restarting all the time or just not being able to connect the controller.

    AVR version of the Arduino 1.8.0 kit needs to be downgraded. I had 1.6.16 and downgraded to 1.6.11.

    Open Arduino. Tools > Board: xxxxx > Boards manager... > Click "Arduino AVR Boards" > Select Version > 1.6.11

    Recompile and you are good.



  • Hi @DallieNL ,
    thanks for your tips,
    I got the same issue with serial gateway, 1.6.11 is the best.

    David.



  • Would it be possible to build an MQTT gateway using the ESP8266 WiFi Gateway?


  • Admin

    @mpp said:

    Would it be possible to build an MQTT gateway using the ESP8266 WiFi Gateway?

    Yes, the MQTT gateway works on ESP as well.



  • Anyone have an instruction to set up a W5500 ethernet gateway?


  • Hardware Contributor

    @LaMB95
    For the moment, i don't think there is an howto regarding w5500 as we're mostly using w5100, but maybe you can find some infos in this topic https://forum.mysensors.org/topic/2901/my-ethernet-gateway-board-w5500



  • Hi All,
    I have an ethernet gateway base on arduino Pro mini with NRF24L01 radio and Funding ethernet card with W5100 chips. (As per description of this page)
    All works fine when I'm connected to it with Arduino IDE. Works for hours/days.
    If I unplug the IDE (disconnect USB) and run it alone it stop working after for minutes or few hours.
    I have only one sensor (temperature) to test. It send Temperature and battery level every 10s (testing). Led attached to Gateway to show the traffic lit up twice each time it receive the information from the sensor. The LED lit up twice like half a second when everything is fine. Easy to see.
    When the issue starts, the led lit up time to time but very quickly, and even very difficult to see. Some time I can ping the Gateway, some time not.
    Any idea from anybody ?



  • additional info: Same situation having //#define MY_DEBUG defined or not.



  • Looks like the issue is related to the power supply. I just plugged a 5V to the USB and It has been working fine for 24h. Need to review the Power supply in place.



  • The first one will not compile since the #include <SPI.h> is missing



  • Hello guys,
    Can anyone help me with modify this to work with W5500 Ethernet module?
    Please advice us what need to be modified and why it needs to be modified.
    Thanks you very much.


  • Mod



  • Hi Guys,

    I'm using a Wiznet W5100 Ethernet module.
    The pins are described as following (I added a numbering myself:
    0_1487281914650_upload-a05aa788-d1ac-4ef0-b42a-7ad6b28b6e9c

    The MySensors Gateway uses different terms, am I 'translating' them correctly?
    0_1487282198655_upload-1949b0d7-52ae-4059-a4e3-e68941dafbe4



  • @Chucky_69
    Looks right!



  • My WizNET (W5100) Ethernet module had to be connected to 5v pin on arduino as the 3.3v would only allow ping but not function properly.



  • Maybe I just overlooked that, but is it possible to statically define netmask and gateway in the sketch? I'm using ENC28J60.


  • Mod

    @AndrewZ I think you can use

    MY_IP_GATEWAY_ADDRESS
    MY_IP_SUBNET_ADDRESS
    


  • @mfalkvidd , yes I also found this in MQTT GW example, thanks.
    This seems to be not working on my ENC28J60 - as I can see the the default gateway setting is not taken into account. I will test with W5100.

    Edit: I confirm that these settings work properly with W5100, just tested.



  • I just spent a long time troubleshooting my problems trying to set this up and I thought I would share. I followed this tutorial and everything was a breeze except my unit kept rebooting and I couldn't figure out why. I thought for the longest time it was the power supply but it ended up being the version of Arduino IDE I was using. I found some answers https://forum.mysensors.org/topic/4628/solved-mysensors-2-0-ethernet-gateway-enc28j60-restart-ip-issue/46 and https://forum.mysensors.org/topic/4680/mysensors-2-0-ethernet-gateway-atmega-w5100-restart-all-time that got me down the right path. I downgraded to "Arduino IDE 1.6.11" and that worked. I completely uninstalled arduino from my system and just started over with the older version. I assembled everything as I had done before and it just fired right up. The mysensors library I used was 2.0.0 and again it all worked perfectly. I was amazed. I didnt have to comment out the debug or do anything other than follow the tutorial EXCEPT only use 1.6.11 to upload it all.
    Hope this helps someone in the future.



  • @hoggin At least according to my experience, just downgrading the AVR Board Definitions to <=1.6.11 using the Board-Manager within an recent version of the IDE should have done the trick; downgrade of the other libs including mysensors (2.1.1) was not necessary.

    In Addition: For the serial Gateways this kind of trouble seems to be solved since version 1.6.18 of the AVR-Board definitions (shipped since several weeks).



  • @rejoe2 Perhaps you are correct. I am not nearly as well versed in this stuff as others. I was working on the Ethernet project so I didn't spend much time messing with the serial end of it.



  • @hoggin I don't have experience with the ethernet part and just wanted to point out that your solution may be a little "overdone" (but I'm not sure about that).
    Anyhow: Perhaps you should add a remark wrt. to this to your other post doubling the info you wrote here to avoid others doing tho long round instead of the direct way?



  • @rejoe2 I think you are suggesting that I create a link between this post and the other one. Here Hopefully this will direct people to more information regarding the rebooting issue i faced.



  • @hoggin The post I had in mind is this one: https://forum.mysensors.org/topic/6149/ethernet-gateway-shows-up-on-vera-but-doens-t-want-to-include-devices/17#
    I am going to post a similar answer also there.



  • @rejoe2 Sounds good.



  • I have a Vera but I'm moving some of my stuff over to OpenHab. So on one side I was using the standard W5100 GateWay on the other I need the MQTT GateWay. The major difference is in the "define MY_PORT" one is 5003 and the other is 1883. Is there a way to do both? Thanks.



  • @hek just tested the gateway sketch on an esp with an rfm69 and it looks really promising. Would it be possible to communicate with moteino's or do I have to create arduino+rfm69 nodes running the mysensor sketch?


  • Mod

    @mpp according to this:

    Moteino is a low power wireless Arduino compatible development platform based on the popular ATmega328p chip used in the Arduino-UNO, making it 100% compatible with the Arduino IDE (programming environment) ... They are compatible with any other Arduino clones that use the popular HopeRF RFM69 transceiver

    so they should work just fine. Just upload one of the MySensors example sketches to the moteino and try.


  • Mod

    Just for sharing, yesterday I was playing around and I tried to make an ethernet gateway with a UNO with w5100 shield and a nrf24 radio, then I attached a DHT11 sensor to it; when I compiled the sketch I had to disable the MY_DEBUG otherwise the I could not upload it to the UNO as it was using 102% of available memory and even with no debug the Arduino IDE was giving me warning about low ram memory available that could make system unstable. I then removed the NRF24 part as I didn't need it at the moment and the sketch compiled smoothly.
    It looks like the MEGA2560 could be a better candidate if you want to make a gateway with some sensors.



  • Solved: challenge with requesttime

    Update: mysensors adapter 1.0.7 for ioBroker solved the issue.

    Challenge:
    my arduino node20 is requesting epoch time. W5100 gateway forwards message to controller (ioBroker). This is the gateways console in debug:
    0;255;3;0;9;TSF:MSG:READ,20-20-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
    0;255;3;0;9;Eth: 20;255;3;1;I_TIME;1491770622
    0;255;3;0;9;TSF:MSG:SEND,0-0-20-20,s=255,c=3,t=0,pt=0,l=10,sg=0,ft=0,st=OK:1491770622
    0;255;3;0;9;TSF:MSG:READ,20-20-0,s=255,c=3,t=0,pt=0,l=10,sg=0:1491770622
    0;255;3;0;9;TSF:MSG:ACK

    The parser helps with the interpretation:

    1. request from node20 (Arduino) t=1 (=I_TIME)
    2. gateway receives epoch time from controller (ioBroker)
    3. gateway forwards info to node20. BUT: now with t=0 (=I_BATTERY_LEVEL)!!!!!!!!!!!!!!!
    4. node20 confirms battery level (and still doesn't know the time)

    I'm using the ordinary gateway for W5100. Sensordata moves flawless to the controller but forwarding the time seems to be broken.

    Any idea? Thank you in advance.



  • The reason why the 5100 module has problems sharing the SPI interface is because it lacks some hardware compared to the W5100 shield.
    On (most of) the module(s) the SEN (SPI Enable) pin is pulled HIGH with a resistor, whereas on the W5100 shield it also receives the inverted CS signal.
    That means that when the chip is deselected (CS=HIGH), the SEN pin receives a LOW and the SPI is switched off.
    Apparently the state of the SS pin through the CS signal is not enough to Switch off the W5100 SPI: the MISO remains active, the SEN pin neds to be addressed too to shut off SPI completely.
    If it works with a virtual SPI connection, great, but if you want to "fix" the hardware SPI, all you need to do is to invert the CS signal with a 74xx14 or maybe even a 74xx04 and feed that to the SEN pin of the chip.
    https://arduinodiy.wordpress.com/2017/04/12/the-w5100-bug/



  • i'm using w5100 and mega, checking wiring 10 times and successfully uploaded code didn't change anything in code just copy paste but it seem like is not working i installed domoticz controller and it log to me
    2017-04-17 21:51:38.438 Error: MySensors: Can not connect to: 192.168.178.66:5003
    2017-04-17 21:51:38.438 TCP: Connection problem (Unable to connect to specified IP/Port)
    Also i can't see any new client in router client table, rx led is blinking but tx led on w5100 is always off
    can anyone tell me how can i see if gw is working, i don't know is the problem on controller or hw? and how can i fix the problem?
    THX for any help, and excuse for my english please 😉


  • Mod

    Try with any other sketch even not mysensors and check if ip is working, if still not working could be also the Chinese clone shield: I had one that got the wrong termination resistors and I fixed it by soldering 1 100ohms resistor between pin 1-2 and 1 between pin 3-6 below the ethernet socket



  • probably dumb question but where can i found any sketch to test the shield i tried ethernet examples from arduino ide but dont know how to connect the right pins it just said like: (Ethernet shield attached to pins 10, 11, 12, 13)





  • Could you send us a picture with the module?



  • look like the Chinese shield is crap i try to test the web server example and nothing displayed



  • @Mitja-Blazinsek can you check your lineresistors? It is the spider like, 8 legged rrsistor array as in this picture https://arduinodiy.files.wordpress.com/2017/04/w5100bug2.png?w=768&h=332
    what is the value?



  • Maybe you have the ENC28J60 module which is different than w5100.

    try this code at the beginning of your sketch(using a mysensor's example)

    you have to change the ip to match your subnet and try to ping it.

    You can find the correct pinout here http://s3.electrodragon.com/wp-content/uploads/2011/11/172004eierrfwri9xsfamq-11.jpg

    #define MY_GATEWAY_ENC28J60
    #define MY_IP_ADDRESS 192,168,1,66  
    #define MY_PORT 5003   
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
    #include <UIPEthernet.h>```


  • i'm sure it's w5100 it's label on chip
    https://goo.gl/photos/xkr326Zrjgom2Ko57



  • @Mitja-Blazinsek exactly the same module I have. Funduino right? Is working here


  • Mod

    Look at THIS page, half way down, there is the picture where to solder the 2 resistors.



  • @Mitja-Blazinsek I went back to what I have done to get that module to work and I remember the only thing I had to do was add a delay in the setup, as most problems with that funduino board seem to be because of a Reset problem:
    with this setup It works for me:

    void setup() {
    // setup ethernet communication using DHCP
    delay(250); /// <-------- THAT ONE, BEFORE your ethernet.begin statement
    if (Ethernet.begin(mac) == 0) {
    //Serial.println(F("Unable to configure Ethernet using DHCP"));
    for (;;);
    }

    Forget about "changing the 510 resistors" that is something that is valid for some shields, not for the Funduino module.
    I only have the Miso,Mosi,SCK and NSS connected (and Vcc/ground ofcourse). NOT the RST. Besides, if you connect RST you cannot upload sketches as your Arduino will continuously reset



  • @Mitja-Blazinsek Is your problem solved now Mitja?
    connecting stand alone W5100 to ethernet should be solved by the delay i advised. I guess it should work with rfm69 if you set up the software SPI as described, but if you want to use hardware SPI a slight modification is necessary, which i described earlier



  • This post is deleted!


  • I am not sure where I went wrong the below code hangs half way through. I am using ENC28J60
    https://www.aliexpress.com/item/Mini-ENC28J60-Webserver-module-Ethernet-Shield-board-for-Arduino-Nano-v3-0/2037927977.html?spm=2114.40010208.4.8.mUp9p8

    #ifndef config_h
    #define config_h
    #include <stdint.h>
    
    /**********************************
       MySensors configuration
    **********************************/
    //#define MY_BAUD_RATE 9600
    #define MY_DEBUG
    //#define MY_BAUD_RATE 38400
    //#define MY_BAUD_RATE 115200
    //#define MY_NODE_ID 100
    
    #define MY_RADIO_NRF24
    
    // Enable gateway ethernet module type
    #define MY_GATEWAY_ENC28J60
    //#define MY_GATEWAY_W5100
    // Enabled repeater feature for this node
    //#define MY_REPEATER_FEATURE
    
    
    // Enable Soft SPI for NRF radio (note different radio wiring is required)
    // The ENC28J60 ethernet module seems to have a hard time co-operate with
    // radio on the same spi bus.
    #define MY_SOFTSPI
    #define MY_SOFT_SPI_SCK_PIN 14
    #define MY_SOFT_SPI_MISO_PIN 16
    #define MY_SOFT_SPI_MOSI_PIN 15
    
    
    // When ENC28J60 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
    
    
    // Gateway IP address
    #define MY_IP_ADDRESS 192,168,0,66
    
    // The port to keep open on node server mode / or port to contact in client mode
    #define MY_PORT 5003
    
    // Controller ip address. Enables client mode (default is "server" mode).
    // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
    //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 0, 55
    
    // The MAC address can be anything you want but should be unique on your network.
    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
    // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xFE
    
    // Flash leds on rx/tx/err
    //#define MY_LEDS_BLINKING_FEATURE
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // 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
    
    #define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
    #define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN  9  // the PCB, on board LED
    
    
    
    //#define MY_DISABLED_SERIAL
    
    
    // Turn off debug if serial pins is used for other stuff
    #ifdef MY_DISABLED_SERIAL
    #undef MY_DEBUG
    #endif
    
    
    /**********************************
    *  Gateway config
    ***********************************/
    
    /**
     * @def MY_GATEWAY_MAX_RECEIVE_LENGTH
     * @brief Max buffersize needed for messages coming from controller.
     */
    #ifndef MY_GATEWAY_MAX_RECEIVE_LENGTH
    #define MY_GATEWAY_MAX_RECEIVE_LENGTH (100u)
    #endif
    
    
    /**
     * @def MY_GATEWAY_MAX_SEND_LENGTH
     * @brief Max buffer size when sending messages.
     */
    #ifndef MY_GATEWAY_MAX_SEND_LENGTH
    #define MY_GATEWAY_MAX_SEND_LENGTH (120u)
    #endif
    
    /**
     * @def MY_GATEWAY_MAX_CLIENTS
     * @brief Max number of parallel clients (sever mode).
     */
    #ifndef MY_GATEWAY_MAX_CLIENTS
    #define MY_GATEWAY_MAX_CLIENTS (1u)
    #endif
    
    
    /**
    * @def MY_RX_MESSAGE_BUFFER_FEATURE
    * @brief This enabled the receiving buffer feature.
    *
    * This feature is currently not supported for RFM69 and RS485, for RF24 MY_RF24_IRQ_PIN has to be defined.
    */
    //#define MY_RX_MESSAGE_BUFFER_FEATURE
    
    /**
     * @def MY_RX_MESSAGE_BUFFER_SIZE
     * @brief Declare the amount of incoming messages that can be buffered.
     */
    #ifdef MY_RX_MESSAGE_BUFFER_FEATURE
    #ifndef MY_RX_MESSAGE_BUFFER_SIZE
    #define MY_RX_MESSAGE_BUFFER_SIZE  (20)
    #endif
    #endif
    
    /**
     * @def MY_RF24_PA_LEVEL
     * @brief Default RF24 PA level. Override in sketch if needed.
     */
    #ifndef MY_RF24_PA_LEVEL
    #define MY_RF24_PA_LEVEL RF24_PA_MAX
    #endif
    
    /**
     * @def MY_RF24_CHANNEL
     * @brief RF channel for the sensor net, 0-125.
     * Frequence: 2400 Mhz - 2525 Mhz Channels: 126
     * http://www.mysensors.org/radio/nRF24L01Plus.pdf
     * 0 => 2400 Mhz (RF24 channel 1)
     * 1 => 2401 Mhz (RF24 channel 2)
     * 76 => 2476 Mhz (RF24 channel 77)
     * 83 => 2483 Mhz (RF24 channel 84)
     * 124 => 2524 Mhz (RF24 channel 125)
     * 125 => 2525 Mhz (RF24 channel 126)
     * In some countries there might be limitations, in Germany for example only the range 2400,0 - 2483,5 Mhz is allowed
     * http://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Allgemeinzuteilungen/2013_10_WLAN_2,4GHz_pdf.pdf
     */
    #ifndef MY_RF24_CHANNEL
    #define MY_RF24_CHANNEL  76
    #endif
    
    /**
     * @def MY_RF24_DATARATE
     * @brief RF24 datarate (RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps or RF24_2MBPS for 2Mbps).
     */
    #ifndef MY_RF24_DATARATE
    #define MY_RF24_DATARATE RF24_250KBPS
    #endif
    
    
    #endif
    
    
    
    #include "config.h"
    
    
    #include <SPI.h>
    #include <UIPEthernet.h>
    #include <MySensors.h>
    
    void setup() {
    }
    void loop() {
    }
    

    Output:

    0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    0;255;3;0;9;TSM:INIT:TSP OK
    0;255;3;0;9;TSM:INIT:GW MODE
    0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
    0;255;3;0;9;MCO:REG:NOT NEEDED
    IP: 192.168.0.66
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
    0;255;3;0;9;Eth: connect
    0;255;3;0;9;Eth: 0;0;3;0;2;
    0;255;3;0;9;Eth: 0;0;3;0;2;Get Version
    0;255;3;0;9;Eth: 0;0;3;0;18;PING
    0;255;3;0;9;TSF:MSG:READ,1-1-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    0;255;3;0;9;TSF:MSG:BC
    0;255;3;0;9;TSF:MSG:FPAR REQ,ID=1
    0;255;3;0;9;TSF:PNG:SEND,TO=0
    0;255;3;0;9;TSF:CKU:OK
    0;255;3;0;9;TSF:MSG:GWL OK
    
    

    ketch uses 26,232 bytes (85%) of program storage space. Maximum is 30,720 bytes.
    Global variables use 1,286 bytes (62%) of dynamic memory, leaving 762 bytes for local variables. Maximum is 2,048 bytes.


  • Mod

    sorry, but that is not the complete code.



  • @hiddenuser That is too bad.
    I must say I find your sketch somewhat confusing. What is the purpose of the ifndef confif_h followed by a config_h?

    your config.h seems to just define the configuration. Why not just do an #include "config.h"
    The large amount of ifdefs make the sketch a little bit hard to read.
    If you are a beginner (we all have been) and make a sketch primarily for yourself, many of those ifdes are not really necessary and at least you are not losing track.
    Anyway, not trying to criticize you, but error tracking also for yrself would be easier.
    Also... you are using a soft SPI. For the ENC28J60 that is not really necessary. (not necessary for w5100 either with a little adaptation).
    So... I am afraid that at this point I cant say anything sensible about yr sketch, but I can say the ENC28J60 works, even with a shared SPI bus.
    Have you tried a working W5100 sketch with simply changing Ethernet.h into UIPEthernet.h?



  • @Ed1500 Thanks for you feedback. I have switched over to using W5100. However I have noticed that for some reason I am missing a data which is sent over nrf24. The gaps in the data are random and I can't seem to figure out why this is happening. BTW I am using domoticz on a pi to get the data. Initially I was using mysensor over usb to get the data and used to work fine. In order to get the update OTA I am trying to switch to ethernet Gateway and does not seem to work 😞

    //#define MY_DEBUG
    
    #define MY_RADIO_NRF24
    #define MY_GATEWAY_W5100
    
    #define MY_SOFTSPI
    #define MY_SOFT_SPI_SCK_PIN 14
    #define MY_SOFT_SPI_MISO_PIN 16
    #define MY_SOFT_SPI_MOSI_PIN 15
    
    #define MY_RF24_CE_PIN 5
    #define MY_RF24_CS_PIN 6
    
    
    #define MY_IP_ADDRESS 192,168,0,66   // If this is disabled, DHCP is used to retrieve address
    #define MY_PORT 5003
    
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
    
    
    #define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
    #define MY_DEFAULT_RX_LED_PIN  7  // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN  7  // Transmit led pin
    
    
    #include <Ethernet.h>
    #include <MySensors.h>
    
    
    void setup(){
      delay(10000);
    }
    
    void loop(){
    }
    ``

  • Mod

    Are you running domoticz on a raspberry? If so, you could skip the arduino and connect the radio on the rpi directly.



  • @hiddenuser Your code seems OK apart from the fact it doesnt seem to do anything. Randomly missing data when using an nrf24 could be due to data just not arriving over the link although with shot distance that is rare. Nevertheless you could disconnect the w5100 and check a serial.print for a while to see if data is still missing.
    I dont have much experience using the soft spi, only using hardware SPI. You may want to consider Gohan' s suggestion



  • @Ed1500 @gohan Thanks. I am trying to create an ehternet gateway so I can do OTAs.



  • @hiddenuser I understand. Not sure if that is possible through a W5100/arduino, I guess it is but might not be easy 🙂


  • Mod

    Ethernet gateway works either way, it is only a matter of personal taste. Personally I did go for the raspberry gw because I have less stuff around and I save an arduino board.



  • Hi everyone,
    Is it possible to build an ethernet gateway with a RFM69 radio module?
    Because I tried this a while ago and that didn't work because of a software problem in the library's. Is that already solved or not?
    Thanks!


  • Mod

    With development branch it should be solved, but I still have to try



  • @Jonathan-Caes I did, with an RFM69HW an arduino pro mini and a funduino Ethernetmodule. Used the setup from computourist in github https://github.com/computourist/RFM69-MQTT-client



  • hello @Ed1500, i have the same problem as @Mitja-Blazinsek. i have a w5100 module (funduino), arduino pro mini and nrf24 radio. i try to use your tip, including a delay in setup() but it doen't work yet, the gateway isn't reached using ping. is necesary another change? did you move the setup() function in the program? thanks!!



  • @Toni-Ramos Sorry to hear that. Are you using Soft SPI or hardware SPI for both?
    Can you get any connection if you just use it as webserver without the NRF24?



  • @Ed1500 i'm using softSPI as the example. I can see ping works correctly if i comment "#define MY_RADIO_NRF24". If not, the gateway shows the following messages continuosly:

    0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    0;255;3;0;9;!TSM:INIT:TSP FAIL
    0;255;3;0;9;TSM:FAIL:CNT=1
    0;255;3;0;9;TSM:FAIL:PDT
    0;255;3;0;9;TSM:FAIL:RE-INIT



  • @Ed1500 after tests with different versions of the library i discovered a bad welded pin in the nrf24. It seens to work fine now,i'll conect a node to the gateway and check all



  • @Toni-Ramos Glad you got it solved. apologies I had not seen yr earlier reply yet, but thats no longer relevant.
    Always good to check the joints 🙂


  • Mod

    What is the best way to make the gateway wait for ip address (it's set to use dhcp) when power goes down? I noticed that the gateway starts faster than the router and doesn't get the ip address so I had to push the reset button to get it to work.


  • Mod

    @gohan maybe add a wait call in before()? Not sure if before() is run early enough, but it might be worth a try.

    Maybe the library can be modified to try for a longer time before giving up.


  • Mod

    Maybe I could make a check if there is no client connected I could reset the board, but I was wondering if there is any was to know if the system has a valid ip



  • hi after long time i finaly get new w5100 module now the test sketch from arduino ide for ethernet like web server are working fine bur still don't work as a gateway in domoticz or mycontroler. i just open example gatewayw5100 from my sensor libary and upload to mega bard bit status in my controler is always down af course i set the gateway in my controler :Enabled
    Enabled
    Type
    Ethernet
    Network type
    MySensors
    Connection details
    Host:192.168.178.66, Port:5003
    Status
    Down
    Status since
    7 minutes ago
    Status message
    ERROR: connect timed out


  • Mod

    Can you ping that ip? There are some faulty w5100 modules around and I did repair one by adding a couple of 100 ohms resistors on the ethernet pins.


  • Mod

    @Mitja-Blazinsek is your local network using the same subnet (192.168.178)? What is the ip and netmask of your controller?



  • my network is using 192.168.0 but i try to change the MY_IP_ADDRESS to 192.168.0.66 but still no responese. i dont know what is the ip of mycontroler it works only when ia write localhost:8443 i of domoticz was 127.0.0.1



  • ok ip of mycontroler is 192.168.0.100



  • is it maybe problem because i'm using mega board an i wired 50 51 52 pins but if i wired 11 12 13 like on the diagram here it not working the shield if i try dhcp address printer for test


  • Mod

    You probably have faulty network shield



  • Sorry, but can't find any information about my problem about the gateaway.
    For connecting a lot of binary switches etc. i took a mega and loaded a gateaway sketch from Mihai . Normally it runs very good, when i change the status flags from ON/Off to 1/0 (Don't know why?)
    But now i had the idea, to disable the radio, because I don't need it for this mega.
    Now the relais-switches do no longer work as before. They only work from time to time and rather randomly.
    I want to switch and contol the switches with iOBroker, but without the radion connected and activated, it doesn't run.
    Any idea?


  • Mod

    @jopebe did you remove the define for the radio from your sketch?
    What does the debug output say?



  • Thank You for Your quick respons!
    Yes, i made two slashes before the define-line of the radio .
    I have no debug-output because I didnt engage myself in debugging until now. I will try it this evening. During the day Im engaged in other things.



  • Here thr output of the seriel monitor:
    0;255;3;0;9;MCO:BGN:INIT GW,CP=R-NGA--,VER=2.1.1
    IP: 192.168.178.134
    0;255;3;0;9;Eth: connect
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:REG:NOT NEEDED
    0;255;3;0;9;MCO:BGN:INIT OK,TSP=NA
    0;255;3;0;9;Eth: 0;101;1;0;2;1
    0;255;3;0;9;Eth: 0;101;1;0;2;0
    0;255;3;0;9;Eth: 0;101;1;0;2;1
    0;255;3;0;9;Eth: 0;101;1;0;2;0
    0;255;3;0;9;Eth: 0;101;1;0;2;1
    0;255;3;0;9;Eth: 0;101;1;0;2;0
    0;255;3;0;9;Eth: 0;101;1;0;2;1
    0;255;3;0;9;Eth: 0;101;1;0;2;0
    0;255;3;0;9;Eth: 0;101;1;0;2;0
    0;255;3;0;9;Eth: 0;101;1;0;2;1
    When I push the button in IoBroker-Vis, it takes often a lot of time until the LED is on; sometimes I have to push the button twice or more times; sometimes nothing happens at all.
    When I define and connect the radio with the same sketch, it runs as expected.


  • Hero Member

    @jopebe are the relays and switches locally attached to the GW? Please post your sketch



  • @scalz A very late reply, but someone else might be helped with it.
    Hardware SPI is working.
    The onnly thing is that on W5100 shield it will work without any problem but with most 5100 modules you need a small modification fixing w5100 problems



  • @fifo Most W5100 modules have a 5-3.3V regulator so if you connect the Vcc to 3V3 the chip just doesnt get enough juice



  • I dont know, how to send my sketch as a file. Copy and past doesnt run.
    I use an ethernet-shield and as I mentioned, when I connect and switch on the radio, everything is alrigth.



  • Thank You to all, who tried to help.
    I think, I found the solution:
    There was this line in the sketch: "const unsigned long tUpdate=60000; //update interval"
    When I changed the time to 6000, it runs as when as the radio was connected.
    So it was probably missing some kind of "interrupt", which usually comes from the radio , when it listens to the nodes or so?



  • hi everyone,

    has the pin setup changed? it looks like it has from the sketch. I used a0, a1 and a2 for the radio.


  • Mod

    @Newzwaver Which sketch do you mean? The build page is still using a0, a1, a2 for W5100.



  • Ok, I screwed up and downloaded the latest arduino software 1.8.3 and can't get my libraries to work correctly. I am trying to upgrade my sensors to 2.1.1 and rebuild my gateway using a new nano I put together. I am using the5100 connection with the radio wired to a0..... It the 1.8.3 not to be used for the overseas board?



  • I have just built a W5100 based Ethernet gateway using a pro mini, NRF24LR and I enabled Soft Signinig - using the latest mysensors github development version 2.2.0-beta I am getting Low on memory messages when I compile and load this - if I disable Signing it does not complain. I have noticed several random crashes with signing enabled however i have secure nodes so need singing support. Is there something I am doing wrong or is the latest dev image causing this to occur. I have Debugging all disabled and burning to a stock 5V 16Mhz device.

    Sketch uses 25476 bytes (82%) of program storage space. Maximum is 30720 bytes.
    Global variables use 1648 bytes (80%) of dynamic memory, leaving 400 bytes for local variables. Maximum is 2048 bytes.
    Low memory available, stability problems may occur.


  • Mod

    @itbeyond you'll need to find a way to save flash and ram, or use a microcontroller that has more flash and ram.


  • Mod

    @itbeyond you could use a Mega 2560 or use a raspberry pi as gateway (if you already have one)


Log in to reply
 

Suggested Topics

  • 3
  • 110
  • 584
  • 5
  • 2
  • 109

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts