GUI-O Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    ESP8266 & Arduino & GUI-O automatic pairing

    Scheduled Pinned Locked Moved
    Frequently Asked Questions (FAQ)
    2
    31
    4.7k
    Loading More Posts
    • 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.
    • B
      Bernard
      last edited by

      Good morning
      I'm desperately trying to follow the procedure "ESP8266 & Arduino & GUI-O automatic pairing" I installed Arduino IDE, libraries etc, etc.
      it is for a Wemos D1 mini ESP8266 module. When compiling the program, I got an error message (attached) I am not a C specialist, can anyone help me?

      C:\Users\bbell\Downloads\ESP8266_GUI-O_pairing_source\PairingMQTT\program_sta.cpp: In member function 'virtual bool ProgramSta::serialInputHandler()':
      C:\Users\bbell\Downloads\ESP8266_GUI-O_pairing_source\PairingMQTT\program_sta.cpp:184:1: error: control reaches end of non-void function [-Werror=return-type]
      184 | }
      | ^
      cc1plus.exe: some warnings being treated as errors
      Multiple libraries were found for "PubSubClient.h"
      Used: C:\Users\bbell\Documents\Arduino\libraries\PubSubClient
      Not used: C:\Users\bbell\Documents\Arduino\libraries\AllThingsTalk_WiFi_SDK
      Multiple libraries were found for "TaskSchedulerDeclarations.h"
      Used: C:\Users\bbell\Documents\Arduino\libraries\TaskScheduler
      Not used: C:\Users\bbell\Documents\Arduino\libraries\TaskScheduler-3.7.0
      exit status 1

      Compilation error: control reaches end of non-void function [-Werror=return-type]

      K 1 Reply Last reply Reply Quote 0
      • K
        kl3m3n @Bernard
        last edited by

        @Bernard Hi,

        your compiler treats warnings as errors, so any warning stops the compilation.

        Firstly, please try putting

        return false;
        

        at the end of

        ProgramSta::serialInputHandler()
        

        method (in program_sta.cpp source).

        So it becomes:

        bool ProgramSta::serialInputHandler ()
        {
            // First try with parent handler...
            if (Program::serialInputHandler()) {
                return true;
            }
        
            // ... then parse your other custom commands on serial port (if any)
            return false;
        }
        

        I will fix this in the source ASAP (I won't have access to my computer for a couple of days, so it will take some time).

        Please try this and recompile.

        Best regards,
        kl3m3n

        B 1 Reply Last reply Reply Quote 0
        • B
          Bernard @kl3m3n
          last edited by

          @kl3m3n Hello
          I modified the program as you suggested and now I have no more message during the compilation and the esp8266 module is written! I find on my phone the wifi network "guio_ea9f6d93b119". But there is something strange, in the config.h program the baud rate is 9600 bd. (#define _GUIO_SERIAL_BAUDRATE 9600) but if I connect the module to the serial port of the arduino, it must be set to 74880 bd to read the module!
          Finally, when I apply the procedure "Pair GUI-O application with ESP8266 board" everything goes well until point 7, but at point 8 I have a message that tells me: waiting for pairing device and 2 seconds later it invites me again to start the procedure again ......?
          practical question: how do you attach a photo, I tried to attach a photo but I got a messagecompilation error.jpg
          Thank you for your patience !!
          Bernard

          K 1 Reply Last reply Reply Quote 0
          • K
            kl3m3n @Bernard
            last edited by kl3m3n

            @Bernard Hi!

            Perhaps you are using older pairing code (the baud rate should be 115200). A brief explanation: 74k baud is used by the Esp8266 bootloader (as far as I know). When you program the Esp8266, you can set your own baud rate for uart - this is your new communication rate... Note that Esp8266 serves as a uart bridge between your device and GUI-O application (via a server of course).

            There was also a potential problem with older pairing code, which resulted in the behaviour you're seeing (pairing failure). The memory allocation for pairing parameters was not big enough for some longer WiFi ssid names (and passwords).

            Please re-download the pairing code (the baud should be set to 115k) and retry. Note that in the newer code (in ProgramAp::pairingRequestHandler method) the

            StaticJsonDocument<500> responseDocument;
            

            is allocated 500 bytes. Your current code is allocating less. Can you confirm this?

            I will appreciate the feedback.

            Best regards,
            kl3m3n

            B 1 Reply Last reply Reply Quote 0
            • B
              Bernard @kl3m3n
              last edited by

              @kl3m3n said in ESP8266 & Arduino & GUI-O automatic pairing:

              ProgramAp::pairingRequestHandler )

              Good morning,
              In the program " program_app.cpp I find: // Prepare response object StaticJsonDocument<500> responseDocument; it seems to be correct. Stupid question but where can I adjust the 115200 bd? and where download "ProgramAp::pairingRequestHandler )"?
              Thank you for your patience Bernard

              K 1 Reply Last reply Reply Quote 0
              • K
                kl3m3n @Bernard
                last edited by kl3m3n

                @Bernard You are using the right code then.

                You can set the baud rate via

                #define _GUIO_SERIAL_BAUDRATE baud
                

                where the baud is your desired baud rate... You can use 9600 if you want to... Just make sure that you use the same baud when communicating with Esp8266 (after pairing!).

                Let's get back to pairing first... After you select "guio_ea9f6d93b119" network, try waiting a bit until Android prompts you to switch networks... Don't switch the network and after this press back button to return to the application.

                Best regards,
                kl3m3n

                B 1 Reply Last reply Reply Quote 0
                • B
                  Bernard @kl3m3n
                  last edited by

                  @kl3m3n
                  After GIO wifi password => I activate the GUIO_xxxx network, my phone does not prompt me to change network but asks me if I want to keep the guio_xxxxxx wifi connection. I answer yes, I go back, a window with a big green V invites me to reconnect to my wifi router => continue, I select my wifi router, I press back and after 1 second my phone tells me that You have to start the procedure again! if I leave it in this state, a window tells me "Iot connection error. Connection refused, retry in 5 seconds. I think that's the procedure? Before this procedure, is there any other reason to TO DO ? Bernard

                  B 1 Reply Last reply Reply Quote 0
                  • B
                    Bernard @Bernard
                    last edited by

                    @kl3m3n
                    small clarification: after being asked to reconnect to my wifi router, I see the blue led of the wifi module light up for about 300 msec.

                    K 1 Reply Last reply Reply Quote 0
                    • K
                      kl3m3n @Bernard
                      last edited by kl3m3n

                      @Bernard Hi.

                      Can you please take a look at this video and tell me where do you encounter the problem?

                      If I understand correctly, the pairing data is exchanged OK. The problem occurs after you reconnect to your router and press back button (at time 0:55 in video above)? You get "Please retry pairing" error?

                      Also, this error you are describing (Iot connection error. Connection refused, retry in 5 seconds) is raising alarms for me... Can you check IoT settings from the settings menu... Can you connect to IoT (Settings -> Connections -> IoT -> Connect)? It seems there is something wrong with your credentials. Did you by chance modify anything?

                      Best regards
                      kl3m3n

                      B 1 Reply Last reply Reply Quote 0
                      • B
                        Bernard @kl3m3n
                        last edited by

                        @kl3m3n
                        it is precisely at second 58 of the video, when I return from my reconnection to my wifi. Regarding IoT parameters:
                        Autoconnect is ON (in blue), Server Name = No set, SSL port Number =50000, User-name=gui-o-mqtt-generic, User password = Hidden from user, If I click on it, 9 black dots appear! ! which looks like a password , ,Client id_ No set, Enable IoT notification= disable, Open IoT notification= nothing, Notification to show = nothing
                        PS: I removed the password in Hidden from user, and tried a connection again, without success!
                        Bernard

                        K B 2 Replies Last reply Reply Quote 0
                        • K
                          kl3m3n @Bernard
                          last edited by kl3m3n

                          @Bernard Yes, you have wrong credentials. This is what's causing the problem. You have changed the settings somehow...

                          I advise you to clear application data or uninstall and reinstall the application. This will reset the settings to default. Alternatively, you could input the correct settings, but I recommend reinstall... It will be easier for you. Then retry pairing.

                          Note that you must keep the default settings if you want to connect to GUI-O server!

                          Best regards,
                          kl3m3n

                          B 1 Reply Last reply Reply Quote -1
                          • B
                            Bernard @Bernard
                            last edited by

                            @Bernard said in ESP8266 & Arduino & GUI-O automatic pairing:

                            @kl3m3n
                            I forgot 2 parameters in IoT: Connect: Disconnected , New: Add new device: nothing, but after trying to connect I find the name I put in "Pairing device name"

                            1 Reply Last reply Reply Quote 0
                            • B
                              Bernard @kl3m3n
                              last edited by

                              @kl3m3n

                              We are progressing! I uninstalled GUI-O and reinstalled. a new connection attempt and now I arrive at "waiting for peraid device" the blue bar advances for 2 minutes and after that it invites me to start the procedure again. This could be a bad configuration of the wifi module?!
                              it's a wemos D1 mini ESP8266, in the arduino IDE I used the Lolin(Wemos) D1 mini pro.
                              Bernard

                              K 1 Reply Last reply Reply Quote 0
                              • K
                                kl3m3n @Bernard
                                last edited by

                                @Bernard how do you put Esp8266 into pairing mode? Once the pairing data is stored on Esp8266, it will boot directly into stationary (working) mode. Do you clear the parameters with !CLEAR_PARAMS command?

                                You must make sure that the WiFi password you input during pairing is correct, otherwise Esp8266 cannot connect. When Esp8266 is connected to the server successfully, the LED should be permanently ON! Please check that the built-in LED configuration is correct for your board (see config.h).

                                Best regards
                                kl3m3n

                                B 1 Reply Last reply Reply Quote 0
                                • B
                                  Bernard @kl3m3n
                                  last edited by

                                  @kl3m3n
                                  I see in config.h the following parameters: // Serial communication baud rate
                                  #define _GUIO_SERIAL_BAUDRATE 9600

                                  // LED used for main signaling tasks (e.g., built-in LED)
                                  #define _GUIO_LED_MAIN LED_BUILTIN

                                  // Pin that serves as AP/reset button
                                  #define _GUIO_AP_BUTTON D4, the password is 12345678, after flashing the module if I press the reset key I have the following text in the serial monitor of the IDE:
                                  "ets Jan 8 2013,rst cause:2, bootmode:(3,7)
                                  load 0x4010f000, len 3424, room 16
                                  tail 0
                                  chksum 0x2e
                                  load 0x3fff20b8, len 40, room 8
                                  tail 0
                                  chksum 0x2b
                                  csum 0x2b
                                  v00051370
                                  ~ld ".
                                  I note that at the end of the pairing attempt, as described yesterday, the blue led flach ~ 300 msec . I also specify that during the pairing phase, the wifi module is connected to my PC for l power and that I have not changed any parameters in config.h or elsewhere. Before starting the procedure in IoT there is: Autoconnect: Automatic (re)connect, Connect: "connected", New: "Add a new device ". After the procedure in New, I find the device associated with the device ( Bernard or GUIO or Test.
                                  Bernard

                                  B 1 Reply Last reply Reply Quote 0
                                  • B
                                    Bernard @Bernard
                                    last edited by

                                    @kl3m3n

                                    If I'm not mistaken, normally after the initialization phase with Arduino IDE, if I press the reset button of the Wifi module I should see on the serial monitor something like:

                                    GUI-O ESP8266
                                    AP mode
                                    ssid: guio_xxxxxxxx
                                    password:12345678
                                    AP status 1.
                                    It's just no ?

                                    K 1 Reply Last reply Reply Quote 0
                                    • K
                                      kl3m3n @Bernard
                                      last edited by

                                      @Bernard please uncomment

                                      #define _GUIO_DEBUG
                                      

                                      in config.h to output more information on uart. Recompile and reupload the code to Esp8266. This will give us more information to work with.

                                      It is definitely some problem on Esp8266 side (not on the GUI-O app side).

                                      Regards,
                                      kl3m3n

                                      B 1 Reply Last reply Reply Quote 0
                                      • B
                                        Bernard @kl3m3n
                                        last edited by

                                        @kl3m3n
                                        Here is what I see on the IDE terminal:
                                        Pairing request: {
                                        "mqttHostName": "mqtt.gui-o.com",
                                        "mqttUserName": "gui-o-mqtt-generic",
                                        "mqttUserPassword": "lqXeZpv5VJyv0XBT",
                                        "networkPassword": "---------",
                                        "networkSsid": "-----",
                                        "publishTopic": "95fb4171-2024-42de-978e-fcbb6c6caf10",
                                        "subscribeTopic": "b1126463-4511-45b0-84fa-350ad2a41751"
                                        }
                                        Pairing response: {
                                        "pairingResponse": 0,
                                        "pairingDeviceName": "guio_ea9f6d93b119",
                                        "networkSsid": "------",
                                        "networkPassword": "---------",
                                        "mqttHostName": "mqtt.gui-o.com",
                                        "mqttUserName": "gui-o-mqtt-generic",
                                        "mqttUserPassword": "lqXeZpv5VJyv0XBT",
                                        "subscribeTopic": "b1126463-4511-45b0-84fa-350ad2a41751",
                                        "publishTopic": "95fb4171-2024-42de-978e-fcbb6c6caf10"
                                        }
                                        Pairing succeeded! Copying parameters and scheduling restart...
                                        b
                                        gC))k%
                                        H
                                        I a 0gf) X ʎ t N
                                        y )1% 9o)C C9
                                        E )/
                                        **** ESP8266 GUI-O ****

                                        GUI-O parameters not found... initializing...
                                        AP Mode
                                        ssid: guio_ea9f6d93b119
                                        password: 12345678
                                        AP status: 1
                                        I deliberately erased password and ssid but they are correct.
                                        Bernard

                                        K 1 Reply Last reply Reply Quote 0
                                        • K
                                          kl3m3n @Bernard
                                          last edited by

                                          @Bernard It seems that the pairing parameters are not saved into Esp8266 EEPROM successfully... This triggers booting into AP (pairing) mode...

                                          I am wondering if your board selection is ok?

                                          @Bernard said in ESP8266 & Arduino & GUI-O automatic pairing:

                                          This could be a bad configuration of the wifi module?!
                                          it's a wemos D1 mini ESP8266, in the arduino IDE I used the Lolin(Wemos) D1 mini pro.

                                          Best regards,
                                          kl3m3n

                                          B 1 Reply Last reply Reply Quote 0
                                          • B
                                            Bernard @kl3m3n
                                            last edited by

                                            @kl3m3n
                                            Good morning,
                                            actually i think the wifi modul is faulty. I tried to flash it with 5 different combinations but it's always the same result. I will therefore recommend one and I will keep you informed of the evolution of things. In any case, thank you very much for your patience and valuable advice! maybe these exchanges will be useful to others, but I think it's bad luck.
                                            Kind regards Bernard

                                            K 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post