1

Topic: is connected failed: ECONNREFUSED

I've connected esp 01 with my arduino uno according to the diagram.
It was working as expected but after shutting it down and turning it on again, I was able to connect to the WiFi with my smart phone but could not start remotexy GUI controller. It shows an error massage:

Connection error: failed to connect to /192.168.4.1 (port 6377) after 90000ms: isConnected failed: ECONNREFUSED

2

Re: is connected failed: ECONNREFUSED

Similar for me. Same hw but after 1 week i keep it running i cannot connect to my project.

https://i.postimg.cc/4dFTg4Vh/photo5998919301114999692.jpg
https://i.postimg.cc/FH1rBs0M/photo5998919301114999691.jpg

I'll test after easter if i can connect after power off and then turn on the board.

3

Re: is connected failed: ECONNREFUSED

I did another test of my platform (Arduino UNO+esp8266-01) to open my garage. My system's been running since 8 days and i'm able to connect with my phone to the access point like a generic lan without internet obviously, so everything works there isn't an issue with my hw or sw.

Now Remote XY PRO, it fails to connect giving the above issue, but if i power off and then turn it on, now it connects!!!

So i think it is a problem of the app, it needs to be tested with a platform whom is running for several days.

4

Re: is connected failed: ECONNREFUSED

It is problem of board. If the UNO board freezes, the esp continues to work. ESP can accept connections via wifi, but there is no connection with UNO.
UNO may freeze for various reasons.
Try to use new arduino RemoteXY library v.3.1.5

5

Re: is connected failed: ECONNREFUSED

It isn't a freeze of my board, i'm almost sure because the LED turned on when the HC-SR505 detects a movement.

https://i.postimg.cc/63ZZq42x/photo5884326902188061887.jpg


Anyway i'll continue to investigate and yes i could try your beta library.

6

Re: is connected failed: ECONNREFUSED

I'm finding the origin of my issue who makes useless this sw with long period of usage. So before to undestand if it is a hw or sw issue, i'm trying to enable the debug mode on my test platform (mega pro embebbed and esp8266-01), but i think i'm missing something in the loop because i cannot get nothing on the serial monitor:

#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT

#include <RemoteXY.h>

// RemoteXY connection settings 
#define REMOTEXY_SERIAL Serial1
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_WIFI_SSID "relay_led"
#define REMOTEXY_WIFI_PASSWORD ""
#define REMOTEXY_SERVER_PORT 6377

uint32_t lastStatus=0;

// RemoteXY debug
#define REMOTEXY__DEBUGLOG                 
#define REMOTEXY__DEBUGLOG_SERIAL Serial  
#define REMOTEXY__DEBUGLOG_SPEED 115200

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,1,0,26,0,10,202,0,
  2,1,16,22,33,18,1,177,3,94,
  79,110,0,79,70,70,0,65,34,70,
  23,16,16 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t switch_1; // =1 if switch ON and =0 if OFF 

    // output variables
  uint8_t led_g; // =0..255 LED Green brightness 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_SWITCH_1 10


void setup() 
{
Serial.begin(115200);
//Serial1.begin(115200);
  RemoteXY_Init (); 
  
  pinMode (PIN_SWITCH_1, OUTPUT);
  digitalWrite(PIN_SWITCH_1, LOW);
  // TODO you setup code
  
}

void loop() 
{ 
  RemoteXY_Handler ();
  
  digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
  
  // TODO you loop code
  // use the RemoteXY structure for data transfer
  // do not call delay() 
if(RemoteXY.switch_1==HIGH)
{
RemoteXY.led_g=255;
}
else {RemoteXY.led_g=0;}
//Serial1.print(Serial.readString());

while (millis() - lastStatus <= 500) // aspetta 0,5 secondi per terminare ma chiama il gestore RemoteXY
{RemoteXY_Handler ();}

}

So should i add a Serial.println("something") in the loop?
Thanks

7

Re: is connected failed: ECONNREFUSED

Add REMOTEXY__DEBUGLOG definition before including RemoteXY.h

// RemoteXY debug
#define REMOTEXY__DEBUGLOG                 
#define REMOTEXY__DEBUGLOG_SERIAL Serial  
#define REMOTEXY__DEBUGLOG_SPEED 115200

#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT

#include <RemoteXY.h>

8 (edited by salsedine 2021-05-20 18:11:55)

Re: is connected failed: ECONNREFUSED

