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. Troubleshooting
  3. Building an Ethernet Gateway on an Arduino Mega

Building an Ethernet Gateway on an Arduino Mega

Scheduled Pinned Locked Moved Troubleshooting
31 Posts 16 Posters 29.4k Views 10 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.
  • sj44kS Offline
    sj44kS Offline
    sj44k
    wrote on last edited by sj44k
    #3

    @Heinz
    I guess I did not make myself perfectly clear as I allready had this information and my W5100 shield is using these pins from the pin 6 pin header in the middle of the board (check the red circle)
    edited Mega2560_R3_Label-small-v2 (2).png

    So I am wondering if these pins are addressed as the same pin numbers on the MEGA as on the UNO (thus making the sketches compatible).
    I am doubting this as I had some issues with this during building a temp sensor designed for an Uno (or Mini) on the same Mega (check also the first link in my initial post).

    The Radio in the Ethernet Gateway is addressed via SoftSPI, and is referred to use :
    A2 MISO
    A1 MOSI
    A0 SCK
    6 CSN
    5 CE

    My guess us that to address the Analogue and digital pins (A0, A1, A2, 5 and 6 ) on an Arduino Mega I need to change some code / pin referals. to get this working. Now I still get :
    0;0;3;0;9;check wires

    My Radio is currently connected to all these pins (A0, A1, A2, 5 and 6 ) located all on the W5100 shield, so I did not change anything from the UNO configuration (which is working) but it's not working on the Mega :(

    After finding the Pin alias sheet for the UNO Clearing up the pins 16,15 and 14 referring to A0,A1,and A2 if found another sheet and according to this sheet I changed the following in my RF24_config.h ( As I hoped that according to this sheet A0,A1 and A2 labeled on the MEGA are corresponding with Digital Pins 56, 55 and 54

    // change these pins to your liking
          // Default for Uno
          //const uint8_t SOFT_SPI_MISO_PIN = 16; 
          //const uint8_t SOFT_SPI_MOSI_PIN = 15; 
          //const uint8_t SOFT_SPI_SCK_PIN = 14;  
          //const uint8_t SPI_MODE = 0;
    	  //MEGA CONFIG ?
          const uint8_t SOFT_SPI_MISO_PIN = 56; 
          const uint8_t SOFT_SPI_MOSI_PIN = 55; 
          const uint8_t SOFT_SPI_SCK_PIN = 54;  
          const uint8_t SPI_MODE = 0;
    

    But still no luck ..

    1 Reply Last reply
    0
    • sj44kS Offline
      sj44kS Offline
      sj44k
      wrote on last edited by
      #4

      I am still in the process of fixing this, is there anyone who can explain me why this is not working ?
      According to all the info I could find it that all I/O pins on the UNO are available on the MEGA, only MEGA has more pins available.

      So I still have no idea why this sketch is not working on my Mega but is on my UNO with the exact same EtherShield (as I own only one)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MSchmidke
        wrote on last edited by
        #5

        sj44k,

        now I got stuck at the exact same location like you. Arduino Mega, Ethernet Shield, Softspi -> "Check wires". Like you I connected the radio to A0/A1/A2 passthru pins on the Ethernet Shield but I am wondering if A0/A1/A2 are the right pins on Mega (since for hardware spi we also have to use other pins on mega).

        I would be very glad to hear from you if you have any new clues.

        So will I if I do, but at the moment I have absolutely no idea.

        Marcus.

        HeinzH 1 Reply Last reply
        0
        • M Offline
          M Offline
          MSchmidke
          wrote on last edited by
          #6

          Heee,

          use 14/15/16 on the mega instead of A0/A1/A2. I did not do too much tests, but I get "gateway startup complete".

          1 Reply Last reply
          0
          • M MSchmidke

            sj44k,

            now I got stuck at the exact same location like you. Arduino Mega, Ethernet Shield, Softspi -> "Check wires". Like you I connected the radio to A0/A1/A2 passthru pins on the Ethernet Shield but I am wondering if A0/A1/A2 are the right pins on Mega (since for hardware spi we also have to use other pins on mega).

            I would be very glad to hear from you if you have any new clues.

            So will I if I do, but at the moment I have absolutely no idea.

            Marcus.

            HeinzH Offline
            HeinzH Offline
            Heinz
            Hero Member
            wrote on last edited by
            #7

            Why do you want to connect A0, A1, A2 to the radio?
            The picture above clearly says:
            PIN 50 = MISO
            PIN 51 = MOSI
            PIN 52 = SCK
            I connected to radio to those pins and everything worked well without any modifications!.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MSchmidke
              wrote on last edited by
              #8

              Because the Ethernet shield breaks SPIs characteristics to be a bus. Once Ethernet shield is plugged onto Arduino, all other devices on SPI bus won't work anymore.

              This is documented at http://www.mysensors.org/build/ethernet_gateway#wiring-things-up and was true for mine: without ethernet shield, radio on 50/51/52 works perfect. With ethernet shield, radio on 50/51/52 won't work. The alternative SoftSpi is documented on the mentioned page, but A0/A1/A2 as written there will only work for classic Arduinos. The question was what to use instead of A0/A1/A2 on Mega, and I think 14/15/16 are the right ones.

              Marcus,

              1 Reply Last reply
              0
              • sj44kS Offline
                sj44kS Offline
                sj44k
                wrote on last edited by sj44k
                #9

                @MSchmidke I am going to try this asap and post my findings .. but sir .. could you please share with me (and the rest of the world ) how did you find out about these pins ? I love solutions but I crave to understand WHY :)

                But still if this works you deserve my everlasting respect for finding it and sharing !

                @Heinz
                Are you using an Arduino MEGA ? I guess you are not.

                [one hour later]
                Ok figures that you choose 14/15/16 on the mega :) the RF24config.h states :

                `      const uint8_t SOFT_SPI_MISO_PIN = 16; 
                      const uint8_t SOFT_SPI_MOSI_PIN = 15; 
                      const uint8_t SOFT_SPI_SCK_PIN = 14;  
                

                But having that said I still am not getting a reply on a ping when I ping the ethershield .. so we are close .. but not there yet :)

                I do get the

                0;0;3;0;14;Gateway startup complete.
                

                So that's further than I've been so far ..

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MSchmidke
                  wrote on last edited by
                  #10

                  Oh it would have been really simple to find this config file ... but I didn't.

                  I investigated the digital read of analog port. On classic Arduino, you can digitalRead(A0), for example. And I wondered what is behind that "A0" - and tadah it's 14 on classic Arduino. So I supposed there will be simply a 14 in SoftSPI code - et voilà it worked.

                  What kind of ethernet related code do you have in your loop? I don't think you'll get a ping if you do not poll the Ethernet. But I'm not sure.

                  Marcus.

                  1 Reply Last reply
                  0
                  • sj44kS Offline
                    sj44kS Offline
                    sj44k
                    wrote on last edited by
                    #11

                    I use the ethernet gateway example of this site, and I am absolutely 100% sure it does reply on ping as when I use the same code on my UNO with the same shield, I do get an reply.
                    When switching the shield to the MEGA, and placing the pins on 14 15 and 16 nothing happens.

                    Do you get a ping ?

                    BulldogLowellB 1 Reply Last reply
                    0
                    • sj44kS sj44k

                      I use the ethernet gateway example of this site, and I am absolutely 100% sure it does reply on ping as when I use the same code on my UNO with the same shield, I do get an reply.
                      When switching the shield to the MEGA, and placing the pins on 14 15 and 16 nothing happens.

                      Do you get a ping ?

                      BulldogLowellB Offline
                      BulldogLowellB Offline
                      BulldogLowell
                      Contest Winner
                      wrote on last edited by
                      #12

                      @sj44k

                      https://www.youtube.com/watch?v=jr0JaXfKj68

                      1 Reply Last reply
                      0
                      • sj44kS Offline
                        sj44kS Offline
                        sj44k
                        wrote on last edited by
                        #13

                        @BulldogLowell

                        :)Hunt for the red october classic :)

                        1 Reply Last reply
                        0
                        • barduinoB Offline
                          barduinoB Offline
                          barduino
                          wrote on last edited by
                          #14

                          I have a similar issue with Adafruit CC3000 shield and a Mega.
                          After much fidling around I finally got it to work.

                          The Adafruit shiled is the same size of an Uno but when connected to a Mega it doesn't get the SCK, MOSI and MISO from the 13,11,12 pins, it gets them from the central connector ICSP as showed on the picture on this thread.

                          So first step was to connect the wireless module to the ICSP.

                          The second issue is the CSN and CE pins, these can't be connected to 10 and 9 since they are used by the shield. I've used 35 and 34.

                          Adjust your code like this:

                          #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
                          #define INCLUSION_MODE_PIN 32 // Digital pin used for inclusion mode button
                          #define CE_PIN 35
                          #define CS_PIN 34
                          MyGateway gw(CE_PIN, CS_PIN, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, 6, 5, 4);

                          Even with this, some times I still get a check wires message, others just a bunch of errors about the version.

                          This erratic behaviour led me to think about noise on the wireless receiver, so in goes a 10uF.

                          Its stable now.

                          On a side note I also changed the CE and CS pin assignments on the sensors...

                          #define DIGITAL_INPUT_SENSOR 4 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
                          #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
                          #define CHILD_ID 1 // Id of the sensor child

                          #define CE_PIN 9
                          #define CS_PIN 53

                          MySensor gw(CE_PIN,CS_PIN);

                          // Initialize motion message
                          MyMessage msg(CHILD_ID, V_TRIPPED);

                          Cheers

                          F 1 Reply Last reply
                          1
                          • sj44kS Offline
                            sj44kS Offline
                            sj44k
                            wrote on last edited by
                            #15

                            @barduino
                            Can you help me out here, I do not get your remark :
                            So first step was to connect the wireless module to the ICSP

                            As my Ethershield is using this, how will this work together with the radio and the ethershield connected to the same pins ?
                            My guess I am not getting exactly what you mean.

                            barduinoB 1 Reply Last reply
                            0
                            • sj44kS sj44k

                              @barduino
                              Can you help me out here, I do not get your remark :
                              So first step was to connect the wireless module to the ICSP

                              As my Ethershield is using this, how will this work together with the radio and the ethershield connected to the same pins ?
                              My guess I am not getting exactly what you mean.

                              barduinoB Offline
                              barduinoB Offline
                              barduino
                              wrote on last edited by barduino
                              #16

                              @sj44k

                              I dont know much about this so I aks for clarification if some of my notes are incorrect.

                              Not sure if you have the shield from adafruit. In my shield (WiFi and memory card) it is designed to be on top of an uno R3 (getting the sck mosi miso) from pins 13,12,11 or if on top of a mega (my case) it gets the sck, mosi and miso from those central pins (ICSP i think) and you have to solder some jumpers on the shield it self.

                              1428958756089-edited-mega2560_r3_label-small-v2-2.png

                              I took this image from your post

                              As I understand it sck, mosi and miso are intended to be shared. The problem comes with the SS/CS pin (slave select) which each device should have one.

                              In adafruit cc3000 shield this is pin 10 and pin 4 for the sd card. At least pin 10 conflicts with MySensors lib so I had to change this and connect the rf module to other pins (the icsp pins for sck mosi miso and cd pin to 53.

                              When I did this I stoped having check wires message. However when I included the code to connect to the wifi on the cc3000 it couldnt still connect.

                              I ended up disconnecting the mysensors rf module and tryied it with just the cc3000 code and it was behaving erratically, sometimes it connected others not... Is it damaged, is it power, in the end I just gave up, removed the cc3000 shield and connected the mysensors gw to a computer and used nodejs to call my REST service.

                              I'll get back to this some time, it should work....

                              The problem of buying a shield is that you cant change the pins to which it is connected to...

                              1 Reply Last reply
                              0
                              • sj44kS sj44k

                                I am trying to utilize all of my available Arduinos as best as I can, and having all sketches being developed on this site for the UNO my Arduino Mega seems to fit best in it's role as an Ethernet Gateway.

                                By this I am able to use my available UNO to do some more testing and playing around with the MySensor sketches without the need to modify my sketches like I did to do in the past

                                BUT, having that said this also exactly gives away my challenge :
                                Getting the Ethernet Gateway Sketch working on my Arduino Mega with a W5100 Ethernet Shield.
                                Issue is the pinout of a Mega's SPI interface is different than the UNO.

                                So the sketch is working easily on my UNO, but changing the shield and uploading the same sketch to my MEGA results in a non working Ethernet Gateway (debug modes states : check wires)
                                (I did uncomment the #define SOFTSPI line in the RF24_Config.h by the way)

                                Does anyone know which file / library I need to edit to change these pins ? I am using the W5100 shield not the module so I would prefer the shield installed as a is, and not use any jumper cables.

                                E Offline
                                E Offline
                                ewgor
                                wrote on last edited by ewgor
                                #17

                                @sj44k hi, may i ask if you need a NRF24L01 radio module in order to make this Ethernet Gateway work? I'm asking because i understood that for a Serial Gateway you need this module, other way you cannot test it!
                                My second question is if you made it i mean if you can read some sensors using the Ethernet W5100 and the Openhab server?
                                Thanks.
                                Forget the 1st question, i got it...
                                Could you please tell me if you made it with Arduino Mega and the Ethernet shield? which are the right pins that needs to be modified in the RF24_Config.h ?

                                1 Reply Last reply
                                0
                                • E Offline
                                  E Offline
                                  ewgor
                                  wrote on last edited by
                                  #18

                                  everybody in holiday here? nodoby answered on the serial gateway so im asking again here about the ethernet gateway if somebody can tell me/us which are the right pins that needs to be modified to start the ethernet gataway and to test it with openhab?

                                  1 Reply Last reply
                                  0
                                  • hekH Online
                                    hekH Online
                                    hek
                                    Admin
                                    wrote on last edited by
                                    #19

                                    @ewgor said:

                                    NRF24L01

                                    The NRF or HopeRF RF69 module i central in the MySensors infrastructure as it is centralised around wireless sensors/actuators. Experimental code exist (https://github.com/mysensors/Arduino/tree/gateway-refactoring) which lets you attach sensors to the gateway (serial or ethernet) directly. But this is not documented on the main site yet so you should be comfortable to read up code yourself.

                                    How to connect ethernet module (and modify configuration) is described on the main site. I haven't personally used a Mega as gateway myself. But I successfully used it as a sensor for the Touch Scene Controller.

                                    1 Reply Last reply
                                    0
                                    • bruno araripeB Offline
                                      bruno araripeB Offline
                                      bruno araripe
                                      wrote on last edited by
                                      #20

                                      hy guys,
                                      i have a mega bord, and wiznet ethernet shield, and i want to use this whith ethernet getway. i try many configs, but nothing work. please help me.

                                      B 1 Reply Last reply
                                      0
                                      • bruno araripeB bruno araripe

                                        hy guys,
                                        i have a mega bord, and wiznet ethernet shield, and i want to use this whith ethernet getway. i try many configs, but nothing work. please help me.

                                        B Offline
                                        B Offline
                                        brakc
                                        wrote on last edited by
                                        #21

                                        @bruno-araripe said:

                                        hy guys,
                                        i have a mega bord, and wiznet ethernet shield, and i want to use this whith ethernet getway. i try many configs, but nothing work. please help me.

                                        Hy,

                                        I have a same project and same problem.

                                        please :sweat:

                                        ;-)

                                        1 Reply Last reply
                                        0
                                        • O Offline
                                          O Offline
                                          otto001
                                          wrote on last edited by
                                          #22

                                          Did someone get the GW with mega and W5100 working????

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


                                          10

                                          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