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. Development
  3. ESP8266 WiFi gateway port for MySensors

ESP8266 WiFi gateway port for MySensors

Scheduled Pinned Locked Moved Development
328 Posts 56 Posters 309.9k Views 39 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.
  • Mark SwiftM Mark Swift

    I tried to get the ESP8266 gateway working for 2 weeks but kept getting st=fail at various times. Switching to a serial gateway fixed it straight away? Is this a known issue? Is it perhaps related to having the ESP8266 and the nRF24L01's so close together? BTW, I tied both the normal gateway and the MQTT gateway without much success. The who time I thought it was a radio issue :-/

    This was all running on a NodeMCU v1.0.

    Mark

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

    @Mark-Swift said:

    kept getting st=fail at various times

    Now I read over your post again I get the impression that it sometimes works, and sometimes you get st=fail. Is this correct?

    http://yveaux.blogspot.nl

    1 Reply Last reply
    0
    • Mark SwiftM Offline
      Mark SwiftM Offline
      Mark Swift
      wrote on last edited by Mark Swift
      #272

      Example - I'm sat here right now with one of my nodes and the gateway connected to my Macbook via USB.

      When using the serial gateway I get =ok after each item no problem; in fact I can't make it fail.

      When using the ESP8266 MQTT gateway I get:

      Starting repeater (RNNRA-, 2.0.0-beta)
      Radio init successful.
      send: 3-3-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,st=ok:R+M+L+T+D+Rpt
      send: 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
      send: 3-3-0-0 s=1,c=0,t=1,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=2,c=0,t=1,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=3,c=0,t=16,pt=0,l=0,sg=0,st=fail:
      send: 3-3-0-0 s=4,c=0,t=15,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=10,c=0,t=1,pt=0,l=0,sg=0,st=fail:
      send: 3-3-0-0 s=11,c=0,t=1,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=12,c=0,t=23,pt=0,l=0,sg=0,st=fail:
      send: 3-3-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
      send: 3-3-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=fail:2.0.0-beta
      send: 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      Init complete, id=3, parent=0, distance=1
      Moisture Sensor: 0
      send: 3-3-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
      Rain Sensor: 0
      send: 3-3-0-0 s=2,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
      LUX: 54612
      send: 3-3-0-0 s=3,c=1,t=37,pt=3,l=2,sg=0,st=ok:54612
      Distance: 0 cm
      send: 3-3-0-0 s=4,c=1,t=13,pt=2,l=2,sg=0,st=ok:0
      No rain or moisture detected, landroid is not waiting: Status(0)
      Landroid is free to go and is now waiting on the schedule: Status(0)
      Landroid is home charging!
      Sending landroidHome (1) status to gateway: send: 3-3-0-0 s=10,c=1,t=16,pt=1,l=1,sg=0,st=ok:1
      Sending landroidWaitingTriggered (0) status to gateway: send: 3-3-0-0 s=11,c=1,t=16,pt=1,l=1,sg=0,st=ok:0
      Sending timeElapsed (0) status to gateway: send: 3-3-0-0 s=12,c=1,t=48,pt=2,l=2,sg=0,st=fail:0

      Using the serial gateway on a nano (Not connected to anything, just the nano and nRF24L01) I get:

      Starting repeater (RNNRA-, 2.0.0-beta)
      Radio init successful.
      send: 3-3-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,st=ok:R+M+L+T+D+Rpt
      send: 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
      send: 3-3-0-0 s=1,c=0,t=1,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=2,c=0,t=1,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=3,c=0,t=16,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=4,c=0,t=15,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=10,c=0,t=1,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=11,c=0,t=1,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=12,c=0,t=23,pt=0,l=0,sg=0,st=ok:
      send: 3-3-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
      send: 3-3-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=ok:2.0.0-beta
      send: 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      Init complete, id=3, parent=0, distance=1
      Moisture Sensor: 0
      send: 3-3-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
      Rain Sensor: 0
      send: 3-3-0-0 s=2,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
      LUX: 54612
      send: 3-3-0-0 s=3,c=1,t=37,pt=3,l=2,sg=0,st=ok:54612
      Distance: 69 cm
      send: 3-3-0-0 s=4,c=1,t=13,pt=2,l=2,sg=0,st=ok:69
      No rain or moisture detected, landroid is not waiting: Status(0)
      Landroid is free to go and is now waiting on the schedule: Status(0)
      Landroid is out cutting the grass!
      Sending landroidHome (0) status to gateway: send: 3-3-0-0 s=10,c=1,t=16,pt=1,l=1,sg=0,st=ok:0
      Sending landroidWaitingTriggered (0) status to gateway: send: 3-3-0-0 s=11,c=1,t=16,pt=1,l=1,sg=0,st=ok:0
      Sending timeElapsed (0) status to gateway: send: 3-3-0-0 s=12,c=1,t=48,pt=2,l=2,sg=0,st=ok:0

      YveauxY 1 Reply Last reply
      0
      • Mark SwiftM Mark Swift

        Example - I'm sat here right now with one of my nodes and the gateway connected to my Macbook via USB.

        When using the serial gateway I get =ok after each item no problem; in fact I can't make it fail.

        When using the ESP8266 MQTT gateway I get:

        Starting repeater (RNNRA-, 2.0.0-beta)
        Radio init successful.
        send: 3-3-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,st=ok:R+M+L+T+D+Rpt
        send: 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
        send: 3-3-0-0 s=1,c=0,t=1,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=2,c=0,t=1,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=3,c=0,t=16,pt=0,l=0,sg=0,st=fail:
        send: 3-3-0-0 s=4,c=0,t=15,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=10,c=0,t=1,pt=0,l=0,sg=0,st=fail:
        send: 3-3-0-0 s=11,c=0,t=1,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=12,c=0,t=23,pt=0,l=0,sg=0,st=fail:
        send: 3-3-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
        send: 3-3-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=fail:2.0.0-beta
        send: 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
        Init complete, id=3, parent=0, distance=1
        Moisture Sensor: 0
        send: 3-3-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
        Rain Sensor: 0
        send: 3-3-0-0 s=2,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
        LUX: 54612
        send: 3-3-0-0 s=3,c=1,t=37,pt=3,l=2,sg=0,st=ok:54612
        Distance: 0 cm
        send: 3-3-0-0 s=4,c=1,t=13,pt=2,l=2,sg=0,st=ok:0
        No rain or moisture detected, landroid is not waiting: Status(0)
        Landroid is free to go and is now waiting on the schedule: Status(0)
        Landroid is home charging!
        Sending landroidHome (1) status to gateway: send: 3-3-0-0 s=10,c=1,t=16,pt=1,l=1,sg=0,st=ok:1
        Sending landroidWaitingTriggered (0) status to gateway: send: 3-3-0-0 s=11,c=1,t=16,pt=1,l=1,sg=0,st=ok:0
        Sending timeElapsed (0) status to gateway: send: 3-3-0-0 s=12,c=1,t=48,pt=2,l=2,sg=0,st=fail:0

        Using the serial gateway on a nano (Not connected to anything, just the nano and nRF24L01) I get:

        Starting repeater (RNNRA-, 2.0.0-beta)
        Radio init successful.
        send: 3-3-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,st=ok:R+M+L+T+D+Rpt
        send: 3-3-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
        send: 3-3-0-0 s=1,c=0,t=1,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=2,c=0,t=1,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=3,c=0,t=16,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=4,c=0,t=15,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=10,c=0,t=1,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=11,c=0,t=1,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=12,c=0,t=23,pt=0,l=0,sg=0,st=ok:
        send: 3-3-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
        send: 3-3-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=ok:2.0.0-beta
        send: 3-3-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
        Init complete, id=3, parent=0, distance=1
        Moisture Sensor: 0
        send: 3-3-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
        Rain Sensor: 0
        send: 3-3-0-0 s=2,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
        LUX: 54612
        send: 3-3-0-0 s=3,c=1,t=37,pt=3,l=2,sg=0,st=ok:54612
        Distance: 69 cm
        send: 3-3-0-0 s=4,c=1,t=13,pt=2,l=2,sg=0,st=ok:69
        No rain or moisture detected, landroid is not waiting: Status(0)
        Landroid is free to go and is now waiting on the schedule: Status(0)
        Landroid is out cutting the grass!
        Sending landroidHome (0) status to gateway: send: 3-3-0-0 s=10,c=1,t=16,pt=1,l=1,sg=0,st=ok:0
        Sending landroidWaitingTriggered (0) status to gateway: send: 3-3-0-0 s=11,c=1,t=16,pt=1,l=1,sg=0,st=ok:0
        Sending timeElapsed (0) status to gateway: send: 3-3-0-0 s=12,c=1,t=48,pt=2,l=2,sg=0,st=ok:0

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

        @Mark-Swift It does work sometimes, so that rules out a lot of possible problems!
        How do you power the NodeMCU & rest of the hardware?
        Both NodeMCU & nRF are very sensitive to low/noisy supplies.

        http://yveaux.blogspot.nl

        Mark SwiftM 1 Reply Last reply
        0
        • YveauxY Yveaux

          @Mark-Swift It does work sometimes, so that rules out a lot of possible problems!
          How do you power the NodeMCU & rest of the hardware?
          Both NodeMCU & nRF are very sensitive to low/noisy supplies.

          Mark SwiftM Offline
          Mark SwiftM Offline
          Mark Swift
          wrote on last edited by
          #274

          @Yveaux I power the NodeMCU from either my Macbook Retina, or from a decent USB wall plug, tbh, it seems to make little difference which I use. I presume everyone else is powering them via the USB also?

          I've also tried a spare NodeMCU and a bunch of radios. In fact, I've been trying to get this working for 3 weeks, it's literally going to cause a divorce soon :-/

          YveauxY 1 Reply Last reply
          0
          • Mark SwiftM Mark Swift

            @Yveaux I power the NodeMCU from either my Macbook Retina, or from a decent USB wall plug, tbh, it seems to make little difference which I use. I presume everyone else is powering them via the USB also?

            I've also tried a spare NodeMCU and a bunch of radios. In fact, I've been trying to get this working for 3 weeks, it's literally going to cause a divorce soon :-/

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

            @Mark-Swift The log mentions Moisture Sensor, Rain Sensor, LUX, Distance.
            Are these real sensor connected (and yes, how) or virtual?

            http://yveaux.blogspot.nl

            1 Reply Last reply
            0
            • Mark SwiftM Offline
              Mark SwiftM Offline
              Mark Swift
              wrote on last edited by
              #276

              @Yveaux real sensors connected to my robot mower garage node...

              1 Reply Last reply
              0
              • Mark SwiftM Offline
                Mark SwiftM Offline
                Mark Swift
                wrote on last edited by
                #277

                @Yveaux Node code is here for reference:

                http://pastebin.com/mxkLq1Rp

                YveauxY 1 Reply Last reply
                0
                • Mark SwiftM Mark Swift

                  @Yveaux Node code is here for reference:

                  http://pastebin.com/mxkLq1Rp

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

                  @Mark-Swift To be frank: I don't know.
                  I'm quite sure it has nothing to do with the ESP port, or software in general.
                  You could try different orientation of the nRF, or move it closer to the sensor(s).

                  Are you using an amplified nRF24 btw?

                  http://yveaux.blogspot.nl

                  1 Reply Last reply
                  0
                  • Mark SwiftM Offline
                    Mark SwiftM Offline
                    Mark Swift
                    wrote on last edited by
                    #279

                    @Yveaux That's a shame, I'd really like to solve this. I've tried the radios orientated different ways but it makes little difference. Not using a PA+LNB, I was but gave up on it as I thought it was the issue (Now realise it wasn't).

                    Strange that I only see these issues with the ESP, and as soon as I switch to a Nano running the serial gateway they're gone.

                    YveauxY 1 Reply Last reply
                    0
                    • Mark SwiftM Mark Swift

                      @Yveaux That's a shame, I'd really like to solve this. I've tried the radios orientated different ways but it makes little difference. Not using a PA+LNB, I was but gave up on it as I thought it was the issue (Now realise it wasn't).

                      Strange that I only see these issues with the ESP, and as soon as I switch to a Nano running the serial gateway they're gone.

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

                      @Mark-Swift I always use my sniffer in this case to see what's going on on air, but I don't know if your marriage will survive another sniffer build :innocent:

                      http://yveaux.blogspot.nl

                      1 Reply Last reply
                      0
                      • Mark SwiftM Offline
                        Mark SwiftM Offline
                        Mark Swift
                        wrote on last edited by Mark Swift
                        #281

                        @Yveaux I doubt it will, seems I'm destined to build a serial gateway, crap, I've invested so much time in this and tried everything!

                        1 Reply Last reply
                        0
                        • Mark SwiftM Offline
                          Mark SwiftM Offline
                          Mark Swift
                          wrote on last edited by Mark Swift
                          #282

                          @Yveaux How about this, for a laugh I just tried rolling the ESP8266 gateway back to v1.5 (master).

                          Guess what? It works every time with no fails (communicating with my 2.0.0 beta node). So the issue lies with the latest development version somewhere, any ideas?
                          ~~
                          Insane, I just took the gateway down the other end of the house and not one fail, wow! So okay, what was changed in version 2.0.0?

                          UPDATE: After more investigation, the reason it was working is because v1.5 only has a straight forward gateway version, and until now I've been using the MQTT client. It seems the gateway versions work fine, but the MQTT client version create the fails!

                          UPDATE 2: Okay, I can reproduce the fails with the gateway too, let me try and explain. When the gateway is not connected to anything (for example Domoticz) I get OK all of the time, no fails whatsoever. If I connect to Domoticz, I start to get fails against certain child sensors (it's always the same!). I presume it's sketch related, or even the amount of node updates I'm sending? As I believe the fails are the same I'm seeing with the MQTT client.

                          UPDATE 3: Nearly 3 weeks in and I've just figured out what has been causing me all this pain. I've always commented out the default 9600 serial baud define on the ESP8266 sketches. It seems this combined with the 200ms TCP delay has been causing me my issues when connecting to my Windows 7 machine. S$%&*!

                          YveauxY 1 Reply Last reply
                          0
                          • Mark SwiftM Mark Swift

                            @Yveaux How about this, for a laugh I just tried rolling the ESP8266 gateway back to v1.5 (master).

                            Guess what? It works every time with no fails (communicating with my 2.0.0 beta node). So the issue lies with the latest development version somewhere, any ideas?
                            ~~
                            Insane, I just took the gateway down the other end of the house and not one fail, wow! So okay, what was changed in version 2.0.0?

                            UPDATE: After more investigation, the reason it was working is because v1.5 only has a straight forward gateway version, and until now I've been using the MQTT client. It seems the gateway versions work fine, but the MQTT client version create the fails!

                            UPDATE 2: Okay, I can reproduce the fails with the gateway too, let me try and explain. When the gateway is not connected to anything (for example Domoticz) I get OK all of the time, no fails whatsoever. If I connect to Domoticz, I start to get fails against certain child sensors (it's always the same!). I presume it's sketch related, or even the amount of node updates I'm sending? As I believe the fails are the same I'm seeing with the MQTT client.

                            UPDATE 3: Nearly 3 weeks in and I've just figured out what has been causing me all this pain. I've always commented out the default 9600 serial baud define on the ESP8266 sketches. It seems this combined with the 200ms TCP delay has been causing me my issues when connecting to my Windows 7 machine. S$%&*!

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

                            @Mark-Swift Well, look on it from the bright side: your marriage is saved now :bowtie:
                            There have been more reports from issues with connections to external servers (e.g. MQTT, Domotiocz) that take too long.
                            Maybe we should pull @hek in as he wrote the MQTT client for ESP.

                            http://yveaux.blogspot.nl

                            1 Reply Last reply
                            0
                            • hekH Offline
                              hekH Offline
                              hek
                              Admin
                              wrote on last edited by
                              #284

                              What adjustments do you propose to the MQTT sketch/driver?

                              YveauxY 1 Reply Last reply
                              0
                              • hekH hek

                                What adjustments do you propose to the MQTT sketch/driver?

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

                                @hek I'm not familiar with the exact implementation at the moment. Just hoped you would have a hunch where these issues might arise from or how we can prevent them...

                                http://yveaux.blogspot.nl

                                1 Reply Last reply
                                0
                                • hekH Offline
                                  hekH Offline
                                  hek
                                  Admin
                                  wrote on last edited by
                                  #286

                                  Nope, I don't get why baud rate would affect radio/tcp traffic. Maybe @Mark-Swift could shed some light on it.

                                  1 Reply Last reply
                                  0
                                  • R Offline
                                    R Offline
                                    robosensor
                                    wrote on last edited by
                                    #287

                                    ESP8266 gateway is quite unusable in setups where TCP ACKs can be delayed. This is because thread is blocked until TCP ACK received in ESP wifi code. So all wireless messages will be rejected if NRF24 receives more than 3 messages during this 200ms delay: http://forum.mysensors.org/topic/1870/esp8266-wifi-gateway-port-for-mysensors/235

                                    1 Reply Last reply
                                    0
                                    • hekH Offline
                                      hekH Offline
                                      hek
                                      Admin
                                      wrote on last edited by
                                      #288

                                      Hmm.. blocking code.. crap.

                                      1 Reply Last reply
                                      0
                                      • R Offline
                                        R Offline
                                        robosensor
                                        wrote on last edited by
                                        #289

                                        The problem is slightly wider than it seems. Wireless messages should be fetched from internal NRF24 FIFO and stored into memory as soon as possible (using interrupts?). But lack of RAM makes the problem difficult to be solved.

                                        The same thing happens not only with ESP8266 gateway and TCP ACKs, but also with all blocking calls during sensor reading (for example for old blocking call to read DS18B20 data with 750ms delay), with improper use of delay() instead of gw.wait() and so on.

                                        YveauxY 1 Reply Last reply
                                        0
                                        • R robosensor

                                          The problem is slightly wider than it seems. Wireless messages should be fetched from internal NRF24 FIFO and stored into memory as soon as possible (using interrupts?). But lack of RAM makes the problem difficult to be solved.

                                          The same thing happens not only with ESP8266 gateway and TCP ACKs, but also with all blocking calls during sensor reading (for example for old blocking call to read DS18B20 data with 750ms delay), with improper use of delay() instead of gw.wait() and so on.

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

                                          @robosensor said:

                                          lack of RAM

                                          Not really an issue on ESP I would say.

                                          @hek IMHO it really is time to investigate the impact on the library to support message queueing (fetched & sent from interrupt).
                                          Starting with @tekka rewrite of the nRF driver in 2.0 beta, as it supports SPI transactions.
                                          Probably we can add support incrementally to lower the impact on the library.

                                          http://yveaux.blogspot.nl

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


                                          14

                                          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