Some little steps to reach my target. So i'm testing, at home, my mega pro embebbed the debug and after i'll move everything to the UNO whom is installed in my garage.

1) setted the new baud rate:

AT

OK
AT+CIOBAUD=19200

ERROR
AT+UART_DEF=19200,8,1,0,3

OK

2) loaded the sample code:

// RemoteXY debug
#define REMOTEXY__DEBUGLOG                 
#define REMOTEXY__DEBUGLOG_SERIAL Serial  
#define REMOTEXY__DEBUGLOG_SPEED 115200

//#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT
#define REMOTEXY_MODE__ESP8266_SOFTSERIAL_POINT
#include <SoftwareSerial.h>
#include <RemoteXY.h>

#define REMOTEXY_SERIAL_RX 2                 
#define REMOTEXY_SERIAL_TX 3                
#define REMOTEXY_SERIAL_SPEED 19200

// RemoteXY connection settings 
/*#define REMOTEXY_SERIAL Serial1
#define REMOTEXY_SERIAL_SPEED 115200*/
#define REMOTEXY_WIFI_SSID "relay_led"
#define REMOTEXY_WIFI_PASSWORD ""
#define REMOTEXY_SERVER_PORT 6377

uint32_t lastStatus=0;



// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,1,0,26,0,10,202,0,
  2,1,16,22,33,18,1,177,3,94,
  79,110,0,79,70,70,0,65,34,70,
  23,16,16 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t switch_1; // =1 if switch ON and =0 if OFF 

    // output variables
  uint8_t led_g; // =0..255 LED Green brightness 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_SWITCH_1 10


void setup() 
{
Serial.begin(115200);
//Serial1.begin(115200);
  RemoteXY_Init (); 
  
  pinMode (PIN_SWITCH_1, OUTPUT);
  digitalWrite(PIN_SWITCH_1, LOW);
  // TODO you setup code
  
}

void loop() 
{ 
  RemoteXY_Handler ();
  
  digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
  
  // TODO you loop code
  // use the RemoteXY structure for data transfer
  // do not call delay() 
if(RemoteXY.switch_1==HIGH)
{
RemoteXY.led_g=255;
}
else {RemoteXY.led_g=0;}
//Serial1.print(Serial.readString());

while (millis() - lastStatus <= 500) // aspetta 0,5 secondi per terminare ma chiama il gestore RemoteXY
{RemoteXY_Handler ();}

}

and this is the output:

[    0.000] Debug log started
[    0.000] Init software serial 19200 baud
[    0.001] pin RX=2; pin TX=3
[    0.003] RemoteXY started
[    1.005] -> AT
[    2.008] -> AT
[    3.011] -> AT
[    4.014] -> AT
[    5.017] -> AT
[    6.020] -> AT
[    7.023] -> AT
[    8.026] -> AT
[    9.029] -> AT
[   10.031] Мodule does not respond to AT commands
[   10.032] -> AT
[   11.036] -> AT
[   12.039] -> AT
[   13.042] -> AT
[   14.045] -> AT
[   15.048] -> AT
[   16.051] -> AT
[   17.054] -> AT
[   18.057] -> AT
[   19.060] -> AT
[   20.062] Мodule does not respond to AT commands
[   20.063] -> AT
[   21.067] -> AT
[   22.070] -> AT
[   23.073] -> AT
[   24.076] -> AT
[   25.079] -> AT
[   26.082] -> AT

Now the problem is, i can connect to the AP but the app fails with the damn econnrefused. Connections between mega and esp8266 seem correct:

D2->GPIO1(TX)
D3->GPIO3(RX)

and the others to 2x3.3V and 1xground.
Nothing is notified during the connection to the AP and while the app tries to connect. I could test using the 2th serial hw port of my mega, but not with the UNO.

https://i.postimg.cc/hGMgzcK1/photo5850311572952561905.jpg

9

Re: is connected failed: ECONNREFUSED

Обратите внимание на наличие достаточной оперативной памяти ОЗУ. Мои проекты на Arduino UNO + esp8266-01 требовали не менее 700-800 байт свободной памяти

10

Re: is connected failed: ECONNREFUSED

Мне кажется вот здесь ошибка:
Скорость передачи:
AT+UART_DEF=19200,8,1,0,3

Попробуйте
AT+UART_DEF=19200,8,1,0,0

11

Re: is connected failed: ECONNREFUSED

salsedine wrote:

