[SOLVED] ESP8266 WiFi Gateway trouble - pm open, type:2 0
-
Hello,
Help needed. I am trying to build a WiFi gateway using NodeMCU. Actually I built it a year ago and it was working fine. But then this hole projekt was suspended, and brought to life again now. But I am not able to get the GW wroking.
I am using Arduino IDE 1.8.5 and have tried with both MySensors library 2.0.0 and 2.1.1. Without any differens.This is my code:
// Enable debug prints to serial monitor #define MY_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 // Enables and select radio type (if attached) #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_GATEWAY_ESP8266 #define MY_ESP8266_SSID "wifi_n2@home" #define MY_ESP8266_PASSWORD "XXXXXXX" // Enable UDP communication //#define MY_USE_UDP // Set the hostname for the WiFi Client. This is the hostname // it will pass to the DHCP server if not static. #define MY_ESP8266_HOSTNAME "MySensor_GW" // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) //#define MY_IP_ADDRESS 192,168,2,50 // If using static ip you need to define Gateway and Subnet address as well //#define MY_IP_GATEWAY_ADDRESS 192,168,2,1 //#define MY_IP_SUBNET_ADDRESS 255,255,255,0 // The port to keep open on node server mode #define MY_PORT 5003 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68 // Enable Inclusion mode button on gateway //#define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) //#define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button //#define MY_INCLUSION_MODE_BUTTON_PIN 3 // Set blinking period //#define MY_DEFAULT_LED_BLINK_PERIOD 10 // Flash leds on rx/tx/err // Led pins used if blinking feature is enabled above // Internal LED is PIN 16 //#define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED = 16 #if defined(MY_USE_UDP) #include <WiFiUdp.h> #endif #include <ESP8266WiFi.h> #include <MySensors.h> void setup() { } void presentation() { // Present locally attached sensors here } void loop() { // Send locally attached sensors data here }
And here is the serial output:
0;255;3;0;9;Starting gateway (RNNGE-, 2.0.0) 0;255;3;0;9;TSM:INIT 0;255;3;0;9;TSM:RADIO:OK 0;255;3;0;9;TSM:GW MODE scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 4 cnt connected with wifi_n2@home, channel 6 dhcp client start... chg_B1:-40 0;255;3;0;9;TSM:READY f r-40, scandone ...................pm open,type:2 0 ...................................................................
No matter what I tries in the code (static/non static IP) it is the same output.
Any ideas about what is wrong?
-
@Strixx I can't see anything wrong. The serial output looks fine.
Could you describe what you expected to see?
-
I don't know what I except to see. Don't remember how it looked a year ago. But at least an assigned IP (I have seen this output in the forum searching this)
I can't ping it. I can't telnet. I can't see it in my router. And my controller can't find it.
Tried as I wrote with both static and dynamic IP.
-
@Strixx yes, you are right. After DHCP the output should say something like this:
connected with Mr-IoT.com, channel 5 dhcp client start... .....ip:192.168.1.204,mask:255.255.255.0,gw:192.168.1.1 .IP: 192.168.1.204
Could you comment out #define MY_RADIO_NRF24 and disconnect the nrf to see if the problem is related to radio?
-
@mfalkvidd I've tried disconnected the radio and comment out the radio. Still the same.
I googled the phrase "pm open,type:2 0" and all hits seemed to refer to problems. So I assumed it was some kind of error message. Since I can't find any documentation of the initial output in the serial interface, and I haven't got the time to go through all the source code.
I started building the gw a year a go, and then it worked. Then I put it on a shelf waiting to get the time to build some sensors. Two weeks ago I started with this project again. And the only thing changed is I now have a new computer. Same router (but uodated firmware), same server, same gateway (Domoticz).
So I thought it was the usb port not being able to power the Node MCU. To day I plugged in a powered usb hub, but that made no difference. Then tried recompiling with the latest MySensors library, then "down grading". Still the same.
-
@Strixx said in ESP8266 WiFi Gateway trouble - pm open, type:2 0:
I googled the phrase "pm open,type:2 0" and all hits seemed to refer to problems. So I assumed it was some kind of error message. Since I can't find any documentation of the initial output in the serial interface, and I haven't got the time to go through all the source code.
I doubt the search results mean that "pm open,type:2 0" indicates a problem. People don't usually post detailed logs when their projects are successful, they post them when they have trouble.
This is the output of my esp8266 when commenting the nrf define. I also changed the wifi ssid and password, but everything else is exactly like your post above (I copied the code you posted). Result:
0;255;3;0;9;MCO:BGN:INIT GW,CP=R-NGE--,VER=2.1.1 scandone f 0, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 1 cnt connected with Mr-IoT.com, channel 5 dhcp client start... .ip:192.168.1.204,mask:255.255.255.0,gw:192.168.1.1 .IP: 192.168.1.204 0;255;3;0;9;MCO:BGN:STP 0;255;3;0;9;MCO:REG:NOT NEEDED 0;255;3;0;9;MCO:BGN:INIT OK,TSP=NA pm open,type:2 0
it responds to ping:
$ ping 192.168.1.204 Pinging 192.168.1.204 with 32 bytes of data: Reply from 192.168.1.204: bytes=32 time=75ms TTL=128 Reply from 192.168.1.204: bytes=32 time=95ms TTL=128 Reply from 192.168.1.204: bytes=32 time=16ms TTL=128
and netcat:
$ nc 192.168.1.204 5003 0;255;3;0;14;Gateway startup complete. 0;255;0;0;17;2.1.1
The connection is also verified in the Arduino IDE Serial Monitor:
0;255;3;0;9;Client 0 connected
Could you post the full output when doing the same on your gateway?
-
Well off course you are right about not posting output when it works. But then again Google wont find many answers on that phrase.
Any way. Last night I updated uupdated to MySensors library 2.1.1, and tried again, without any luck. I did notice that I got some errors about invalid library in the IDE after switching to 2.1.1. But there was no luck, still no assigned IP. Tried to change to a different AP. Nothing
So this morning I gave it a new go and change the code back to static IP, and now it is working.
connected with wifi_2@home, channel 11 ip:192.168.2.50,mask:255.255.255.0,gw:192.168.2.1 .IP: 192.168.2.50 0;255;3;0;9;MCO:BGN:STP 0;255;3;0;9;MCO:REG:NOT NEEDED 0;255;3;0;9;MCO:BGN:INIT OK,TSP=NA pm open,type:2 0 0;255;3;0;9;Client 0 connected 0;255;3;0;9;Client 0: 0;0;3;0;2
So I cant find any pattern in this. I will do some more testing during the day to see if I can find what went wrong before..
-
Why don't you give a try to mysensors library 2.2?
-
Ok... Sorry for bothering you... I have been testing several things now for an hour. And I found what was causing the errors, and it was my Asus router. A year ago when started this project apparently set up an dhcp rule for the gateway binding it to a certain ip when connecting. Some how this is the cause for not getting any IP at all.
Because now, when removing this rule, I am able to connect and receive IP adress in dynamic mode on.
It is strange because I have allot of other things that is getting manually assigned IP from the DHCP in the router, and they all works. But I guess this is to hard for me to find why the gateway is not working with this settings in the router..
Now I will get back to testing inclusion mode and traffic leds on the NodeMCU wifi gateway.
-
That's odd as I use dhcp reservations too without issues
-
It for shore is. And what is even more strange is that adding a new manually assigned IP now is working.
Can't explain it. The router is a Asus RT-AC66U.