ESP-01 module is resetting again and again!!!!

ashok.askalsoft
Posts: 4
Joined: Tue Dec 19, 2017 3:49 pm

ESP-01 module is resetting again and again!!!!

Postby ashok.askalsoft » Tue Dec 26, 2017 3:38 pm

Hello,
I'm trying to establish a TCP server but the module is being reset automatically after few seconds.
I'm getting these logs in UART.
ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x3ffe8000, len 876, room 16
tail 12
chksum 0x07
ho 0 tail 12 room 4
load 0x3ffe8370, len 624, room 12
tail 4
chksum 0x87
load 0x40100000, len 28528, room 4
tail 12
chksum 0x84
csum 0x84



This is my code :

Code: Select all

#include <ets_sys.h>
#include <osapi.h>
#include <gpio.h>
#include <os_type.h>
#include <user_interface.h>
#include <espmissingincludes.h>
#include <espconn.h>
#include <mem.h>

LOCAL struct espconn esp_conn;
LOCAL esp_tcp esptcp;

/*static os_timer_t s_Timer;
int s_Tick = 0;

void TimerFunction(void *arg)
{
   
   s_Tick++;
   
   if(GPIO_REG_READ(GPIO_OUT_ADDRESS) & BIT2)
   {
      gpio_output_set(0, BIT2, BIT2, 0);
   }
   else
   {
      gpio_output_set(BIT2, 0, BIT2, 0);
   }
   os_timer_disarm(&s_Timer);
}

void blink(int x)
{
   int i;
   for (i = 0; i < (x * 2); i++)
   {
      os_timer_setfn(&s_Timer, TimerFunction, NULL);
      os_timer_arm(&s_Timer, 300, 0);
   }
}*/

LOCAL void ICACHE_FLASH_ATTR tcp_server_sent_cb(void *arg)
{
   os_printf("\nSent Successfuly");   
}
 
 

LOCAL void ICACHE_FLASH_ATTR tcp_server_recv_cb(void *arg, char *pusrdata, unsigned short length)
{
   os_printf("\nRecieved Data : %s", pusrdata);
   char *data = "ON";
   int x = os_strncmp(pusrdata, data, os_strlen(data));
   os_printf("\nX : %d", x);
   if (x == 0)
      os_printf("\nDevice is ON");
   else
   {
      os_printf("\nWrong Data Recieved!!!!");
      //blink(1);
   }
   
}
 

LOCAL void ICACHE_FLASH_ATTR tcp_server_discon_cb(void *arg)
{
   os_printf("\nServer Disconnected");
}
 

LOCAL void ICACHE_FLASH_ATTR tcp_server_recon_cb(void *arg, sint8 err)
{
   os_printf("\nServer Connection Failed!! Re-connecting");
}
 
 
LOCAL void ICACHE_FLASH_ATTR tcp_server_connect(void *arg)
{
   os_printf("\nA Device Connected to Server");
   //blink(1);
   struct espconn *pesp_conn = arg;
 
   espconn_regist_recvcb(pesp_conn, tcp_server_recv_cb);
   espconn_regist_reconcb(pesp_conn, tcp_server_recon_cb);
   espconn_regist_disconcb(pesp_conn, tcp_server_discon_cb);
   espconn_regist_sentcb(pesp_conn, tcp_server_sent_cb);
}
 
void ICACHE_FLASH_ATTR user_tcpserver_init()
{
   const char tcp_local_ip[4] = { 192, 168, 123, 101 };
   esp_conn.type = ESPCONN_TCP;
   esp_conn.state = ESPCONN_NONE;
   esp_conn.proto.tcp = &esptcp;
   esp_conn.proto.tcp->local_port = 8881;
   os_memcpy(esp_conn.proto.tcp->local_ip, tcp_local_ip, 4);
   espconn_regist_connectcb(&esp_conn, tcp_server_connect);
   espconn_accept(&esp_conn);
   os_printf("\nTCP Server Established");
}

void ICACHE_FLASH_ATTR user_set_softap_config(void)
{
   struct softap_config config;

   wifi_softap_get_config(&config);
   
   os_memset(config.ssid, 0, 32);
   os_memset(config.password, 0, 64);
   os_memcpy(config.ssid, "ESP8266", 7);
   os_memcpy(config.password, "12345678", 8);
   config.authmode = AUTH_WPA_WPA2_PSK;
   config.ssid_len = 7;
   config.beacon_interval = 100;
   config.max_connection = 4;

   wifi_softap_set_config(&config);
   os_printf("\nSoftAP Configured");
   
}


void user_init(void)

   //system_soft_wdt_stop();
   os_printf("\nSystem Started\n");
   gpio_init();
   PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
   gpio_output_set(BIT2, 0, BIT2, 0);
   //blink(1);
   if(wifi_get_opmode() != SOFTAP_MODE)
   {
      wifi_set_opmode(SOFTAP_MODE);
      system_restart();
   }
   os_printf("\nWifi OPMODE : SOFTAP");
   user_set_softap_config();
   user_tcpserver_init();
}


Please Help me out.

Thankyou

Ragards
Ashok Vaishnav

Her Majesty
Posts: 283
Joined: Mon Oct 27, 2014 11:09 am

Re: ESP-01 module is resetting again and again!!!!

Postby Her Majesty » Tue Dec 26, 2017 4:11 pm

There is an example may help you. http://bbs.espressif.com/viewtopic.php?f=31&t=763

ashok.askalsoft
Posts: 4
Joined: Tue Dec 19, 2017 3:49 pm

Re: ESP-01 module is resetting again and again!!!!

Postby ashok.askalsoft » Tue Dec 26, 2017 5:22 pm

Hello Her Majesty,
Thanks for your kind help. :)

But I had written my code with reference to the same code in the link you gave me. I'm able to run my code on NodeMCU board but the same code is not running on ESP-01 or any other ESP8266 modules. It's again and again resetting automatically.

Please suggest me any solution regarding my issue. :(
Thankyou

Ragards
Ashok Vaishnav

YimingLi
Posts: 56
Joined: Sun May 03, 2015 5:36 pm

Re: ESP-01 module is resetting again and again!!!!

Postby YimingLi » Mon Jan 08, 2018 4:28 pm

ashok.askalsoft wrote:Hello Her Majesty,
Thanks for your kind help. :)

But I had written my code with reference to the same code in the link you gave me. I'm able to run my code on NodeMCU board but the same code is not running on ESP-01 or any other ESP8266 modules. It's again and again resetting automatically.

Please suggest me any solution regarding my issue. :(
Thankyou

Ragards
Ashok Vaishnav


Hi,

rst cause : 4 is a Hardware WDT reset.

Hope it would be helpful.

Who is online

Users browsing this forum: No registered users and 8 guests