MicrochipTech / gcp-iot-core-examples

Google Cloud Platform IOT Core Examples
Other
111 stars 21 forks source link

Slow MQTT communication #9

Closed danielepsv closed 4 years ago

danielepsv commented 4 years ago

Hi all,

I also have this problem.

I've been testing with SAMD21 + WINC1510 the connection to Google Cloud from the gcp-project (https://github.com/MicrochipTech/gcp-iot-core-examples) and I have the same issue with AVR-IoT:

(SAMD21 LOG) **-- Chip ID 1503a0 -- DriverVerInfo: 0x13521352 -- Firmware ver : 19.6.1 Svnrev 16761 -- Firmware Build May 23 2018 Time 14:39:16 -- Firmware Min driver ver : 19.3.0 -- Driver ver: 19.5.2 -- Driver built at Oct 22 2019 11:12:06

WINC1500 WIFI: Connected to the WIFI access point WINC1500 WIFI: Device IP Address: 192.168.138.192 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 00/00/00 00:00:00 WINC1500 WIFI: Device Time: 2019/10/25 10:57:42

topic[35]: /devices/dXXXXXXXXXXXXX/events json[216]: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX**

It connects fast to wifi as you can see I have an IP address . The device(SAMD21+WINC1510) asks the date/time when connected to the server/cloud and in this log it took a long time. (This happens frequently)

On start/ restart of the AVR-IOT WG demo board (AC164160) the initial connection of the board to the google cloud platform is most of the times slow and a few times acceptable.

I've made this test: restarting the AVR-IOT board to test initial connection speed. I tested with the original code and original microchip project, 70% of the times it takes too long to connect and 30% of the times is acceptable.

Is this because of the ATmega 4808 having 8 bit or is the google cloud traffic slow somehow? The leds bounce between BLUE and RED:

(AVR-IoTSenario) **BLUE led for some seconds RED led only BLUE led again for some seconds RED led only

This goes on for awhile.

Finally BLUE and GREEN led are on and the connection is established.**

What do you think it is? This huge lag between the MQTT communication to the cloud?

Best regards, Daniele

danielepsv commented 4 years ago

Hello,

Does this problem has to do with the region chosen for the project?

Best regards, Daniele

bryan-hunt commented 4 years ago

The time sync is related to finding an NTP time server and getting a time from it. Successive connections should be much faster once you have an RTC set. The ntp communication is all handled inside the WINC1500. If you need additional product support on the WINC you can obtain it through the myMicrochip Support portal

Time is an essential component of the GCP authentication so you need it set up first.

danielepsv commented 4 years ago

Hi Bryan,

Do you know the average time sync for this communication? Thanks in advance.

Best regards, Daniele

bryan-hunt commented 4 years ago

No I don't. It depends on how the WINC functions, which NTP servers it uses, and where you are in the world relative to those NTP servers.

danielepsv commented 4 years ago

I've been texting them too but i don't know if is the time different but they take ages to respond and sometimes they don't understand my questions.

Ok Bryan thank you very much. I think it's related to the region then, I'm in portugal, so the best region for GCP registry is europe-west1, correct?

Best regards, Daniele

bryan-hunt commented 4 years ago

You can change the ntp server pool that the WINC is using by the function m2m_wifi_configure_sntp which you would configure before starting a connection to the access point.

There is a list of ntp servers. I think europe.pool.ntp.org looks like a good option.

danielepsv commented 4 years ago

Hi Bryan,

I've searched in the entire solution and the function m2m_wifi_configure_sntp() doesn't exist. Do I need to create this? Or download it from another project/pacake/library?

Best regards, Daniele

danielepsv commented 4 years ago

Hello Bryan,

This function m2m_wifi_configure_sntp() does not exists. Do you have another solution? This (https://github.com/MicrochipTech/gcp-iot-core-examples/blob/master/scripts/at_set_time.py) doesn't work as well. I've programmed successfully but it didn't make any difference. The time sync is huge most of the times..

Best regards, Daniele

danielepsv commented 4 years ago

Hi Bryan,

In the attachment you can find this project (https://github.com/MicrochipTech/gcp-iot-core-examples) with the function m2m_wifi_configure_sntp() that I got from WINC1500_IOT_CLOUD_DEMO from atmel ASF 3.47 example.

One thing, to use this example, you need to go to config.c and adjust some parameters.

gcp-iot-core-examples-master.zip

Still the SNTP takes too log as you can see in the log file.

log.txt

Do you have another solution?

Best regards, Daniele

bryan-hunt commented 4 years ago

This project is meant to be illustrative examples and "too long" is not a meaningful metric - if its not the sntp maybe it's the loop time, or the connection latency). There are other resources that may be able to assist (the previously mentioned Microchip support) and Google even has their own IOT SDK

danielepsv commented 4 years ago

Hi Bryan,

What loop time? SNTP request time? Which variable should I change? When I say "too long" is around 10 minutes. I think 1 to 3 seconds should be the ideal.

Best regards, Daniele

danielepsv commented 4 years ago

Hi Bryan,

Microchip support detected that in this project the winc15x0 driver version is 19.5.2 and there is a new driver version that matches the firmware version (the lastest is 19.6.1).

Before: Chip ID 1503a0 DriverVerInfo: 0x13521352 Firmware ver : 19.6.1 Svnrev 16761 Firmware Build May 23 2018 Time 14:39:16 Firmware Min driver ver : 19.3.0 Driver ver: 19.5.2 Driver built at Oct 22 2019 11:12:06

Now: Chip ID 1503a0 DriverVerInfo: 0x13301361 Firmware ver : 19.6.1 Svnrev 16761 Firmware Build May 23 2018 Time 14:39:16 Firmware Min driver ver : 19.3.0 Driver ver: 19.6.1 Driver built at Jan 10 2020 09:48:06

Hope this helps.

Best regards, Daniele