cesanta / mDash

Arduino / ESP-IDF library for mdash.net IoT service
https://mdash.net
Other
34 stars 17 forks source link

Not able to connect Mdash on ESP32 with Ethernet W5500 #27

Open Thermelgy-Repo opened 2 months ago

Thermelgy-Repo commented 2 months ago

Dear @cpq @novlean ,

Thankq so much for this library. Hi, I have used the Mdash with WiFi & PPP in ESP32 Arduino, it is working perfectly. Recently I have integrated with Ethernet W5500. The Ethernet connection is working with MQTT PubSub module, but not with the Mdash. It is not able to connect. Kindly help me on the integration of Mdash with Ethernet.

Code:

void Com::Ethernet_Reconnect(){

  byte Eth_link = Ethernet.linkStatus();

  if(Eth_link == 1){ // If link is connected

    if(Eth_flg == 0){ // If not connected

      uint8_t mac[6];  
      esp_read_mac(mac, ESP_MAC_WIFI_STA);

      Serial.print("\n Ethernet Mac Address : ");
      Mac_Disp(mac);

      Serial.print("\n Ethernet Connecting..");

      if (Ethernet.begin(mac) == 0) {
        Serial.println("Failed to configure Ethernet using DHCP");
        Eth_flg = 0;
          // You can try a static IP if DHCP fails.
          // Ethernet.begin(mac, ip);
      }

      else{
          Serial.print("\n DHCP comfigured Successfully");
          Eth_flg = 1;
      }
    }
  }

  else{
    Serial.print("\n Link is not connected");
    Eth_flg = 0;
  }
}

Com COM;
    OTA OT;

    WiFiClient *Wifi;
    EthernetClient *EthClient;

    COM.WiFi_Connect("Service", "12345678", 10000); // For 10 sec, timeout    
    COM.WiFi_Range(); // Wifi Range Display
/*
    Wifi = new WiFiClient();
    COM.MQTT_SetClient(*Wifi); // Pubsub default as Wifi Client
*/

    COM.Ethernet_init(LAN_cs);
    COM.Ethernet_Reconnect();
    EthClient = new EthernetClient();
    COM.MQTT_SetClient(*EthClient); // Pubsub default as Wifi Client

    OT.Mdash_Begin("8bHnIEYfB3AlzrTVMoWeTQ");

    COM.TCP_Connect("broker.hivemq.com", 1883); // Wifi based TCP connect

    while(1){

        COM.MQTT_Connect("Therm1");

        //COM.CheckIP_Reconnect("Therm1", "NBST1");

        uint8_t Pub_stat = COM.MQTT_Publish("thermelgy", "{Hello}");

        if (Pub_stat == 1)
            Serial.printf("Successfully sent to cloud\n");

        else
            Serial.println("\n Failed sent to Cloud");

        delay(10000);
    }
}