and this is the output:

[    0.000] Debug log started
[    0.000] Init software serial 19200 baud
[    0.001] pin RX=2; pin TX=3
[    0.003] RemoteXY started
[    1.005] -> AT
[    2.008] -> AT
[    3.011] -> AT
[    4.014] -> AT
[    5.017] -> AT
[    6.020] -> AT
[    7.023] -> AT
[    8.026] -> AT
[    9.029] -> AT
[   10.031] Мodule does not respond to AT commands
[   10.032] -> AT
[   11.036] -> AT
[   12.039] -> AT
[   13.042] -> AT
[   14.045] -> AT
[   15.048] -> AT
[   16.051] -> AT
[   17.054] -> AT
[   18.057] -> AT
[   19.060] -> AT
[   20.062] Мodule does not respond to AT commands
[   20.063] -> AT
[   21.067] -> AT
[   22.070] -> AT
[   23.073] -> AT
[   24.076] -> AT
[   25.079] -> AT
[   26.082] -> AT

ESP does not answer. Default speed of ESP8266 is 115200. If you want to use another speed you must set this speed in ESP by default. In the previous post they wrote how to do it. Use AT command AT+UART_DEF=19200,8,1,0,3 for ESP8266

12

Re: is connected failed: ECONNREFUSED

Поясните режим: Use AT command AT+UART_DEF=19200,8,1,0,3 for ESP8266-01

AT+UART_DEF – дефолтная настройка UART. Эта команда устанавливает настройки UART, а затем сохраняет их на FLASH. Будучи записанными, эти настройки становятся настройками по умолчанию (в том числе и скорость передачи данных, т.е. baudrate).

Написание: AT+UART_DEF=<скорость в бодах>, <биты данных>, <стоп-биты>, <контроль четности>, <контроль потока>
Ответ: OK
Параметры:
<скорость в бодах>
В диапазоне от 110 до 115200*40 (4,608 мегабод)
<биты данных>
5 — 5 битов данных
6 — 6 битов данных
7 — 7 битов данных
8 — 8 битов данных
<стоп-биты>
1 — 1 стоп-бит
2 — 1,5 стоп-бита
3 — 2 стоп-бита
<контроль четности>
0 — бит контроля четности не посылается
1 — бит контроля четности нечетный
2 — бит контроля четности четный
<контроль потока>
0 — контроль потока выключен
1 — включен RTS
2 — включен CTS
3 — включены RTS и CTS

Тем самым включен контроль потока по RTS и CTS
Но физически к этим шинам в модуле ESP8266-01 ничего не подключено!
Или я чего то не понимаю

13

Re: is connected failed: ECONNREFUSED

bukinay1 wrote:

Обратите внимание на наличие достаточной оперативной памяти ОЗУ. Мои проекты на Arduino UNO + esp8266-01 требовали не менее 700-800 байт свободной памяти


Yes, i think i'm not using all the memory available:

Sketch uses 14502 bytes (44%) of program storage space. Maximum is 32256 bytes.
Global variables use 973 bytes (47%) of dynamic memory, leaving 1075 bytes for local variables. Maximum is 2048 bytes

14

Re: is connected failed: ECONNREFUSED

bukinay1 wrote:

Мне кажется вот здесь ошибка:
Скорость передачи:
AT+UART_DEF=19200,8,1,0,3

Попробуйте
AT+UART_DEF=19200,8,1,0,0

I tested with 19200,8,1,0,0 but i get always the same problem so i studied all the variabiles between commas and remebering the old 56k modem i enabled the hw control mode flow "3".

15

Re: is connected failed: ECONNREFUSED

Между Arduino и ESP-01 расстояние 4 метра.
Временно, попробуйте уменьшить до 0.1-0.2 метра и скорость передачи до 9600 бод. Какой результат?

16

Re: is connected failed: ECONNREFUSED

bukinay1 wrote:

Между Arduino и ESP-01 расстояние 4 метра.
Временно, попробуйте уменьшить до 0.1-0.2 метра и скорость передачи до 9600 бод. Какой результат?

That will be my next test, to connect like it was in the past <10cm.

17

Re: is connected failed: ECONNREFUSED

remotexy wrote:
salsedine wrote:

and this is the output:

