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.7k 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.
  • FotoFieberF FotoFieber

    @Yveaux

    • ESP12E
    • Development Version
    • Defined both DEBUG AND VERBOSE
    • Playing with AES:
    #define MY_RF24_CHANNEL  13
    #define MY_RF24_BASE_RADIO_ID ((uint64_t)0xF8A813FC09CL)
    
    #define MY_RF24_ENABLE_ENCRYPTION
    #define MY_RF24_ENCRYPTKEY  secret....
    
    #define MY_SIGNING_SOFT // Software signing enabled
    
    #define MY_SIGNING_SOFT_SERIAL secret....
    // Key to use for HMAC calculation in soft signing (32 bytes)
    
    #define MY_SIGNING_SOFT_HMAC_KEY secret
    

    It seems to work perfect without the verbose debug.

    I will test now without AES. My gut tells me, I should look inside the AES stuff.

    FotoFieberF Offline
    FotoFieberF Offline
    FotoFieber
    Hardware Contributor
    wrote on last edited by
    #157

    @Yveaux
    Downloaded the development branch again and used the sketch included as example. The sketch is hanging too. My gut was wrong, AES is not the problem.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vickey
      wrote on last edited by
      #158

      Hi.
      I am having an issue with my ESP8266 gateway. I have tried all versions of mysensors including developmental versions, but my esp8266 does not show any serial debug, nor it gets connected to my router. I also enabled debug in configuration file. When I install AT firmware, it replies to AT command, it also works with nodemcu firmware, but it does not respond with Arduino firmware. May someone help me?

      1 Reply Last reply
      0
      • AndurilA Offline
        AndurilA Offline
        Anduril
        wrote on last edited by Anduril
        #159

        Finally I got my NodeMCU and tried the WiFi gateway too. But I get the following messages (with Serial.setDebugOutput(true);):

        ESP8266 MySensors Gateway
        Connecting to WLAN
        scandone
        f 0, ....scandone
        .add 0
        aid 1
        pm open phy_2,type:2 0 0
        cnt 
        ..................rm 0
        pm close 7 0 0/9299504
        ..reconnect
        f -240, ....scandone
        no WLAN found, reconnect after 1s
        .reconnect
        f 0, ....scandone
        .add 0
        aid 1
        pm open phy_2,type:2 0 0
        cnt 
        ................rm 0
        pm close 7 0 0/8288631
        ..reconnect
        f -240, ....scandone
        no WLAN found, reconnect after 1s
        .reconnect
        f 0, ....scandone
        .add 0
        aid 1
        pm open phy_2,type:2 0 0
        cnt 
        ................rm 0
        pm close 7 0 0/8124923
        ..reconnect
        
        

        Additionally I tried to use

          IPAddress ip(192, 168, 38, 18);  /* Set to whatever IP address you'd like the gateway to have */
          WiFi.config(ip);
        

        to avoid DHCP, but that gives error during compiling:

        no matching function for call to 'ESP8266WiFiClass::config(IPAddress&)'
        

        Any hints how to solve?

        Thanks

        Edit:
        to find the problem I tested to connect the ESP to the wifi-hotspot of my smartphone... worked. Is it maybe a problem if the password contain special characters which behave strange during compiling?

        1 Reply Last reply
        0
        • YveauxY Offline
          YveauxY Offline
          Yveaux
          Mod
          wrote on last edited by Yveaux
          #160

          @Anduril said:

          no WLAN found, reconnect after 1s

          That's a clear indication the ESP cannot connect to your WiFi accesspoint.
          Is the SSID matching your accesspoint ('WLAN')?
          Is the encryption supported by the ESP (see e.g. https://nurdspace.nl/ESP8266#Features -- not sure if it is accurate)
          Weird characters in the password could be problematic (and of course the password is case-sensitive).

          Changing between DHCP/Fixed IP won't make a difference here, as the ESP doesn't even connect. IP configuration starts once connected.

          http://yveaux.blogspot.nl

          AndurilA 1 Reply Last reply
          0
          • YveauxY Yveaux

            @Anduril said:

            no WLAN found, reconnect after 1s

            That's a clear indication the ESP cannot connect to your WiFi accesspoint.
            Is the SSID matching your accesspoint ('WLAN')?
            Is the encryption supported by the ESP (see e.g. https://nurdspace.nl/ESP8266#Features -- not sure if it is accurate)
            Weird characters in the password could be problematic (and of course the password is case-sensitive).

            Changing between DHCP/Fixed IP won't make a difference here, as the ESP doesn't even connect. IP configuration starts once connected.

            AndurilA Offline
            AndurilA Offline
            Anduril
            wrote on last edited by
            #161

            @Yveaux
            SSID is 'WLAN' (all capital). Encryption is WPA2 which should be supported. The password contains '|' (don't know the name, vertical line) and 'ß' (german character). I use them among other more common ones to raise the complexity of the encryption. As I am using a bunch of wifi devices I don't want to go around and change passwords for all if not absolutely necessary. Is there a way to specify these 'weird characters' e.g. by ASCII codes or anything else?

            Changing the IP was not to solve this problem but for future use, as my DHCP is not very good. Can you tell me how to fix IP else?

            YveauxY 1 Reply Last reply
            0
            • AndurilA Anduril

              @Yveaux
              SSID is 'WLAN' (all capital). Encryption is WPA2 which should be supported. The password contains '|' (don't know the name, vertical line) and 'ß' (german character). I use them among other more common ones to raise the complexity of the encryption. As I am using a bunch of wifi devices I don't want to go around and change passwords for all if not absolutely necessary. Is there a way to specify these 'weird characters' e.g. by ASCII codes or anything else?

              Changing the IP was not to solve this problem but for future use, as my DHCP is not very good. Can you tell me how to fix IP else?

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

              @Anduril try to print your password to the serial console and see if it matches the password you entered in the sketch.

              http://yveaux.blogspot.nl

              1 Reply Last reply
              0
              • AndurilA Offline
                AndurilA Offline
                Anduril
                wrote on last edited by
                #163

                good idea @Yveaux, seems that 'ß' is the problem. serial.print shows ß at that position. Do you know how to avoid that?

                YveauxY 1 Reply Last reply
                0
                • AndurilA Anduril

                  good idea @Yveaux, seems that 'ß' is the problem. serial.print shows ß at that position. Do you know how to avoid that?

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

                  @Anduril probably Unicode problem of the editor. I assume you use the Arduino editor? Try a simple editor like notepad to type the problematic character, or directly type it in windows by setting your keyboard in numpad mode and type it's ascii code: alt+225

                  http://yveaux.blogspot.nl

                  1 Reply Last reply
                  0
                  • AndurilA Offline
                    AndurilA Offline
                    Anduril
                    wrote on last edited by Anduril
                    #165

                    @Yveaux tried with a nano to print out "ß" to serial, no problems. After that I tried that sketch on ESP:

                    void setup() {
                      Serial.begin(115200);
                      const char *pass = "ß1ß";
                      Serial.println(" "); //to break line after rubbish at init
                      Serial.println(pass);
                    }
                    
                    [not readable/copyable stuff]
                    ß1ß
                    

                    So in general it should be no problem compiling the char 'ß' even on ESP.. Also in the ESPGateway sketch I don't see anything that is changing the *pass, but maybe you know what is going on with this string in more detail.

                    edit: it seems to happen even before void setup in the gw sketch. I uncommented everything in setup, loop and output, but still get the distorted serial print of pass.

                    YveauxY 1 Reply Last reply
                    0
                    • AndurilA Anduril

                      @Yveaux tried with a nano to print out "ß" to serial, no problems. After that I tried that sketch on ESP:

                      void setup() {
                        Serial.begin(115200);
                        const char *pass = "ß1ß";
                        Serial.println(" "); //to break line after rubbish at init
                        Serial.println(pass);
                      }
                      
                      [not readable/copyable stuff]
                      ß1ß
                      

                      So in general it should be no problem compiling the char 'ß' even on ESP.. Also in the ESPGateway sketch I don't see anything that is changing the *pass, but maybe you know what is going on with this string in more detail.

                      edit: it seems to happen even before void setup in the gw sketch. I uncommented everything in setup, loop and output, but still get the distorted serial print of pass.

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

                      @Anduril I guess it shouldn't make a difference. What happens if you copy/paste the "ß1ß" string from your test sketch into the ESP gateway sketch as password and print that to serial? (make sure to use the same editor on both sketches)

                      http://yveaux.blogspot.nl

                      1 Reply Last reply
                      0
                      • AndurilA Offline
                        AndurilA Offline
                        Anduril
                        wrote on last edited by Anduril
                        #167

                        @Yveaux already tried that. When using my own sketch I get "ß1ß", when using the gw sketch (with really everything commented out, so no functionality) I get "ß1ß". I thought that it might be a problem of UFT encoding, had this issue with transfering LaTeX files created on linux system to windows system and vice versa: the system that creates the file sets the charset.
                        But I also created a completely new .ino with the gateway-code inside and new created gatewayutil.h with data copied in notepad++, but no succes.
                        And yes I use Arduino IDE as editor. Is there a good way to use another editor and compile/upload without the IDE?

                        YveauxY 1 Reply Last reply
                        0
                        • AndurilA Anduril

                          @Yveaux already tried that. When using my own sketch I get "ß1ß", when using the gw sketch (with really everything commented out, so no functionality) I get "ß1ß". I thought that it might be a problem of UFT encoding, had this issue with transfering LaTeX files created on linux system to windows system and vice versa: the system that creates the file sets the charset.
                          But I also created a completely new .ino with the gateway-code inside and new created gatewayutil.h with data copied in notepad++, but no succes.
                          And yes I use Arduino IDE as editor. Is there a good way to use another editor and compile/upload without the IDE?

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

                          @Anduril I'm still convinced it has something to do with Unicode, but very hard to nail from a distance without the actual files...
                          Maybe @hek has seen this before?

                          http://yveaux.blogspot.nl

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

                            Nope, not the slightest idea.

                            @Anduril
                            Couldn't you just temporarily change password on router to rule out other stuff?

                            1 Reply Last reply
                            0
                            • AndurilA Offline
                              AndurilA Offline
                              Anduril
                              wrote on last edited by
                              #170

                              @hek yeah already did this, when leaving out ß it works perfect. So no problem with router or ESP hardware. But changing the wifi password would be the worst case, as I have to reassign that to squeezeboxes, smartphones, laptops, wifi printer,... (and all guest devices of friends/familie) but still possible if all other things fail.
                              @Yveaux Would it help if I send you the files for verification? Is it possible inside this forum or only via email?

                              1 Reply Last reply
                              0
                              • AndurilA Offline
                                AndurilA Offline
                                Anduril
                                wrote on last edited by
                                #171

                                @Yveaux thank you very much for offering help with verification, but something strange happened during preperation of files: I took an example sketch and modified it to print the "ß1ß" on serial --> working fine.
                                But after saving the file I tried again, only reading rubbish. Thats strange! So it has something to do with saving the file and maybe setting a special encoding. Maybe thats related to the editor? Could you please try to redo what I explained and see if you get the same results? Thank you. @hek have you ever had such a problem of a sketch behaving differently after saving?

                                YveauxY 1 Reply Last reply
                                0
                                • AndurilA Anduril

                                  @Yveaux thank you very much for offering help with verification, but something strange happened during preperation of files: I took an example sketch and modified it to print the "ß1ß" on serial --> working fine.
                                  But after saving the file I tried again, only reading rubbish. Thats strange! So it has something to do with saving the file and maybe setting a special encoding. Maybe thats related to the editor? Could you please try to redo what I explained and see if you get the same results? Thank you. @hek have you ever had such a problem of a sketch behaving differently after saving?

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

                                  @Anduril Ok, did some tests:

                                  Copied your problematic example string from this topic into Arduino IDE (1.6.5), on Windows 10:

                                  upload-d3f2ea5f-8442-4f01-9f16-d77ffc2c4b49

                                  Saved the sketch.

                                  Viewed sketch.ino in notepad:
                                  upload-65587bba-2f55-4d38-9071-303fa5df2772
                                  Newlines are f*cked up, but "ß1ß" can clearly be recognized.

                                  Viewed the same sketch in HxD hex viewer:
                                  upload-d5300e08-17b9-4d7b-b069-dddba71f6649

                                  And there we are! The string is stored as Unicode characters!

                                  Reading it back in Arduino IDE:
                                  upload-01fb9b7d-3b1d-40c5-8916-6a1da46913fa

                                  Everything looks fine again.

                                  Apparently the unicode string gets compiled directly and shows as multiple, wrong characters in your sketch when used/printed...

                                  Ok, one more idea: you can try to store the ß character as an escaped ASCII character in you string (refer to this ).
                                  This will look strange in the code, but should print correctly to the console:

                                  The ASCII escape sequence for ß is \xE1
                                  Your test sequence "ß1ß" then becomes "\xE11\xE1"
                                  

                                  Please try this...

                                  http://yveaux.blogspot.nl

                                  1 Reply Last reply
                                  1
                                  • YveauxY Yveaux

                                    @Mickey In principle the MQTT gateway should also run on the ESP8266, if you make the same changes to it as I did to the Ethernet gateway example (diff of the files should help a lot: https://www.diffchecker.com/eeo5ahzn).
                                    On the other hand, the pubsubclient (https://github.com/knolleary/pubsubclient) MQTT client implementation by knolleary is heavily tested and works fine on ESP8266 (I tested it myself).
                                    The ESP8266 has a lot more Flash & RAM available than an ATMega, so implementing MQTT should not be a problem.

                                    M Offline
                                    M Offline
                                    mkeyno
                                    wrote on last edited by
                                    #173

                                    @Yveaux
                                    hi
                                    there is problem for sensor library when we intend use the its examples as following
                                    In file included from \libraries\MySensors\MyGateway.cpp:13:0:

                                    \libraries\MySensors\utility/MsTimer2.h:7:2: error: #error MsTimer2 library only works on AVR architecture
                                    #error MsTimer2 library only works on AVR architecture
                                    ^
                                    In file included from \libraries\MySensors\MyGateway.cpp:14:0:
                                    \libraries\MySensors\utility/PinChangeInt.h:103:19: fatal error: new.h: No such file or directory
                                    #include <new.h>
                                    ^
                                    compilation terminated.
                                    Error compiling.

                                    YveauxY 1 Reply Last reply
                                    0
                                    • M mkeyno

                                      @Yveaux
                                      hi
                                      there is problem for sensor library when we intend use the its examples as following
                                      In file included from \libraries\MySensors\MyGateway.cpp:13:0:

                                      \libraries\MySensors\utility/MsTimer2.h:7:2: error: #error MsTimer2 library only works on AVR architecture
                                      #error MsTimer2 library only works on AVR architecture
                                      ^
                                      In file included from \libraries\MySensors\MyGateway.cpp:14:0:
                                      \libraries\MySensors\utility/PinChangeInt.h:103:19: fatal error: new.h: No such file or directory
                                      #include <new.h>
                                      ^
                                      compilation terminated.
                                      Error compiling.

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

                                      @mkeyno did you change anything to the gateway code, and which version of MySensors are you running?
                                      I've ported the gateway code to ESP8266. That doesn't mean any sensor code will also automatically run on an ESP.
                                      Packaged with MySensors are a lot of libraries that will not compile on ESP, so if you try to use one (pinchange int or timers) it will likely fail to compile.

                                      http://yveaux.blogspot.nl

                                      M 1 Reply Last reply
                                      0
                                      • AndurilA Offline
                                        AndurilA Offline
                                        Anduril
                                        wrote on last edited by
                                        #175

                                        @Yveaux SUCCES!!! Thank you very much, your way worked nearly perfect. ONly small change: "ß" is represented by hexcode DF, so using \eDF gives the correct wifi password for me.
                                        Now a last thing as bonus: how to setup a fixed ip and not using dhcp? My dhcp is not very usable as it reassigns all IPs on reboot (stupid firmware by Deutsche Telekom).

                                        YveauxY 1 Reply Last reply
                                        0
                                        • AndurilA Anduril

                                          @Yveaux SUCCES!!! Thank you very much, your way worked nearly perfect. ONly small change: "ß" is represented by hexcode DF, so using \eDF gives the correct wifi password for me.
                                          Now a last thing as bonus: how to setup a fixed ip and not using dhcp? My dhcp is not very usable as it reassigns all IPs on reboot (stupid firmware by Deutsche Telekom).

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

                                          @Anduril Great to hear you got it to work!

                                          how to setup a fixed ip and not using dhcp?

                                          Google'd a bit. Seems like Wifi.config requires 3 parameters:

                                              // static ip, gateway, netmask
                                              WiFi.config(IPAddress(192,168,1,100), IPAddress(192,168,1,1), IPAddress(255,255,255,0));
                                          

                                          Make sure to call it after WiFi.begin().

                                          Btw. ESP8266 Arduino port follows the Arduino WiFi library API.

                                          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


                                          10

                                          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