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.
  • E Offline
    E Offline
    emc2
    Hardware Contributor
    wrote on last edited by
    #242

    @Yveaux
    Is there any specific reason on why CE is plugged on D2?
    I'm asking as I want to add a BME280 sensor directly on my gateway and by default the I2C bus is on D2/D1. It can be changed to any pin with Wire.begin(SDA,SCL) so it is not a major problem, but for user friendliness it would be nicer id CE was plugged on D9 or eventually D4 or D3.

    If there is no specific reason can I change MyConfig.h line 329 to #define MY_RF24_CE_PIN 3 safely?

    Thanks again for this gateway!

    YveauxY 1 Reply Last reply
    0
    • E emc2

      @Yveaux
      Is there any specific reason on why CE is plugged on D2?
      I'm asking as I want to add a BME280 sensor directly on my gateway and by default the I2C bus is on D2/D1. It can be changed to any pin with Wire.begin(SDA,SCL) so it is not a major problem, but for user friendliness it would be nicer id CE was plugged on D9 or eventually D4 or D3.

      If there is no specific reason can I change MyConfig.h line 329 to #define MY_RF24_CE_PIN 3 safely?

      Thanks again for this gateway!

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

      @emc2 said:

      Is there any specific reason on why CE is plugged on D2?

      Not that I know of.

      http://yveaux.blogspot.nl

      1 Reply Last reply
      0
      • E Offline
        E Offline
        emc2
        Hardware Contributor
        wrote on last edited by
        #244

        Switching it to D9 and adding #define MY_RF24_CE_PIN 3 directly to the program worked indeed.

        Now everything seems to work either by moving the I2C bus or the CE. It may be nice to officially free up the I2C port on the next versions of the library by default? It could be easier than to modify each I2C sensor or even display libraries individually.

        I will let it run a little while and if I don't see any major problem I will try to put the code in a new topic. Thanks for your fast answer @Yveaux !

        1 Reply Last reply
        0
        • rapzakR Offline
          rapzakR Offline
          rapzak
          wrote on last edited by rapzak
          #245

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


                                          26

                                          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