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.
  • 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
                                    • B Offline
                                      B Offline
                                      bkenobi
                                      wrote on last edited by
                                      #266

                                      Can anyone provide the correct wiring for NodeMCU (ESP-12E) to RFM69HW? I have seen several different guides that show connections for RFM69, but there are several different patterns and none have worked so far. Perhaps I didn't get it right, but this is what I've seen and tried:

                                      someburner/esp-rfm69

                                      RFM69->	ESP-12E
                                      MISO	GPIO12
                                      MOSI	GPIO13
                                      SCK		GPIO14
                                      CS/SS	GPIO15
                                      DIO0	GPIO5
                                      VCC		3V3
                                      GND		GND
                                      ANA		<antenna>
                                      

                                      halburd/NodeMCU-Gateway

                                      RFM69->	NodeMCU
                                      NSS		GPIO2 (J2P5)
                                      SCK		SCK (J1P9)
                                      MISO	MISO (J1P8)
                                      MOSI	MOSI (J1P6)
                                      DIO0	SS (J1P7)
                                      VCC		3V3
                                      GND		GND
                                      ANA		<antenna>
                                      

                                      I've also determined that the following should also be correct, though again, they all don't match.

                                      RFM69	ESP-12E	WEMOS D1	NodeMCUv3
                                      MISO	GPIO12	D6/D12		D6
                                      MOSI	GPIO13	D7/D11		D7
                                      SCK		GPIO14	D5/D13		D5
                                      CS/SS	GPIO15	D10			D8
                                      DIO0	GPIO5	D3/D15		D1
                                      

                                      I've also tried to figure out how to use the nRF24L0+ wiring, but that doesn't quite match either. If someone could simply post a working config, I could get some traction on my project.

                                      1 Reply Last reply
                                      0
                                      • B Offline
                                        B Offline
                                        bkenobi
                                        wrote on last edited by
                                        #267

                                        Looking at the different charts, I've located some errors (I think).

                                        Looking at someburner's setup, it looks like he is opting to use software SPI rather than hardware as the ESP pins for SPI are not on GPIO12-15.

                                        Looking at halburd's code, it appears that he's opted to use GPIO2 for slave select and connect the actual SS to DIO0. I'm not clear why this is done, but it seems odd.

                                        I lost the reference to the last chart. It also uses GPIO's for SPI rather than the built-in hardware SPI. The guide in this sketch is only documented for nRF24L01+, so it doesn't match exactly. But, it also uses GPIO 4, 12, 13, 14, 15. It seems odd to use those rather than the SPI pins.

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

                                          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 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          23

                                          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