Debug log:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13192
load:0x40080400,len:3028
entry 0x400805e4
E (425) esp_core_dump_flash: No core d3f
�partition found!
E (425) esp_core_dump_flash: No core dump partition found!
[     7][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[   459][I][esp32-hal-psram.c:96] psramInit(): PSRAM enabled
Connecting to: Service
[  2495][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 0 - WIFI_READY
[  2591][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[  2589][V][WiFiGeneric.cpp:340] _arduino_event_cb(): STA Started
[  2596][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 2 - STA_START
----[  5013][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[  5013][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[  5021][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[  5028][D][WiFiGeneric.cpp:1077] _eventCallback(): WiFi Reconnect Running
[  5036][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
-----[  7458][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[  7458][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[  7466][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[  7473][D][WiFiGeneric.cpp:1081] _eventCallback(): WiFi AutoReconnect Running
[  7481][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
-----[  9903][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[  9904][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[  9911][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[  9918][D][WiFiGeneric.cpp:1081] _eventCallback(): WiFi AutoReconnect Running
[  9926][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
-----[ 12348][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[ 12349][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 12356][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[ 12363][D][WiFiGeneric.cpp:1081] _eventCallback(): WiFi AutoReconnect Running
[ 12372][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
-
Failed on WiFi connection: Timeout
MAC address: 78:21:84:92:8D:24
WiFi range: 0 dBm

 Ethernet Mac Address : 78:21:84:92:8D:24
 Ethernet Connecting..
 DHCP comfigured Successfully37f3 2 mDash.c:117:mount_fs             FS -> /spiffs: 0
37fb 2 mDash.c:810:doinit               Initialised, id
Re-attempting to connect
382f 1 mongoose.c:406:mg_error          2 0x30 DNS send
3831 1 mongoose.c:406:mg_error          1 0xffffffff DNS error
Successfully sent to cloud
3c2e 1 mongoose.c:406:mg_error          4 0x30 DNS send
3c2f 1 mongoose.c:406:mg_error          3 0xffffffff DNS error
402c 1 mongoose.c:406:mg_error          6 0x30 DNS send
402d 1 mongoose.c:406:mg_error          5 0xffffffff DNS error
[ 17248][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[ 17249][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 17256][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[ 17263][D][WiFiGeneric.cpp:1081] _eventCallback(): WiFi AutoReconnect Running
[ 17271][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
43f7 1 mongoose.c:406:mg_error          8 0x30 DNS send
43f8 1 mongoose.c:406:mg_error          7 0xffffffff DNS error
47f5 1 mongoose.c:406:mg_error          10 0x30 DNS send
47f6 1 mongoose.c:406:mg_error          9 0xffffffff DNS error
4bc0 1 mongoose.c:406:mg_error          12 0x30 DNS send
4bc1 1 mongoose.c:406:mg_error          11 0xffffffff DNS error
[ 19694][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[ 19695][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 19702][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[ 19709][D][WiFiGeneric.cpp:1081] _eventCallback(): WiFi AutoReconnect Running
[ 19718][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
4fbe 1 mongoose.c:406:mg_error          14 0x30 DNS send
4fbf 1 mongoose.c:406:mg_error          13 0xffffffff DNS error
5389 1 mongoose.c:406:mg_error          16 0x30 DNS send
538a 1 mongoose.c:406:mg_error          15 0xffffffff DNS error
[ 22140][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[ 22141][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 22148][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[ 22155][D][WiFiGeneric.cpp:1081] _eventCallback(): WiFi AutoReconnect Running
[ 22164][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
5787 1 mongoose.c:406:mg_error          18 0x30 DNS send
5788 1 mongoose.c:406:mg_error          17 0xffffffff DNS error
5b85 1 mongoose.c:406:mg_error          20 0x30 DNS send
5b86 1 mongoose.c:406:mg_error          19 0xffffffff DNS error
5f50 1 mongoose.c:406:mg_error          22 0x30 DNS send
5f51 1 mongoose.c:406:mg_error          21 0xffffffff DNS error
[ 24587][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[ 24587][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 24595][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[ 24602][D][WiFiGeneric.cpp:1081] _eventCallback(): WiFi AutoReconnect Running
[ 24610][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
Connected to Therm1
Successfully sent to cloud
634e 1 mongoose.c:406:mg_error          24 0x30 DNS send
634f 1 mongoose.c:406:mg_error          23 0xffffffff DNS error
6719 1 mongoose.c:406:mg_error          26 0x30 DNS send
671a 1 mongoose.c:406:mg_error          25 0xffffffff DNS error
[ 27033][V][WiFiGeneric.cpp:362] _arduino_event_cb(): STA Disconnected: SSID: Service, BSSID: 00:00:00:00:00:00, Reason: 201
[ 27034][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 27041][W][WiFiGeneric.cpp:1057] _eventCallback(): Reason: 201 - NO_AP_FOUND
[ 27048][D][WiFiGeneric.cpp:1081] _eventCallback(): WiFi AutoReconnect Running
[ 27056][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
6b17 1 mongoose.c:406:mg_error          28 0x30 DNS send
6b18 1 mongoose.c:406:mg_error          27 0xffffffff DNS error
6ee2 1 mongoose.c:406:mg_error          30 0x30 DNS send
6ee3 1 mongoose.c:406:mg_error          29 0xffffffff DNS error
72e0 1 mongoose.c:406:mg_error          32 0x30 DNS send
72e1 1 mongoose.c:406:mg_error          31 0xffffffff DNS error

PlatformIO .ini file:

[env:esp32dev]
platform = espressif32@6.3.1
board = esp32dev
framework = arduino
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
lib_deps = 
knolleary/PubSubClient@2.8.0
https://github.com/Thermelgy-Repo/mDash.git#V1.2.17X3
ethernet@2.0.2
build_flags = 
    -Isdkconfig
    -DLOG_LEVEL=LOG_LEVEL_VERBOSE
    -DCORE_DEBUG_LEVEL=5