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. Getting the Ethernet/ESP8266 gateway to act as client instead of server

Getting the Ethernet/ESP8266 gateway to act as client instead of server

Scheduled Pinned Locked Moved Development
14 Posts 5 Posters 6.3k Views 8 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.
  • rakeshpaiR Offline
    rakeshpaiR Offline
    rakeshpai
    wrote on last edited by
    #1

    Currently, it looks like the Ethernet/ESP8266 gateways open a socket and act as a server to accept incoming network connections. However, I'd like it to act as a client, and connect to a public host/port. Is this possible?

    This is my use-case: I need to be able to control devices at home with a phone/web-based app, from anywhere in the world. To make this possible, I'll need to host the controller software on a public server on the Internet. If this controller has to access the gateway inside my home network, I'll have to do some jiggery-pokery at my router, and maybe configure a VPN. I could avoid the trouble if the gateway would act as a client and connect to the controller instead.

    Even better if this was done using standard/expected open ports, rather than ports that might be blocked in different networks. So if the gateway could initiate a HTTP-based WebSocket connection to a controller based on the controller's public address, it would be perfect.

    It appears that this is how the gateway connects to an MQTT broker, but I couldn't find any way to do this for the socket API. Is this possible?

    1 Reply Last reply
    0
    • mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino perhaps?

      1 Reply Last reply
      0
      • rakeshpaiR Offline
        rakeshpaiR Offline
        rakeshpai
        wrote on last edited by
        #3

        Thanks, @mfalkvidd. That seems to only work for the MQTT gateway, though. I was wondering if there's something similar for the socket API, using just the Ethernet/ESP8266 gateways (without MQTT).

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

          Enabling client mode is documented in the sketch here:

          https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewayESP8266/GatewayESP8266.ino#L104

          stofakillerS 1 Reply Last reply
          0
          • rakeshpaiR Offline
            rakeshpaiR Offline
            rakeshpai
            wrote on last edited by
            #5

            Client mode is what I was looking for, thanks, @hek.

            Is it possible to define the controller IP address dynamically at runtime, rather than having it compiled into the sketch? That way, it could be possible to have some sort of API/UI to configure the gateway after deployment, without having to reflash the Arduino.

            (I'm working off the development branch, if that's any help.)

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

              No, but you can set an url instead (and control it via your/some dns): https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyGatewayTransportEthernet.cpp#L160

              1 Reply Last reply
              0
              • rakeshpaiR Offline
                rakeshpaiR Offline
                rakeshpai
                wrote on last edited by
                #7

                Cool. Doesn't quite do the job, but I'll figure my way around it. Thanks again, @hek.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Adam McCartney
                  wrote on last edited by
                  #8

                  This isn't what you're looking for, but whats stopping you hosting the controller in your own home and using a VPN or internet facing controller behind security or using a VPN on your phone?

                  i currently run Domoticz and have a Domain pointed at a Raspberry pi in my house. access outside the internal network requires a username and password, but recently i setup OpenVPN so that when connect to the VPN on my phone, i can use the Domoticz app or access the Domoticz web interface without having to setup Authentication.

                  rakeshpaiR 1 Reply Last reply
                  0
                  • A Adam McCartney

                    This isn't what you're looking for, but whats stopping you hosting the controller in your own home and using a VPN or internet facing controller behind security or using a VPN on your phone?

                    i currently run Domoticz and have a Domain pointed at a Raspberry pi in my house. access outside the internal network requires a username and password, but recently i setup OpenVPN so that when connect to the VPN on my phone, i can use the Domoticz app or access the Domoticz web interface without having to setup Authentication.

                    rakeshpaiR Offline
                    rakeshpaiR Offline
                    rakeshpai
                    wrote on last edited by
                    #9

                    @Adam-McCartney That certainly works. I'm looking to avoid the overhead of the configuration and setup required at home, and want to keep it simple for everyone to use ("just go to <url>"). There's also the interesting possibility of the hosted controller being used by more than one household, but that's something for the future.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Adam McCartney
                      wrote on last edited by
                      #10

                      Personally, i dont like the idea of my controller being on someone elses Box. I have all i need on the RPi. Plus, if my internet connection goes down, i can still turn my lights off!

                      Domoticz allows you to join up controllers so you can still have access to other controllers in other houses. Its worth having a look.

                      1 Reply Last reply
                      0
                      • hekH hek

                        Enabling client mode is documented in the sketch here:

                        https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewayESP8266/GatewayESP8266.ino#L104

                        stofakillerS Offline
                        stofakillerS Offline
                        stofakiller
                        wrote on last edited by stofakiller
                        #11

                        @hek

                        Hi, In the 3 post is there a link https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewayESP8266/GatewayESP8266.ino#L104... The link is dead and i tried to find it, but with no luck... Can you post the new URL?

                        Regards,
                        Jan

                        mfalkviddM 1 Reply Last reply
                        0
                        • stofakillerS stofakiller

                          @hek

                          Hi, In the 3 post is there a link https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewayESP8266/GatewayESP8266.ino#L104... The link is dead and i tried to find it, but with no luck... Can you post the new URL?

                          Regards,
                          Jan

                          mfalkviddM Offline
                          mfalkviddM Offline
                          mfalkvidd
                          Mod
                          wrote on last edited by mfalkvidd
                          #12

                          @stofakiller Examples->MySensors->GatewayESP8266MQTTClient in the Arduino IDE or https://github.com/mysensors/MySensors/tree/development/examples/GatewayESP8266MQTTClient is what you are looking for I think (at least for MySensors 2)

                          Or GatewayESP8266 / https://github.com/mysensors/MySensors/tree/development/examples/GatewayESP8266 for the one without mqtt

                          stofakillerS 1 Reply Last reply
                          0
                          • mfalkviddM mfalkvidd

                            @stofakiller Examples->MySensors->GatewayESP8266MQTTClient in the Arduino IDE or https://github.com/mysensors/MySensors/tree/development/examples/GatewayESP8266MQTTClient is what you are looking for I think (at least for MySensors 2)

                            Or GatewayESP8266 / https://github.com/mysensors/MySensors/tree/development/examples/GatewayESP8266 for the one without mqtt

                            stofakillerS Offline
                            stofakillerS Offline
                            stofakiller
                            wrote on last edited by
                            #13

                            @mfalkvidd

                            Hi,

                            I have look at both of them... But my interest lies in the esp8266 as a client/node without NRF24L01, to eg switch a relay on/off... And it has to go through my Vera controller... I have been playing with Apples Homekit, Raspberry Pi and Vera, and now i can control my vera switches and dimmers with just my voice

                            Regards,
                            Jan

                            mfalkviddM 1 Reply Last reply
                            0
                            • stofakillerS stofakiller

                              @mfalkvidd

                              Hi,

                              I have look at both of them... But my interest lies in the esp8266 as a client/node without NRF24L01, to eg switch a relay on/off... And it has to go through my Vera controller... I have been playing with Apples Homekit, Raspberry Pi and Vera, and now i can control my vera switches and dimmers with just my voice

                              Regards,
                              Jan

                              mfalkviddM Offline
                              mfalkviddM Offline
                              mfalkvidd
                              Mod
                              wrote on last edited by
                              #14

                              @stofakiller I think that is supported but I don't know how to do it. Hopefully someone else can chip in.

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


                              8

                              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