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. Announcements
  3. 💬 Building an Ethernet Gateway

💬 Building an Ethernet Gateway

Scheduled Pinned Locked Moved Announcements
133 Posts 42 Posters 36.0k Views 35 Watching
  • 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.
  • gohanG Offline
    gohanG Offline
    gohan
    Mod
    wrote on last edited by
    #42

    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sensibelchen
      wrote on last edited by Sensibelchen
      #43

      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.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Ed1500
        wrote on last edited by
        #44

        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/

        1 Reply Last reply
        0
        • Mitja BlazinsekM Offline
          Mitja BlazinsekM Offline
          Mitja Blazinsek
          wrote on last edited by
          #45

          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 ;)

          1 Reply Last reply
          0
          • gohanG Offline
            gohanG Offline
            gohan
            Mod
            wrote on last edited by
            #46

            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

            1 Reply Last reply
            0
            • Mitja BlazinsekM Offline
              Mitja BlazinsekM Offline
              Mitja Blazinsek
              wrote on last edited by
              #47

              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)

              E 1 Reply Last reply
              0
              • Mitja BlazinsekM Mitja Blazinsek

                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)

                E Offline
                E Offline
                Ed1500
                wrote on last edited by
                #48

                @Mitja-Blazinsek https://i0.wp.com/www.jdohnalek.com/wp-content/uploads/2014/10/W5100-Red-Mini-01-e1414707788425.jpg

                1 Reply Last reply
                0
                • numanxN Offline
                  numanxN Offline
                  numanx
                  wrote on last edited by
                  #49

                  Could you send us a picture with the module?

                  1 Reply Last reply
                  0
                  • Mitja BlazinsekM Offline
                    Mitja BlazinsekM Offline
                    Mitja Blazinsek
                    wrote on last edited by
                    #50

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

                    E 1 Reply Last reply
                    0
                    • Mitja BlazinsekM Mitja Blazinsek

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

                      E Offline
                      E Offline
                      Ed1500
                      wrote on last edited by
                      #51

                      @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?

                      1 Reply Last reply
                      0
                      • numanxN Offline
                        numanxN Offline
                        numanx
                        wrote on last edited by
                        #52

                        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>```
                        1 Reply Last reply
                        0
                        • Mitja BlazinsekM Offline
                          Mitja BlazinsekM Offline
                          Mitja Blazinsek
                          wrote on last edited by
                          #53

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

                          E 3 Replies Last reply
                          0
                          • Mitja BlazinsekM Mitja Blazinsek

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

                            E Offline
                            E Offline
                            Ed1500
                            wrote on last edited by
                            #54

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

                            1 Reply Last reply
                            0
                            • gohanG Offline
                              gohanG Offline
                              gohan
                              Mod
                              wrote on last edited by
                              #55

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

                              1 Reply Last reply
                              0
                              • Mitja BlazinsekM Mitja Blazinsek

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

                                E Offline
                                E Offline
                                Ed1500
                                wrote on last edited by
                                #56

                                @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

                                1 Reply Last reply
                                0
                                • Mitja BlazinsekM Mitja Blazinsek

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

                                  E Offline
                                  E Offline
                                  Ed1500
                                  wrote on last edited by
                                  #57

                                  @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

                                  1 Reply Last reply
                                  0
                                  • H Offline
                                    H Offline
                                    hiddenuser
                                    wrote on last edited by
                                    #58
                                    This post is deleted!
                                    1 Reply Last reply
                                    0
                                    • H Offline
                                      H Offline
                                      hiddenuser
                                      wrote on last edited by
                                      #59

                                      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.

                                      E 1 Reply Last reply
                                      0
                                      • gohanG Offline
                                        gohanG Offline
                                        gohan
                                        Mod
                                        wrote on last edited by
                                        #60

                                        sorry, but that is not the complete code.

                                        1 Reply Last reply
                                        0
                                        • H hiddenuser

                                          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.

                                          E Offline
                                          E Offline
                                          Ed1500
                                          wrote on last edited by Ed1500
                                          #61

                                          @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?

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          23

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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