[    0.000] Debug log started
[    0.000] Init software serial 19200 baud
[    0.001] pin RX=2; pin TX=3
[    0.003] RemoteXY started
[    1.005] -> AT
[    2.008] -> AT
[    3.011] -> AT
[    4.014] -> AT
[    5.017] -> AT
[    6.020] -> AT
[    7.023] -> AT
[    8.026] -> AT
[    9.029] -> AT
[   10.031] Мodule does not respond to AT commands
[   10.032] -> AT
[   11.036] -> AT
[   12.039] -> AT
[   13.042] -> AT
[   14.045] -> AT
[   15.048] -> AT
[   16.051] -> AT
[   17.054] -> AT
[   18.057] -> AT
[   19.060] -> AT
[   20.062] Мodule does not respond to AT commands
[   20.063] -> AT
[   21.067] -> AT
[   22.070] -> AT
[   23.073] -> AT
[   24.076] -> AT
[   25.079] -> AT
[   26.082] -> AT

ESP does not answer. Default speed of ESP8266 is 115200. If you want to use another speed you must set this speed in ESP by default. In the previous post they wrote how to do it. Use AT command AT+UART_DEF=19200,8,1,0,3 for ESP8266

I'll test tomorrow with calm, now i can't launch "AT+UART_DEF?"

In my post i showed that i successfully setted the baudrate, in fact i got OK.

18 (edited by bukinay1 2021-05-21 18:43:06)

Re: is connected failed: ECONNREFUSED

Выше, в своем посту вы привели скетч, для Arduino MEGA. Приведите полный скетч для Arduino UNO

Например:

while (millis() - lastStatus <= 500) // aspetta 0,5 secondi per terminare ma chiama il gestore RemoteXY
{RemoteXY_Handler ();}

Для чего ???

19

Re: is connected failed: ECONNREFUSED

Finally everything runs smooth. The cable between the esp and UNO now is long only 1 meter. it is not only a hw issue but sw too. I had a confirm from this https://www.forward.com.au/pfod/Arduino … tml#reboot, the dev cleared my dubts.

So i decided to replace the RemoteXY with a sw found over the web where UNO reads the serial flow and found keywords to turn on and off pins. I just added some AT command to reset the esp and restart the AP every 24 hours....and surprise...... after 7 days it works, using a web page or an app (i used MIT app inventor) made by me.

So a suggestion for devs: a big improvement could be to add a function to reset the board when the user need it. It is absolutely necessary for a 24h working platform.

20

Re: is connected failed: ECONNREFUSED

You can try next code for restart ESP every 24 hours. But how can we determine that the ESP8266 is no longer working?

//#define REMOTEXY__DEBUGLOG 

#include <RemoteXY.h>

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t const PROGMEM RemoteXY_CONF_PROGMEM[] =
  { 255,1,0,1,0,27,0,10,13,2,
  1,0,9,9,46,46,6,7,50,50,
  2,31,88,0,65,4,62,16,31,31,
  14,62,35,35 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t button_1; // =1 if button pressed, else =0 

    // output variables
  uint8_t led_1_r; // =0..255 LED Red brightness 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)


CRemoteXY *remotexy;
CRemoteXYComm_ESP8266Point * esp;

void setup() 
{
  esp = new CRemoteXYComm_ESP8266Point (
    new CRemoteXYStream_HardSerial (
      &Serial,          // use Serial1 (Serial2, Serial3) for Arduino Mega board
      115200
    ),
    "myRemoteXY",       // REMOTEXY_WIFI_SSID
    "12345678"        // REMOTEXY_WIFI_PASSWORD
  );
  
  remotexy = new CRemoteXY (
    RemoteXY_CONF_PROGMEM, 
    &RemoteXY, 
    "", 
    new CRemoteXYConnectionServer (
      esp,        
      6377                  // REMOTEXY_SERVER_PORT
    )
  ); 

}

uint32_t timer = 0;

void loop() 
{ 
  remotexy->handler ();
  if (millis() - timer > 3600000 * 24)  {
    timer = millis();
    esp->sendATCommand ("AT+RST",NULL);
  }
}

21

Re: is connected failed: ECONNREFUSED

remotexy wrote:

...But how can we determine that the ESP8266 is no longer working?

We cannot know when it will stop but it is safe to reboot every 12/24/..h to keep the esp up and running.
Probably you'll get the following cases:

  • the famous "econnrefused" issue while the AP is active;

  • the AP is off.

So it is time to reboot wink.

I'm not excluding that the "econnrefused" issue is due of a not enought signal strenght so it is good if it is minus of |-70|dBm.