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.
  • scalzS Offline
    scalzS Offline
    scalz
    Hardware Contributor
    wrote on last edited by scalz
    #246

    hi.

    Has someone already thought about using websockets with wifiGW ??? before I start to reinvent the wheel!
    I have already made some tests with websockets but it was not with mysensors. it was not big tests too but I was able to have an html5 client with js. it was a simple test like blink led+serial monitor, receive/sending serial things. very simple!
    I did this because I would like to have sort of display on my phone even if there are no controller. and I don't want to use spiffs and webserver. I prefer to have the stuff on client side and esp8266 acting as a simple websocket server. More lightweight I think, to handle something more complex if needed...For the client, then it could be html+boostrap or something more hybrid. I am not expert at this but I should be able to make some poc..but I don't want to waste my time if it already exists! I have lot of other projects so I don't know how long it could take, and maybe someone is faster on this, so it depends..but it's a feature I would like to have in future and I will make it when needed :)

    So what do you think ??? dumb idea?

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

      Yeah, thought about it the other day and found this.

      https://github.com/Links2004/arduinoWebSockets

      Would have been fun to create something cloud.mysensors.org where people could share sensor data (and of course make it embeddable on the forum). Creating a websocket gateway-variant would probably be my first choice if I decide going down that path.

      It also seems to support wss which is kind of nice.

      1 Reply Last reply
      0
      • scalzS Offline
        scalzS Offline
        scalz
        Hardware Contributor
        wrote on last edited by scalz
        #248

        @hek : cool so you think it could be useful too.
        yes I use this lib, nice features and simple to use.
        so, even if someone has already done something, maybe I will dig a little for fun, time to time...

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

          I haven't done anything yet. The old head is just constantly spinning ideas you know ;)

          So please go ahead and see if you can create a MyGatewayTransportWebsocket.cpp

          1 Reply Last reply
          0
          • ErrKE Offline
            ErrKE Offline
            ErrK
            Plugin Developer
            wrote on last edited by
            #250

            @scalz @hek you can look at socket.io if you are thinking of using websockets.

            hekH scalzS 2 Replies Last reply
            0
            • ErrKE ErrK

              @scalz @hek you can look at socket.io if you are thinking of using websockets.

              hekH Offline
              hekH Offline
              hek
              Admin
              wrote on last edited by
              #251

              @ErrK said:

              socket.io

              Yep, use it on my dayjob. Allows downgrade to polling which (I guess) the Arduino library doesn't support. Might be better to use raw websocket on the server side in this case.

              ErrKE 1 Reply Last reply
              0
              • ErrKE ErrK

                @scalz @hek you can look at socket.io if you are thinking of using websockets.

                scalzS Offline
                scalzS Offline
                scalz
                Hardware Contributor
                wrote on last edited by scalz
                #252

                @ErrK : yes I saw it too. but here a discussion about socket.io with esp websockets https://github.com/Links2004/arduinoWebSockets/issues/42
                very interesting ;)

                YveauxY 1 Reply Last reply
                0
                • scalzS scalz

                  @ErrK : yes I saw it too. but here a discussion about socket.io with esp websockets https://github.com/Links2004/arduinoWebSockets/issues/42
                  very interesting ;)

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

                  @scalz @hek a local server on the ESP serving gateway status overview (connected clients, routing table, sensors presented by clients, data etc) would be a very nice addition to any gateway IMHO.
                  The ESP has enough power/flash to implement this.

                  http://yveaux.blogspot.nl

                  1 Reply Last reply
                  0
                  • hekH hek

                    @ErrK said:

                    socket.io

                    Yep, use it on my dayjob. Allows downgrade to polling which (I guess) the Arduino library doesn't support. Might be better to use raw websocket on the server side in this case.

                    ErrKE Offline
                    ErrKE Offline
                    ErrK
                    Plugin Developer
                    wrote on last edited by
                    #254

                    @hek: Yes, it has fallbacks to use other protocols. I think there is a setting if you don't want to use all the default protocols.
                    @scalz: interesting discussion. It looks like the best way shuld be to only use the websockets :)

                    1 Reply Last reply
                    0
                    • scalzS Offline
                      scalzS Offline
                      scalz
                      Hardware Contributor
                      wrote on last edited by scalz
                      #255

                      @Yveaux: exactly what I was thinking ;) for monitoring :) and it could be fun to be able to show something on the phone without a controller (for instance when I visit my not geek friends, it looks more simple if something on the phone instead of setting up a controller).
                      I started to look at dev branch last night but was too tired.... I visualize where are the changes to do, but maybe not all, I will ask you if I have some problems ;) A cool thing in websocket lib is broadcasting client is already implemented in it.

                      1 Reply Last reply
                      0
                      • A RA Offline
                        A RA Offline
                        A R
                        wrote on last edited by
                        #256

                        Hi,
                        I am working on a sensor system. Sensors feed to ESP8266 which feed to NodeMCU ESP8266. I saw in the intro to GatewayESP8266.ino on GitHub your code which says:

                        • The EthernetGateway sends data received from sensors to the WiFi link.
                        • The gateway also accepts input on ethernet interface, which is then sent out to the radio network.

                        Does that mean Ethernet Gateway receiving data from WiFi?
                        Thanking you in anticipation.
                        Riaz Ahmed

                        YveauxY 1 Reply Last reply
                        0
                        • A RA A R

                          Hi,
                          I am working on a sensor system. Sensors feed to ESP8266 which feed to NodeMCU ESP8266. I saw in the intro to GatewayESP8266.ino on GitHub your code which says:

                          • The EthernetGateway sends data received from sensors to the WiFi link.
                          • The gateway also accepts input on ethernet interface, which is then sent out to the radio network.

                          Does that mean Ethernet Gateway receiving data from WiFi?
                          Thanking you in anticipation.
                          Riaz Ahmed

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

                          @A-R said:

                          Does that mean Ethernet Gateway receiving data from WiFi?

                          As the topic indicates this is a WiFi gateway for mysensors. That means that it converts sensor data from the MySensors network to WiFi and vice versa.
                          When sending data to a sensor, a controller will send data over WiFi to the gateway, which then sends the data on to a MySensors sensor (using nRF24L01+ or RFM69HW radio).
                          Seen from the controller, it will communicate to the WiFi gateway exactly the same way as it would when connecting to a wired ethernet gateway.

                          http://yveaux.blogspot.nl

                          A RA 1 Reply Last reply
                          0
                          • YveauxY Yveaux

                            @A-R said:

                            Does that mean Ethernet Gateway receiving data from WiFi?

                            As the topic indicates this is a WiFi gateway for mysensors. That means that it converts sensor data from the MySensors network to WiFi and vice versa.
                            When sending data to a sensor, a controller will send data over WiFi to the gateway, which then sends the data on to a MySensors sensor (using nRF24L01+ or RFM69HW radio).
                            Seen from the controller, it will communicate to the WiFi gateway exactly the same way as it would when connecting to a wired ethernet gateway.

                            A RA Offline
                            A RA Offline
                            A R
                            wrote on last edited by
                            #258

                            @Yveaux Thanks for the reply. Let me elaborate please. My sensor sends data to ESP8266 which sends it to NodeMCU ESP8266. From there I want the NodeMCU ESP8266 to send data through a wired Ethernet. (from there i want it be sent to a router).

                            So my question is can the GatewayESP8266.ino be used to send data from NodeMCU to Ethernet?

                            YveauxY 1 Reply Last reply
                            0
                            • A RA A R

                              @Yveaux Thanks for the reply. Let me elaborate please. My sensor sends data to ESP8266 which sends it to NodeMCU ESP8266. From there I want the NodeMCU ESP8266 to send data through a wired Ethernet. (from there i want it be sent to a router).

                              So my question is can the GatewayESP8266.ino be used to send data from NodeMCU to Ethernet?

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

                              @A-R said:

                              can the GatewayESP8266.ino be used to send data from NodeMCU to Ethernet?

                              How do you plan to connect the wired ethernet to the NodeMCU board?
                              You could probably connect a W5100 module through SPI, but why bother?

                              http://yveaux.blogspot.nl

                              A RA 1 Reply Last reply
                              0
                              • YveauxY Yveaux

                                @A-R said:

                                can the GatewayESP8266.ino be used to send data from NodeMCU to Ethernet?

                                How do you plan to connect the wired ethernet to the NodeMCU board?
                                You could probably connect a W5100 module through SPI, but why bother?

                                A RA Offline
                                A RA Offline
                                A R
                                wrote on last edited by
                                #260

                                @Yveaux I am using W5100. Its a system requirement. I want wifi connectivity with sensors through ESPs but the final data is to be routed through ethernet for security.

                                YveauxY 1 Reply Last reply
                                0
                                • A RA A R

                                  @Yveaux I am using W5100. Its a system requirement. I want wifi connectivity with sensors through ESPs but the final data is to be routed through ethernet for security.

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

                                  @A-R But do you use any MySensors parts then?

                                  http://yveaux.blogspot.nl

                                  A RA 1 Reply Last reply
                                  0
                                  • YveauxY Yveaux

                                    @A-R But do you use any MySensors parts then?

                                    A RA Offline
                                    A RA Offline
                                    A R
                                    wrote on last edited by
                                    #262

                                    @Yveaux No. I asked a simple question: can the GatewayESP8266.ino be used to send data from NodeMCU to Ethernet? If you have an answer then do reply.

                                    YveauxY 1 Reply Last reply
                                    0
                                    • A RA A R

                                      @Yveaux No. I asked a simple question: can the GatewayESP8266.ino be used to send data from NodeMCU to Ethernet? If you have an answer then do reply.

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

                                      @A-R No need to get all grumpy! I'm just trying to understand what you want to achieve, and help you out.
                                      You are posting to a MySensors forum, so I assumed you are using MySensors software in your project.
                                      Answer to your question: No.

                                      http://yveaux.blogspot.nl

                                      1 Reply Last reply
                                      2
                                      • scalzS Offline
                                        scalzS Offline
                                        scalz
                                        Hardware Contributor
                                        wrote on last edited by scalz
                                        #264

                                        @A-R : it depends of what you are connecting to esp8266, you didn't give details. esp8266 lacks of io, so it depends...I think you have not googled?? esp8266 w5100 for instance, you will find things...then if it is to use radio+w5100 with esp8266, sure it's possible but depends of available io...software spi you would have to double io, hardware spi, need manage your cs lines...some work. If it's just esp8266+w5100 there are already things on google...

                                        1 Reply Last reply
                                        0
                                        • rapzakR rapzak

                                          Hi,

                                          I have added som support, where the gateway can upload data to emoncms, transparant to other functions (not fully testet):

                                          in gatewayutil add this in top of file, after the ARDUINO check:

                                          #define EMONCMS
                                          
                                          #ifdef EMONCMS
                                          static WiFiClient emon_client;
                                          const char* emon_host = "emoncms.org";  
                                          const int emon_httpPort = 80; 
                                          const int emon_addr_offset = 10;
                                          #endif
                                          

                                          Change this function to:

                                          void incomingMessage(const MyMessage &message) {
                                          //  if (mGetCommand(message) == C_PRESENTATION && inclusionMode) {
                                          //	gw.rxBlink(3);
                                          //   } else {
                                          //	gw.rxBlink(1);
                                          //   }
                                             // Pass along the message from sensors to serial line
                                             serial(PSTR("%d;%d;%d;%d;%d;%s\n"),message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type, message.getString(convBuf));
                                          #ifdef EMONCMS
                                               if (!emon_client.connect(emon_host, emon_httpPort)) {
                                                Serial.println("emoncms connection failed");
                                                }
                                          
                                                emon_client.print(String("GET /emoncms/input/post.json?&node="+ String(message.sender+emon_addr_offset)+"&json={"+String(message.sensor)+":"+message.getString(convBuf)+"}&apikey=XXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n"));
                                                Serial.println(String("GET /emoncms/input/post.json?&node="+ String(message.sender+emon_addr_offset)+"&json={"+String(message.sensor)+":"+message.getString(convBuf)+"}&apikey=XXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n"));
                                          #endif
                                          } 
                                          

                                          It will upload data with NODE ID and Sensor ID from the network, with an offset of emon_addr_offset...

                                          /Rapzak

                                          RobbanR Offline
                                          RobbanR Offline
                                          Robban
                                          wrote on last edited by
                                          #265

                                          @rapzak said:

                                          Hi,

                                          I have added som support, where the gateway can upload data to emoncms, transparant to other functions (not fully testet):

                                          in gatewayutil add this in top of file, after the ARDUINO check:

                                          #define EMONCMS
                                          
                                          #ifdef EMONCMS
                                          static WiFiClient emon_client;
                                          const char* emon_host = "emoncms.org";  
                                          const int emon_httpPort = 80; 
                                          const int emon_addr_offset = 10;
                                          #endif
                                          

                                          Change this function to:

                                          void incomingMessage(const MyMessage &message) {
                                          //  if (mGetCommand(message) == C_PRESENTATION && inclusionMode) {
                                          //	gw.rxBlink(3);
                                          //   } else {
                                          //	gw.rxBlink(1);
                                          //   }
                                             // Pass along the message from sensors to serial line
                                             serial(PSTR("%d;%d;%d;%d;%d;%s\n"),message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type, message.getString(convBuf));
                                          #ifdef EMONCMS
                                               if (!emon_client.connect(emon_host, emon_httpPort)) {
                                                Serial.println("emoncms connection failed");
                                                }
                                          
                                                emon_client.print(String("GET /emoncms/input/post.json?&node="+ String(message.sender+emon_addr_offset)+"&json={"+String(message.sensor)+":"+message.getString(convBuf)+"}&apikey=XXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n"));
                                                Serial.println(String("GET /emoncms/input/post.json?&node="+ String(message.sender+emon_addr_offset)+"&json={"+String(message.sensor)+":"+message.getString(convBuf)+"}&apikey=XXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n"));
                                          #endif
                                          } 
                                          

                                          It will upload data with NODE ID and Sensor ID from the network, with an offset of emon_addr_offset...

                                          /Rapzak

                                          Are there any one that can help me implement this in the dev version? Have a nodemcu 1-0 and got errors uploading the 1.5 version so i cant use that. Tried to fix it but ended up with the dev version.

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


                                          17

                                          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