Page 1 of 1

Unable to connect AWS iot Shadow Thing with SIM800!....

Posted: Thu Nov 19, 2020 3:01 pm
by Tahir Shaik
Hi All,

My ESP32 is unable to connect to AWS IoT shadow thing with SIM800,
I'm getting the following output on console.

Code: Select all

I (0) cpu_start: App cpu up.
I (397) cpu_start: Pro cpu start user code
I (397) cpu_start: Application information:
I (397) cpu_start: Project name:     BookWater
I (402) cpu_start: App version:      c1611ab-dirty
I (408) cpu_start: Compile time:     Nov 19 2020 20:15:34
I (414) cpu_start: ELF file SHA256:  55ecbb3f9f85b55e...
I (420) cpu_start: ESP-IDF:          v4.3-dev-907-g6c17e3a64-dirty
I (427) heap_init: Initializing. RAM available for dynamic allocation:
I (434) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (440) heap_init: At 3FFB6A08 len 000295F8 (165 KiB): DRAM
I (446) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (452) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (459) heap_init: At 4008CDE4 len 0001321C (76 KiB): IRAM
I (466) spi_flash: detected chip: gd
I (469) spi_flash: flash io: dio
W (473) spi_flash: Detected size(8192k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
Solo Init
I (1607) BW: Starting Sensor and AWS Task ...
I (1607) BW: : Battery Boost Turned ON
I (3127) BookWater: : Modem Power up Completed
I (18127) uart: queue free spaces: 40
I (29077) BW: : Parameters
I (29227) BW: : Module: SIMCOM_SIM800L
I (29427) BW: : rssi: 12, ber: 0
I (29627) BW: : Battery voltage: 4043 mV
I (29827) BW: : PPP Started
I (29827) BW: : Completed Connect Modem. Netif Up !!! 
I (29827) BW: : AWS IoT SDK Version 3.0.1-
I (29827) BW: : Waiting for SIM800 to connect to network
I (30837) esp-netif_lwip-ppp: Connected
I (30837) esp-netif_lwip-ppp: Name Server1: 59.144.144.106
I (30837) esp-netif_lwip-ppp: Name Server2: 203.145.160.5
I (30837) BW: : Modem Connect to PPP Server
I (30877) BW: : GOT ip event!!!
I (30887) BW: : Shadow Init
I (30887) BW: : Shadow Connect
E (44607) aws_iot: failed! mbedtls_net_connect returned -0x52
E (44607) BW: : aws_iot_shadow_connect returned error -23
E (59607) BW :: Device ID string not read from NVS
E (59607) BW: Cannot Connect to AWS ... Retry!!!
I (59607) BookWater: : Disconnecting
E (73607) aws_iot: failed! mbedtls_net_connect returned -0x52
E (73607) BW: : Error unable to disconnect from AWS -23
E (83607) BW: Cannot Connect to AWS ... Retry!!!
I (83607) BW: : Disconnecting
E (97607) aws_iot: failed! mbedtls_net_connect returned -0x52
E (97607) BW: : Error unable to disconnect from AWS -23

But when I connected ESP32 with WiFi network its working!
I'm getting the following output on console.

Code: Select all

I (577) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (641) wifi:wifi driver task: 3ffc2438, prio:23, stack:6656, core=0
I (641) system_api: Base MAC address is not set
I (641) system_api: read default base MAC address from EFUSE
I (691) wifi:wifi firmware version: 8d94a49
I (691) wifi:wifi certification version: v7.0
I (691) wifi:config NVS flash: enabled
I (691) wifi:config nano formating: disabled
I (701) wifi:Init data frame dynamic rx buffer num: 32
I (701) wifi:Init management frame dynamic rx buffer num: 32
I (711) wifi:Init management short buffer num: 32
I (711) wifi:Init dynamic tx buffer num: 32
I (721) wifi:Init static rx buffer size: 1600
I (721) wifi:Init static rx buffer num: 10
I (721) wifi:Init dynamic rx buffer num: 32
I (731) wifi_init: rx ba win: 6
I (731) wifi_init: tcpip mbox: 32
I (731) wifi_init: udp mbox: 6
I (741) wifi_init: tcp mbox: 6
I (741) wifi_init: tcp tx win: 5744
I (751) wifi_init: tcp rx win: 5744
I (751) wifi_init: tcp mss: 1440
I (751) wifi_init: WiFi IRAM OP enabled
I (761) wifi_init: WiFi RX IRAM OP enabled
I (761) shadow: Setting WiFi configuration SSID Error...
W (771) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (911) phy: phy_version: 4370, 4e803b3, Aug 11 2020, 14:18:07, 0, 2
I (921) wifi:mode : sta (4c:11:ae:69:80:30)
I (931) shadow: AWS IoT SDK Version 3.0.1-
I (1651) wifi:new:<6,0>, old:<1,0>, ap:<255,255>, sta:<6,0>, prof:1
I (2421) wifi:state: init -> auth (b0)
I (2431) wifi:state: auth -> assoc (0)
I (2441) wifi:state: assoc -> run (10)
I (2721) wifi:connected with Error, aid = 1, channel 6, BW20, bssid = 7c:78:7e:0b:57:96
I (2731) wifi:security: WPA2-PSK, phy: bgn, rssi: -40
I (2731) wifi:pm start, type: 1
I (2751) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (5621) esp_netif_handlers: sta ip: 192.178.41.203, mask: 255.255.255.0, gw: 192.178.41.1
I (5621) shadow: Shadow Init
I (5621) shadow: Shadow Connect
I (19581) shadow: =======================================================================================
I (19581) shadow: On Device: window state false
I (19591) shadow: Update Shadow: {"state":{"reported":{"temperature":25.500000,"windowOpen":false}}, "clientToken":"MH01AA1234-0"}
I (23021) shadow: *****************************************************************************************
I (23021) shadow: Stack remaining for task 'aws_iot_task' is 3444 bytes
I (24391) shadow: Update accepted
I (25431) shadow: =======================================================================================
I (25431) shadow: On Device: window state false
I (25441) shadow: Update Shadow: {"state":{"reported":{"temperature":26.000000,"windowOpen":false}}, "clientToken":"MH01AA1234-1"}
Thank You!........................

Re: Unable to connect AWS iot Shadow Thing with SIM800!....

Posted: Fri Nov 20, 2020 8:55 am
by ESP_Mahavir
This error code (-0x52) points to failure in name resolution. See code snippet below from mbedTLS:

Code: Select all

  1     if ( getaddrinfo( host, port, &hints, &addr_list ) != 0 ) {
  2         return ( MBEDTLS_ERR_NET_UNKNOWN_HOST );
  3     }
So probably with SIM800 there is issue in DNS lookup, please check on gateway and overall netif configuration for this interface.

Mahavir

Re: Unable to connect AWS iot Shadow Thing with SIM800!....

Posted: Sat Nov 21, 2020 9:29 am
by Tahir Shaik
Thanks for your replay ESP_Mahavir !

Same firmware with the same ESP32 board and with SIM800, I programmed with my Laptop, its working fine and after that, when I programmed with my PC its generating the above error repeatedly.

My PC IDF Version:
ESP-IDF v4.3-dev-907-g6c17e3a64-dirty


MY Laptop IDF Version:
ESP-IDF v4.1-dirty

Re: Unable to connect AWS iot Shadow Thing with SIM800!....

Posted: Fri Nov 27, 2020 8:37 am
by Tahir Shaik
Now its working,

The main reason is netif in
ESP-IDF v4.1-dirty
and
ESP-IDF v4.3-dev-907-g6c17e3a64-dirty
are different.

So when I changed the netif files in
ESP-IDF v4.3-dev-907-g6c17e3a64-dirty
then its working....................

Re: Unable to connect AWS iot Shadow Thing with SIM800!....

Posted: Fri Mar 12, 2021 4:43 am
by neeraja17s@gmail.com
Hi ,

Can you please share the working code for the AWS IOT connection with SIM800L via MQTT.
Thanks in advance.

Regards,
Neeraja