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. Arduino Mega + W5500 + BME280 = Connection refused all the time

Arduino Mega + W5500 + BME280 = Connection refused all the time

Scheduled Pinned Locked Moved Troubleshooting
22 Posts 4 Posters 108 Views 3 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.
  • TRS-80T TRS-80

    Well, I am only part way into my first cup of coffee, so maybe my brain just isn't working yet. But so far I am failing to understand what all this shouldAsk and justAsked business is all about? Why not just do a simple check on millis() and if enough time has passed, enter the measurement function? Something like:

    void loop() {
      if ( millis() > previousBME280Millis + BME280measurementInterval ) {
        // take measurements, etc...
      }
    

    The way it is presented in OP is, IMO, much more complicated than necessary. Or maybe someone smarter can point out what I am missing?

    Your BME280measurementInterval = 60000 (60 seconds), so if you:

    @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

    get measurements every 10 seconds

    ... then it makes me suspect that something is wrong with the main loop there. And if the loop is hogging the CPU, maybe the Ethernet interface can't get a word in edgewise?

    But I couldn't seem to figure out the loop, with everything you've got going on there. Maybe I try again in a little while when I have had some coffee and am all the way "on." :D

    N Offline
    N Offline
    NeoX
    wrote on last edited by
    #5

    @TRS-80 I've pasted old version, i;ve modified BME280measurementInterval = 10000
    But it doesnt matter, to be honest.
    Now ive completely commented out loop() body, and it's still same problem :(

    Maybe it's some kind of problem with library version?
    I found that only compatibile Ethernet library for MySensors is 2.0.0. so i cant downgrade it, but maybe MySensors has some bug here?

    TRS-80T 1 Reply Last reply
    0
    • N NeoX

      @TRS-80 I've pasted old version, i;ve modified BME280measurementInterval = 10000
      But it doesnt matter, to be honest.
      Now ive completely commented out loop() body, and it's still same problem :(

      Maybe it's some kind of problem with library version?
      I found that only compatibile Ethernet library for MySensors is 2.0.0. so i cant downgrade it, but maybe MySensors has some bug here?

      TRS-80T Offline
      TRS-80T Offline
      TRS-80
      wrote on last edited by TRS-80
      #6

      @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

      Maybe it's some kind of problem with library version?
      I found that only compatibile Ethernet library for MySensors is 2.0.0. so i cant downgrade it, but maybe MySensors has some bug here?

      I just put together Ethernet based gateway (with MQTT, but that shouldn't matter) based on W5500 and Arduino Nano not too long ago. I used platform.io, which (I just double checked my local files) apparently pulled in same v2.0.0 of Ethernet library. And mine works absolutely flawless for a few weeks now.

      How about we back up a little and go step by step. Try just the plain (MySensors) Ethernet gateway code and see how that works?

      N 1 Reply Last reply
      0
      • TRS-80T TRS-80

        @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

        Maybe it's some kind of problem with library version?
        I found that only compatibile Ethernet library for MySensors is 2.0.0. so i cant downgrade it, but maybe MySensors has some bug here?

        I just put together Ethernet based gateway (with MQTT, but that shouldn't matter) based on W5500 and Arduino Nano not too long ago. I used platform.io, which (I just double checked my local files) apparently pulled in same v2.0.0 of Ethernet library. And mine works absolutely flawless for a few weeks now.

        How about we back up a little and go step by step. Try just the plain (MySensors) Ethernet gateway code and see how that works?

        N Offline
        N Offline
        NeoX
        wrote on last edited by
        #7

        @TRS-80 Well what can i say, it works. I can ping, just after a reboot i can connect to 5003 via telnet.
        When i close connection (by ctrl+] and close), then i cannot connect to it again :(

        1 Reply Last reply
        0
        • TRS-80T Offline
          TRS-80T Offline
          TRS-80
          wrote on last edited by TRS-80
          #8

          @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

          Well what can i say, it works. I can ping, just after a reboot i can connect to 5003 via telnet.
          When i close connection (by ctrl+] and close), then i cannot connect to it again

          Was this with the plain (MySensors) Ethernet code? Or your code from OP with the loop commented out?

          N 1 Reply Last reply
          0
          • TRS-80T TRS-80

            @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

            Well what can i say, it works. I can ping, just after a reboot i can connect to 5003 via telnet.
            When i close connection (by ctrl+] and close), then i cannot connect to it again

            Was this with the plain (MySensors) Ethernet code? Or your code from OP with the loop commented out?

            N Offline
            N Offline
            NeoX
            wrote on last edited by
            #9

            @TRS-80 No, with plain code unfortunately.

            1 Reply Last reply
            0
            • TRS-80T Offline
              TRS-80T Offline
              TRS-80
              wrote on last edited by
              #10

              OK, so it appears the Ethernet part works? I am still not sure what this is about though?:

              @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

              When i close connection (by ctrl+] and close), then i cannot connect to it again

              Other than this (potential?) problem, if Ethernet works, brings me back to what I speculated above about the main loop running too much...

              N 1 Reply Last reply
              0
              • TRS-80T TRS-80

                OK, so it appears the Ethernet part works? I am still not sure what this is about though?:

                @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

                When i close connection (by ctrl+] and close), then i cannot connect to it again

                Other than this (potential?) problem, if Ethernet works, brings me back to what I speculated above about the main loop running too much...

                N Offline
                N Offline
                NeoX
                wrote on last edited by
                #11

                @TRS-80 But it's not possible, or some bug in Mysensors.
                Because in plain example the loop in sketch is empty.
                Do you use lib version 2.3.3 of MySensors lib?

                YveauxY 1 Reply Last reply
                0
                • TRS-80T Offline
                  TRS-80T Offline
                  TRS-80
                  wrote on last edited by
                  #12

                  I just checked my local files for my gateway, and looks like MySensors is v2.3.2.

                  I am inclined to think the problem is somewhere else, before assuming a bug in MySensors, however it is possible (although unlikely IMO) that potentially could be the problem. One easy way to find out, anyway... ;)

                  N 1 Reply Last reply
                  0
                  • N NeoX

                    @TRS-80 But it's not possible, or some bug in Mysensors.
                    Because in plain example the loop in sketch is empty.
                    Do you use lib version 2.3.3 of MySensors lib?

                    YveauxY Offline
                    YveauxY Offline
                    Yveaux
                    Mod
                    wrote on last edited by
                    #13

                    @NeoX mysensors has an empty main loop() by default. The stack runs in the 'background', after each loop iteration, so your loop() should not block!

                    http://yveaux.blogspot.nl

                    1 Reply Last reply
                    0
                    • TRS-80T TRS-80

                      I just checked my local files for my gateway, and looks like MySensors is v2.3.2.

                      I am inclined to think the problem is somewhere else, before assuming a bug in MySensors, however it is possible (although unlikely IMO) that potentially could be the problem. One easy way to find out, anyway... ;)

                      N Offline
                      N Offline
                      NeoX
                      wrote on last edited by
                      #14

                      @TRS-80 Do you have any idea whats more i can check? :)
                      Because i have no idea what could be wrong when i use plain sketch

                      1 Reply Last reply
                      0
                      • TRS-80T Offline
                        TRS-80T Offline
                        TRS-80
                        wrote on last edited by TRS-80
                        #15

                        Didn't you say plain sketch was working? Other than only being able to connect only once via telnet?

                        To be honest I am not familiar with using telnet for testing this sort of thing, so I installed it here on my Debian development machine to try and replicate what you are doing, but so far no luck. Probably because first time with tool and simply haven't figured it out yet. But this is what I get so far (probably doing something wrong):

                        ┌─[ 2020-06-26 09:33 trs80@host:~ ]
                        └─▶ $ telnet 192.168.x.y 1883
                        
                        Trying 192.168.x.y...
                        telnet: Unable to connect to remote host: Connection refused
                        
                        ┌─[ 2020-06-26 09:33 trs80@host:~ ]
                        └─▶ $ telnet 192.168.x.y:1883
                        
                        telnet: could not resolve 192.168.x.y:1883/telnet: Name or service not known
                        

                        Note I am running an MQTT gateway, therefore I set port 1883 in my sketch, furthermore I am running in MY_GATEWAY_MQTT_CLIENT mode (I think I read server mode is default in plain (non-MQTT) Ethernet sketch? not sure). So that could be part of my problem here, too.

                        N 1 Reply Last reply
                        0
                        • TRS-80T TRS-80

                          Didn't you say plain sketch was working? Other than only being able to connect only once via telnet?

                          To be honest I am not familiar with using telnet for testing this sort of thing, so I installed it here on my Debian development machine to try and replicate what you are doing, but so far no luck. Probably because first time with tool and simply haven't figured it out yet. But this is what I get so far (probably doing something wrong):

                          ┌─[ 2020-06-26 09:33 trs80@host:~ ]
                          └─▶ $ telnet 192.168.x.y 1883
                          
                          Trying 192.168.x.y...
                          telnet: Unable to connect to remote host: Connection refused
                          
                          ┌─[ 2020-06-26 09:33 trs80@host:~ ]
                          └─▶ $ telnet 192.168.x.y:1883
                          
                          telnet: could not resolve 192.168.x.y:1883/telnet: Name or service not known
                          

                          Note I am running an MQTT gateway, therefore I set port 1883 in my sketch, furthermore I am running in MY_GATEWAY_MQTT_CLIENT mode (I think I read server mode is default in plain (non-MQTT) Ethernet sketch? not sure). So that could be part of my problem here, too.

                          N Offline
                          N Offline
                          NeoX
                          wrote on last edited by
                          #16

                          @TRS-80 The plain sketch is working in Server mode, so it is possible to connect to port 5003.
                          Since i don't know any tools to test MySensors ethernet, i've used telnet :)

                          My plain Ethernet example sketch is working, but only for one time after reset, which is weird. Just like some resources hasn't been released or W5500 didnt realised that connection was closed after ctrl+] ?
                          No idea...
                          I will take a look at MQTT, since it is working in Client mode...

                          YveauxY 1 Reply Last reply
                          0
                          • N NeoX

                            @TRS-80 The plain sketch is working in Server mode, so it is possible to connect to port 5003.
                            Since i don't know any tools to test MySensors ethernet, i've used telnet :)

                            My plain Ethernet example sketch is working, but only for one time after reset, which is weird. Just like some resources hasn't been released or W5500 didnt realised that connection was closed after ctrl+] ?
                            No idea...
                            I will take a look at MQTT, since it is working in Client mode...

                            YveauxY Offline
                            YveauxY Offline
                            Yveaux
                            Mod
                            wrote on last edited by
                            #17

                            @NeoX what bme library are you using?

                            http://yveaux.blogspot.nl

                            N 1 Reply Last reply
                            0
                            • YveauxY Yveaux

                              @NeoX what bme library are you using?

                              N Offline
                              N Offline
                              NeoX
                              wrote on last edited by
                              #18

                              @Yveaux Adafruit BME280 in version 2.0.0, as it said in Arduino IDE

                              YveauxY 1 Reply Last reply
                              0
                              • N Offline
                                N Offline
                                NeoX
                                wrote on last edited by
                                #19

                                Well, i tested MQTT and it worked just fine for a few minutes. Any problems.
                                I belive that there is some kind of bug in TCP server mode or maybe W5500 driver?
                                I can also say that when i close telnet connection via ctrl+] i can see that my PC is still waiting for close ack ( connection state in netstat is WAIT_FIN_2).

                                Don't know, but i switched to MQTT and it works fine, and i think MQTT client is more important for me.

                                1 Reply Last reply
                                0
                                • N NeoX

                                  @Yveaux Adafruit BME280 in version 2.0.0, as it said in Arduino IDE

                                  YveauxY Offline
                                  YveauxY Offline
                                  Yveaux
                                  Mod
                                  wrote on last edited by
                                  #20

                                  @NeoX Maybe not relevant, but that doesn't appear to be the Adafruit BME280, as you're including <bme280_mod-1022.h>. This headerfile appears to be part of this library: https://github.com/embeddedadventures/BME280 which is very different from the Adafruit implementation.
                                  If that library blocks too long in one of its calls it might cause troubles.

                                  http://yveaux.blogspot.nl

                                  N 1 Reply Last reply
                                  0
                                  • YveauxY Yveaux

                                    @NeoX Maybe not relevant, but that doesn't appear to be the Adafruit BME280, as you're including <bme280_mod-1022.h>. This headerfile appears to be part of this library: https://github.com/embeddedadventures/BME280 which is very different from the Adafruit implementation.
                                    If that library blocks too long in one of its calls it might cause troubles.

                                    N Offline
                                    N Offline
                                    NeoX
                                    wrote on last edited by
                                    #21

                                    @Yveaux Hmm, interesting, since only one library i do find in Arduino IDE library manager as installed was this Adafruit.
                                    But's should be fine

                                    TRS-80T 1 Reply Last reply
                                    0
                                    • N NeoX

                                      @Yveaux Hmm, interesting, since only one library i do find in Arduino IDE library manager as installed was this Adafruit.
                                      But's should be fine

                                      TRS-80T Offline
                                      TRS-80T Offline
                                      TRS-80
                                      wrote on last edited by TRS-80
                                      #22

                                      @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

                                      only one library i do find in Arduino IDE library manager

                                      I started using PlatformIO recently, and I much prefer their way of searching libraries. When you do pio run it will even take the library.h file name that you are missing and give you a link to look it up in their library search. You can also search there for library name, or file names. Very handy!

                                      Anyway, a bit offtopic for this thread, so recently I started another one where we can discuss PlatformIO (if you are interested).

                                      @NeoX said in Arduino Mega + W5500 + BME280 = Connection refused all the time:

                                      i switched to MQTT and it works fine, and i think MQTT client is more important for me

                                      I rebuilt my gateway recently (few weeks ago) and this time I decided to go MQTT way. I actually have MQTT broker running on separate machine from my HA controller. Sort of distributed architecture, if you will. So far I am really liking this approach. Soon I will add some additional monitoring and metrics based directly off the MQTT, these will also be totally independent of the controller.

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


                                      21

                                      Online

                                      11.7k

                                      Users

                                      11.2k

                                      Topics

                                      113.1k

                                      Posts


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