ESP8266Wifi Gateway won't connect



  • I'm trying to add a 2.4 GHz gateway using an 8266 nodemcu and nrf24l01 module. I wired the system according to the "Connecting the Radio" section for ESP8266 devices. I've double checked the wiring.
    The system programs and runs as expected with no errors. Nothing is sent to the serial port except the initial bootloader stuff. No connection info, no nada. My SSID and password are correct. I have the My_Debug def uncommented. The system is not connecting to the network...and I'm not sure why. The 8266 is known good. I'm using the app directly from the MySensors Examples with my network credentials added. Wired up a WEMOS mini and another radio exactly the same way with the same results. I've even tried another radio on the setup...same
    Does the code try to connect to the network first or does set up the radio first. I'm not seeing any debug info whatsoever? I'm using Domoticz running on a raspberry pi system. Any ideas?? Have I got the wiring wrong?

    Thanks,
    Dan


  • Mod



  • @mfalkvidd yes
    Yes, it's defined. I also ran the advanced webserver sample and it runs fine. It connects nicely and sends status to the serial port.


  • Mod

    @dpcons could you post photos of your setup? Having some more eyes on the wiring can help sometimes.

    When you test the webserver, do you use the exact same wiring?



  • IMG_20220819_114756303_HDR.jpg IMG_20220819_114858392_HDR.jpg IMG_20220819_114802950_HDR.jpg

    I tested the Advanced Web Server Sample with this setup. Works fine. I tried the GatewayESP8266 on this setup and another setup with a WEMOS Pro mini. Same results, nothing out the serial port. I also tried the gateway app on an esp8266 with no radio attached and got no serial at 115200 at all. Is this normal? Shouldn't I get some kind of error message.
    I'll try setting up an app to talk to the RF24 directly and see how that goes.
    Is the GatewayESP32 working for the RF24 radios? If so, maybe I'll try that. I'm quite puzzled.
    This assembly worked at one time a couple of years ago on another system.



  • Tried on windows 11 machine Arduino 1.8.19 with latest MySensors Library. Tried on Windows 10 machine with Arduino 1.8.13 and latest MySensors library. Just an FYI. Thanks for staying with me.



  • @dpcons As you are seeing no serial debug data. Have you checked that your serial data monitor is set for the same baud rate as set in the sketch (9600 on MySensors GatewayESP8266 sketch) as other sketches use default 115200



  • No comm at any baud rate except trash I/O at boot time. The gateway code specifies 9600 but I've tried them all. The problem is the system is not connecting with the network.

    In addition, built up a new system using an ESP32 module and an nRF24L01 module.
    Tried the "GatewayESP32" example app on the known good ESP32 module. After uploading, this module spits good data out the serial port at 115200 KHz (See below:)...but never tries to connect to the network. I'm using the "GatewayESP32" example with my network credentials added.
    The ESP32 appears to be getting data from my 2.4GHz sensors, but never gets to my network.

    16:57:05.271 -> 10009772 TSF:MSG:BC
    16:57:05.271 -> 10009774 TSF:MSG:FPAR REQ,ID=12
    16:57:05.271 -> 10009776 TSF:PNG:SEND,TO=0
    16:57:05.271 -> 10009779 TSF:CKU:OK
    16:57:05.271 -> 10009781 TSF:MSG:GWL OK
    16:57:05.505 -> 10010001 !TSF:MSG:SEND,0-0-12-12,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    16:57:05.505 -> 10010008 TSF:MSG:READ,9-9-0,s=0,c=1,t=0,pt=7,l=5,sg=0:26.0
    16:57:21.018 -> 10025533 TSF:MSG:READ,7-7-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    16:57:21.018 -> 10025539 TSF:MSG:BC
    16:57:21.018 -> 10025540 TSF:MSG:FPAR REQ,ID=7
    16:57:21.018 -> 10025543 TSF:PNG:SEND,TO=0
    16:57:21.018 -> 10025545 TSF:CKU:OK
    16:57:21.018 -> 10025547 TSF:MSG:GWL OK
    16:57:21.674 -> 10026174 !TSF:MSG:SEND,0-0-7-7,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    16:57:29.313 -> 10033832 TSF:MSG:READ,3-3-0,s=0,c=1,t=37,pt=2,l=2,sg=0:1380
    16:57:31.843 -> 10036367 TSF:MSG:READ,5-5-0,s=0,c=1,t=0,pt=7,l=5,sg=0:-0.3
    16:57:31.937 -> 10036433 TSF:MSG:READ,5-5-0,s=1,c=1,t=0,pt=7,l=5,sg=0:-19.5
    16:57:43.934 -> 10048467 TSF:MSG:READ,7-7-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
    16:57:43.981 -> 10048472 TSF:MSG:PINGED,ID=7,HP=1
    16:57:43.981 -> 10048516 !TSF:MSG:SEND,0-0-7-7,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1
    16:57:56.119 -> 10060615 TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:43.3
    16:57:56.119 -> 10060635 TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:26.0
    16:58:04.393 -> 10068900 TSF:MSG:READ,3-3-0,s=0,c=1,t=37,pt=2,l=2,sg=0:1380
    16:58:05.190 -> 10069700 TSF:MSG:READ,9-9-0,s=0,c=1,t=0,pt=7,l=5,sg=0:26.0
    16:58:06.736 -> 10071270 TSF:MSG:READ,5-5-0,s=0,c=1,t=0,pt=7,l=5,sg=0:-0.1
    16:58:06.830 -> 10071334 TSF:MSG:READ,5-5-0,s=1,c=1,t=0,pt=7,l=5,sg=0:-19.4
    16:58:35.125 -> 10099641 TSF:MSG:READ,9-9-0,s=0,c=1,t=0,pt=7,l=5,sg=0:26.0
    16:58:39.437 -> 10103962 TSF:MSG:READ,3-3-0,s=0,c=1,t=37,pt=2,l=2,sg=0:1380
    16:58:41.640 -> 10106168 TSF:MSG:READ,5-5-0,s=0,c=1,t=0,pt=7,l=5,sg=0:0.0
    16:58:59.372 -> 10123897 TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:43.3
    16:58:59.419 -> 10123914 TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:26.0
    16:59:05.091 -> 10129603 TSF:MSG:READ,9-9-0,s=0,c=1,t=0,pt=7,l=5,sg=0:26.0
    16:59:14.527 -> 10139033 TSF:MSG:READ,3-3-0,s=0,c=1,t=37,pt=2,l=2,sg=0:1380
    16:59:16.571 -> 10141065 TSF:MSG:READ,5-5-0,s=0,c=1,t=0,pt=7,l=5,sg=0:0.1
    Again, as with the ESP8266 gateway the "Advanced Web Server" for the ESP32 chip uploads nicely, connects to my network and runs as expected. I'm stopped anyway I try to go.



  • @dpcons I assembled a board copied from yours for testing.
    Img_9930x.jpg

    I could replicate the problem. It is with the ESP core version and the MySensor Version
    MySensors version 2.3.2 and ESP8266 core 3.0.2 does not work,

    MySensors version 2.3.2 and ESP8266 core 2.7.4 works

    Mysensors development version 2.4.0-Alpha and newest ESP8266 core 3.0.2 also works

    So you can either update the esp core to older version 2.7.4, or install the development version of MySensors 2.4.0-Alpha



  • @hard-shovel said in ESP8266Wifi Gateway won't connect:

    MySensors version 2.3.2 and ESP8266 core 2.7.4 works



  • @hard-shovel I had same issue and using older version worked for me too



  • @hard-shovel Thanks so much for your effort and your timely resolution. I tried going back with previous versions of the library and they didn't work or didn't compile. I greatly appreciate your help with this. I assume something similar is happening to the ESP32 version also. Again, thanks.



  • @dpcons @hard-shovel @paqor @chrishiscox @mfalkvidd Hi all,

    I saw this and got excited that I could use my NodeMCUv1.0 as a MySensors Gateway. I made sure I had the latest MySensors library (2.3.2) and ESP8266 board (3.0.2). I successfully ran a couple examples, first file-->examples-->ESP8266-->Blink then file-->examples-->ESP8266-->interactive (with my ssid & pass), the latter with serial monitor at 115200 baud.

    I ensured that my nRF24l01 was functional by connecting it to an Arduino Nano and running the scanner program.

    I connected my nRF24l01 to my NodeMCU, both having pins, using new 10cm 7 conductor ribbon cable. (I have successfully used this type of connection to an RPi)

    The program ... I copied the program from this page and applied my ssid and password. Nothing ... I suspected that this code is a node template, not a the gateway program.

    On that same page was the instruction "Open the WiFi gateway in the Arduino IDE (File -> Sketchbook -> Libraries -> MySensors -> Esp8266Gateway)" I didn't find "Libraries" under "Sketchbook" I a file of the same name at (File -> Sketchbook -> Libraries -> MySensors -> examples --> Esp8266Gateway) which is the same file.

    I tried putting into setup the line

    Serial.println("com check");
    

    but nothing came out on the console.

    I think I'm at the same place as @dpcons

    update: rechecked my radio with the RF24 "getting started" program and found the radio good. Updated my Arduino IDE. Still not working.



  • @OldSurferDude @dpcons Hi all,
    The sample sketch could also be found using (File -> Examples -> MySensors -> Esp8266Gateway

    As MySensors version 2.3.2 and ESP8266 core 3.0.2 combination does not work you need to change one or the other versions.

    The simplest is to roll back the ESP8266 Core version to 2.7.4 and keep the MySensors 2.3.2 version
    (Tools -> Board -> Board Manager)
    Enter ESP8266 in search bar, then click within the ESP8266 data info box, click the select version pulldown.
    Select 2.7.4 and then click Install.

    311c31b0-d056-436f-a3b0-d95cf3099b13-image.png

    Other option is to update the MySensors library to the development version 2.4.0-Alpha but that has to be done manually.



  • @hard-shovel Thanks! Now I'm getting output to the monitor. I think I need to set up the IP address and the port 1883 for the MQTT broker. How is that done? I am also getting data from my Arduino node sensors 🙂 I see "controller" but when I change that to my broker's address I get streaming ETH FAIL



  • The port was set to 5003 and setting it to 1883 (the default MQTT broker port) it now seems to work



  • @OldSurferDude If connecting to a MQTT Broker i would have expected you to use the GatewayESP8266MQTTClient sketch.
    as this is already setup with correct Port 1883 for MQTT and the publishing and subscription topics.

    I did a quick test of a GatewayESP8266MQTTClient sketch with mosquitto and it works fine for me.



  • @hard-shovel While it all seemed to be working, it appears that the ESP8266 MySensors Gateway was not passing the data onto the MQTT broker. Working, meaning that data from the Arduino sensors were getting to the Gateway, but that data was not getting to the broker. Here are some lines of the debug output:

    6217818 TSF:MSG:READ,133-133-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    6217883 TSF:MSG:BC
    6217903 TSF:MSG:FPAR REQ,ID=133
    6217936 TSF:CKU:OK,FCTRL
    6217962 TSF:MSG:GWL OK
    6218281 !TSF:MSG:SEND,0-0-133-133,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 
    

    Also, as an indication that data was not being passed from the Gateway to the broker, I had reset my MQTT Broker and subsequently monitored it with MQTT explorer. The topic "mysensors-out" was not created.

    I shut down the ESP8266 MySensors Gateway and restarted the my original one that is running on an RPi. Everything started running as expected.

    Thus, my conclusion.

    OK, so why isn't the ESP8266 MySensors Gateway passing on the data?



  • @hard-shovel I try the client



  • @hard-shovel client worked for me, too. That is, it sent the message "2.3.2" to topic "mygateway1-outx/0/255/0/0/18"



  • @hard-shovel I tried the client and it did indeed send the MySensors version message. But it does not pass along the messages from the Arduino nodes.



  • @OldSurferDude have you set the MQTT user and MQTT passwords in the sketch and uncommented them as well?

    // Enable these if your MQTT broker requires usenrame/password
    //#define MY_MQTT_USER "username"
    //#define MY_MQTT_PASSWORD "password"
    
    // Enable these if your MQTT broker requires usenrame/password
    #define MY_MQTT_USER "MQTTusername2022"
    #define MY_MQTT_PASSWORD "MQTTpassword2022"
    

    what does your debug log look like?
    This sample is not connected correctly to the MQTT Broker

    10:33:26.151 -> dhcp client start...
    10:33:26.151 -> 341 TSM:INIT:GW MODE
    10:33:26.199 -> 364 TSM:READY:ID=0,PAR=0,DIS=0
    10:33:26.199 -> 396 MCO:REG:NOT NEEDED
    10:33:26.339 -> 505 GWT:TPC:CONNECTING...
    10:33:27.365 -> 1533 MCO:BGN:STP
    10:33:27.365 -> 1551 MCO:BGN:INIT OK,TSP=1
    10:33:27.412 -> 1579 TSM:READY:NWD REQ
    10:33:27.412 -> 1606 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    10:33:28.671 -> scandone
    10:33:35.993 -> pm open,type:2 0
    10:33:44.664 -> 18861 TSF:MSG:READ,254-254-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    10:33:44.758 -> 18924 TSF:MSG:BC
    10:33:44.758 -> 18942 TSF:MSG:FPAR REQ,ID=254
    10:33:44.804 -> 18973 TSF:PNG:SEND,TO=0
    10:33:44.804 -> 18998 TSF:CKU:OK
    10:33:44.851 -> 19016 TSF:MSG:GWL OK
    10:33:45.459 -> 19646 TSF:MSG:SEND,0-0-254-254,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    10:33:46.671 -> 20876 TSF:MSG:READ,254-254-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
    10:33:46.766 -> 20939 TSF:MSG:PINGED,ID=254,HP=1
    10:33:46.813 -> 20980 TSF:MSG:SEND,0-0-254-254,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
    10:33:46.860 -> 21057 TSF:MSG:READ,254-254-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    

    This is working correctly

    10:36:34.908 -> dhcp client start...
    10:36:37.655 -> ip:192.168.1.202,mask:255.255.255.0,gw:192.168.1.254
    10:36:37.702 -> 7014 GWT:TPC:IP=192.168.1.202
    10:36:37.702 -> 7100 GWT:RMQ:CONNECTING...
    10:36:37.749 -> 7144 GWT:RMQ:OK
    10:36:37.795 -> 7161 GWT:TPS:TOPIC=mygateway4-out/0/255/0/0/18,MSG SENT
    10:36:44.792 -> pm open,type:2 0
    10:38:56.629 -> 146027 TSF:MSG:READ,254-254-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    10:38:56.723 -> 146091 TSF:MSG:BC
    10:38:56.723 -> 146109 TSF:MSG:FPAR REQ,ID=254
    10:38:56.770 -> 146142 TSF:PNG:SEND,TO=0
    10:38:56.770 -> 146168 TSF:CKU:OK
    10:38:56.816 -> 146187 TSF:MSG:GWL OK
    10:38:57.655 -> 147013 TSF:MSG:SEND,0-0-254-254,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    10:38:58.683 -> 148042 TSF:MSG:READ,254-254-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
    10:38:58.730 -> 148105 TSF:MSG:PINGED,ID=254,HP=1
    10:38:58.776 -> 148148 TSF:MSG:SEND,0-0-254-254,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
    10:38:58.869 -> 148226 TSF:MSG:READ,254-254-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    10:38:58.916 -> 148294 TSF:MSG:SEND,0-0-254-254,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    10:38:59.010 -> 148375 TSF:MSG:READ,254-254-0,s=255,c=0,t=17,pt=0,l=11,sg=0:2.4.0-alpha
    10:38:59.058 -> 148450 GWT:TPS:TOPIC=mygateway4-out/254/255/0/0/17,MSG SENT
    10:38:59.151 -> 148515 TSF:MSG:READ,254-254-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
    10:38:59.197 -> 148578 GWT:TPS:TOPIC=mygateway4-out/254/255/3/0/6,MSG SENT
    10:39:00.923 -> 150319 TSF:MSG:READ,254-254-0,s=255,c=3,t=11,pt=0,l=14,sg=0:MockMySensors 
    10:39:01.017 -> 150398 GWT:TPS:TOPIC=mygateway4-out/254/255/3/0/11,MSG SENT
    10:39:01.064 -> 150462 TSF:MSG:READ,254-254-0,s=255,c=3,t=12,pt=0,l=4,sg=0:v0.5
    10:39:01.157 -> 150529 GWT:TPS:TOPIC=mygateway4-out/254/255/3/0/12,MSG SENT
    10:39:01.949 -> 151337 TSF:MSG:READ,254-254-0,s=1,c=0,t=0,pt=0,l=12,sg=0:Outside Door
    10:39:02.044 -> 151410 GWT:TPS:TOPIC=mygateway4-out/254/1/0/0/0,MSG SENT
    10:39:02.091 -> 151471 TSF:MSG:READ,254-254-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
    10:39:02.184 -> 151542 TSF:MSG:SEND,0-0-254-254,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
    10:39:02.699 -> 152055 TSF:MSG:READ,254-254-0,s=255,c=3,t=0,pt=1,l=1,sg=0:83
    


  • @hard-shovel My MQTT broker does not require them. Should I uncomment and leave them blank?



  • @OldSurferDude You should leave them commented if not required.

    I have just tested with a new install on windows of mosquitto with config file for anonymous access and it is working fine with them commented out.

    what do your gateway debug logs look like?



  • @hard-shovel This is what I'm getting (with no nodes connecting to gateway)

    MCO:BGN:INIT GW,CP=RNNGE---,FQ=80,REL=255,VER=2.3.2
    117 TSF:LRT:OK
    133 TSM:INIT
    147 TSF:WUR:MS=0
    170 TSM:INIT:TSP OK
    191 TSM:INIT:GW MODE
    213 TSM:READY:ID=0,PAR=0,DIS=0
    245 MCO:REG:NOT NEEDED
    scandone
    1322 GWT:TIN:CONNECTING...
    2351 GWT:TIN:CONNECTING...
    scandone
    state: 0 -> 2 (b0)
    4097 GWT:TIN:CONNECTING...
    state: 2 -> 3 (0)
    state: 3 -> 5 (10)
    add 0
    aid 1
    cnt
    
    connected with Automation, channel 9
    dhcp client start...
    ip:192.168.1.30,mask:255.255.255.0,gw:192.168.1.193
    4316 GWT:TIN:IP: 192.168.1.30
    4355 GWT:TIN:ETH OK
    4378 MCO:BGN:STP
    4396 MCO:BGN:INIT OK,TSP=1
    4424 TSM:READY:NWD REQ
    4451 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    pm open,type:2 0
    

    And this comes when a node connects:

    197868 TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    197928 TSF:MSG:BC
    197947 TSF:MSG:FPAR REQ,ID=2
    197977 TSF:PNG:SEND,TO=0
    198003 TSF:CKU:OK
    198022 TSF:MSG:GWL OK
    198460 TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
    200006 TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
    200065 TSF:MSG:PINGED,ID=2,HP=1
    200106 TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
    200244 TSF:MSG:READ,2-2-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    200309 TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    200385 TSF:MSG:READ,2-2-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.2
    200456 GWT:TSA:ETH OK
    200481 TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
    200545 GWT:TSA:ETH OK
    202529 TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=15,sg=0:BatMoistHumTemp
    202611 GWT:TSA:ETH OK
    202636 TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=9,sg=0:     0.01
    202710 GWT:TSA:ETH OK
    202885 TSF:MSG:READ,2-2-0,s=0,c=0,t=35,pt=0,l=0,sg=0:
    202948 GWT:TSA:ETH OK
    203141 TSF:MSG:READ,2-2-0,s=1,c=0,t=7,pt=0,l=0,sg=0:
    203203 GWT:TSA:ETH OK
    203396 TSF:MSG:READ,2-2-0,s=2,c=0,t=6,pt=0,l=0,sg=0:
    203458 GWT:TSA:ETH OK
    203651 TSF:MSG:READ,2-2-0,s=3,c=0,t=30,pt=0,l=0,sg=0:
    203713 GWT:TSA:ETH OK
    203925 TSF:MSG:READ,2-2-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
    203992 TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
    204128 TSF:MSG:READ,2-2-0,s=255,c=3,t=0,pt=1,l=1,sg=0:100
    204199 GWT:TSA:ETH OK
    204407 TSF:MSG:READ,2-2-0,s=3,c=1,t=38,pt=7,l=5,sg=0:6.52
    204475 GWT:TSA:ETH OK
    204542 TSF:MSG:READ,2-2-0,s=0,c=1,t=37,pt=2,l=2,sg=0:1023
    204610 GWT:TSA:ETH OK
    


  • Hello have with the gateway constantly disconnects after a few days and I can only reactivate it by resetting on the gateway.

    Have now inserted a separate power supply with a large electrolytic capacitor 5000 µF-let's see....



  • @OldSurferDude You are getting regular GWT:TSA:ETH OK message which i do not and you have no
    MSG SENT lines

    Which MQTT broker are you using?

    my test setup which i hope matches yours is:
    MySensors 2.3.2 & ESP8266 core 2.7.4
    ESP8266 Node MCU with sketch GatewayESP8266MQTTClient
    MY_BAUD_RATE 9600
    MY_MQTT_USER & MQTT_PASSWORD commented out
    MY_CONTROLLER_IP_ADDRESS 192, 168, 1, 195 address of the MQTT broker
    MY_CONTROLLER_URL_ADDRESS "MQTT-TEST-W10" commented out Use IP or URL not Both
    MY_PORT 1883

    MQTT Broker
    Mosquitto 2.0.15 running as a service on a windows 10 machine
    listener 1883 anonymous access
    URL MQTT-TEST-W10

    When connected to the MQTT Broker and receiving messages from a node the gateway shows

    09:48:18.962 -> 718935 TSF:MSG:READ,254-254-0,s=1,c=1,t=16,pt=2,l=2,sg=0:0
    09:48:19.010 -> 718997 GWT:TPS:TOPIC=mygateway5-out/254/1/1/0/16,MSG SENT
    
    09:48:19.104 -> 719059 TSF:MSG:READ,254-254-0,s=1,c=1,t=15,pt=1,l=1,sg=0:1
    09:48:19.149 -> 719121 GWT:TPS:TOPIC=mygateway5-out/254/1/1/0/15,MSG SENT
    
    09:48:19.198 -> 719182 TSF:MSG:READ,254-254-0,s=255,c=3,t=0,pt=1,l=1,sg=0:83
    09:48:19.292 -> 719246 GWT:TPS:TOPIC=mygateway5-out/254/255/3/0/0,MSG SENT
    

    if a message is sent to the broker the gateway shows

    10:03:54.285 -> 1654209 GWT:IMQ:TOPIC=mygateway5-in/254/255/1/0/15, MSG RECEIVED
    10:03:54.331 -> 1654279 TSF:MSG:SEND,0-0-254-254,s=255,c=1,t=15,pt=0,l=1,sg=0,ft=0,st=OK:1
    10:03:54.423 -> 1654358 TSF:MSG:READ,254-254-0,s=1,c=1,t=16,pt=2,l=2,sg=0:1
    10:03:54.471 -> 1654421 GWT:TPS:TOPIC=mygateway5-out/254/1/1/0/16,MSG SENT
    10:03:54.565 -> 1654483 TSF:MSG:READ,254-254-0,s=1,c=1,t=15,pt=1,l=1,sg=0:1
    10:03:54.611 -> 1654546 GWT:TPS:TOPIC=mygateway5-out/254/1/1/0/15,MSG SENT
    


  • @hard-shovel I created a faux nano sensor and used nRF24L01 channel 121 to communicate to the gateway. Here is my NodeMCU ESP8266 code with all comments taken out:

    #define VER 0.4
    #define MY_DEBUG true
    #define MY_BAUD_RATE 9600
    #define MY_RADIO_RF24
    #define MY_RF24_CHANNEL 121
    #define MY_GATEWAY_ESP8266 "Test"
    #define MY_WIFI_SSID "SSID"
    #define MY_WIFI_PASSWORD "pass"
    #define MY_HOSTNAME "ESP8266_GW"
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mysensors-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mysensors-in"
    #define MY_PORT 1883
    #define MY_GATEWAY_MAX_CLIENTS 8
    #define MY_CONTROLLER_IP_ADDRESS 192, 168, 1, 142
    #include <MySensors.h>
    void setup() {Serial.print("ESP8266MySensorsGateway version: ");Serial.println(VER); }
    void presentation(){}
    void loop(){}
    

    On boot, the gateway generates the following debug output:

    60 MCO:BGN:INIT GW,CP=RNNGE---,FQ=80,REL=255,VER=2.3.2
    118 TSF:LRT:OK
    133 TSM:INIT
    147 TSF:WUR:MS=0
    170 TSM:INIT:TSP OK
    191 TSM:INIT:GW MODE
    213 TSM:READY:ID=0,PAR=0,DIS=0
    246 MCO:REG:NOT NEEDED
    scandone
    1322 GWT:TIN:CONNECTING...
    2350 GWT:TIN:CONNECTING...
    scandone
    state: 0 -> 2 (b0)
    4097 GWT:TIN:CONNECTING...
    state: 2 -> 3 (0)
    state: 3 -> 5 (10)
    add 0
    aid 1
    cnt 
    
    connected with Automation, channel 9
    dhcp client start...
    ip:192.168.1.30,mask:255.255.255.0,gw:192.168.1.193
    4316 GWT:TIN:IP: 192.168.1.30
    4354 GWT:TIN:ETH OK
    4376 MCO:BGN:STP
    ESP8266MySensorsGateway version: 0.40
    4394 MCO:BGN:INIT OK,TSP=1
    4463 TSM:READY:NWD REQ
    4490 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    6865 TSF:MSG:READ,2-2-0,s=0,c=1,t=37,pt=2,l=2,sg=0:208
    6933 GWT:TSA:ETH OK
    

    The faux node connects to the gateway indicated by this debug code from the gateway (which is repeated for each "reading" (eg. 204):

    1047590 TSF:MSG:READ,2-2-0,s=0,c=1,t=37,pt=2,l=2,sg=0:204
    1047656 GWT:TSA:ETH OK
    

    Nothing arrives at the MQTT broker. From another machine, I can publish to the broker:

    mosquitto_pub -h 192.168.1.139 -t test/mztake -m "did it arrive?"
    

    and it does arrive at the broker.

    What am I missing?

    OSD


  • Mod

    @OldSurferDude you are (at least) missing #define MY_GATEWAY_MQTT_CLIENT.

    The sketch you are using is instructing MySensors to create an ethernet gateway.

    Example sketch for esp8266 mqtt: https://github.com/mysensors/MySensors/blob/master/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino



  • @mfalkvidd said in ESP8266Wifi Gateway won't connect:

    #define MY_GATEWAY_MQTT_CLIENT

    That was it! Thank you!

    OSD



  • @mfalkvidd Because I see that the example has a presentation() routine with the comment "// Present locally attached sensors here" I made the assumption that the gateway could have local sensors. I described a local sensor

    // local sensor information
    #define MY_NODE_ID 3
    #define CHILD_ID_GATEWAY_FAUX_SENSOR 0
    MyMessage msgFauxSensor(CHILD_ID_GATEWAY_FAUX_SENSOR, V_LEVEL);
    int fauxSensorValue = 0;
    

    and put the data acquisition code in the loop:

    // Send locally attached sensors data here
     send(msgFauxSensor.set(fauxSensorValue++));
     Serial.print("Value sent: ");Serial.println(fauxSensorValue);
     delay(30000);
    

    Lo and Behold! This data was being found on the MQTT broker! Albeit the NODE_ID was not 3 as defined, but 0. This makes sense because the NODE_ID of the gateway is zero.

    Previously, I had my gateway running on an RPi. My question is, can I put a presentation() routine and data acquisition of the gateway running on my RPi?


  • Mod

    delay(30000);

    A delay in the gateway will make the gateway freeze. It will not handle incoming messages (not from the mqtt broker, not for any nodes). Use wait() instead.

    Previously, I had my gateway running on an RPi. My question is, can I put a presentation() routine and data acquisition of the gateway running on my RPi?

    Yes, it should work. The file to edit is https://github.com/mysensors/MySensors/blob/development/examples_linux/mysgw.cpp

    Have you forgotten about https://forum.mysensors.org/post/111806 ?



  • @mfalkvidd Yes, totally forgot about that link you put there. Thanks for reminding me. 🙂


Log in to reply
 

Suggested Topics

  • 3
  • 1
  • 6
  • 1
  • 2
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts