This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Connecting to AWS IoT through MQTT

Hello guys,

I have nRF9160DK board here with me and the nRF Connect SDK v1.3.0 environment installed. I want to connect to AWS IoT Thing through the MQTT connection.

I used cloud_client example and your documentation from here as a starting point. My AWS IoT device is properly created on the AWS account and certificates are downloaded into nRF0160DK. In addition to that, here is how I modified my prj.conf and Kconfig files of the cloud_client example.

prj.conf:

#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

# General config
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_NCS_SAMPLES_DEFAULTS=y

# Log level
# For more verbose and detailed log output, set the log level to
# CONFIG_CLOUD_CLIENT_LOG_LEVEL_DBG=y instead.
CONFIG_CLOUD_CLIENT_LOG_LEVEL_INF=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_NETWORK_MODE_LTE_M=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

# BSD library
CONFIG_BSD_LIBRARY=y

# DK
CONFIG_DK_LIBRARY=y

# AT commands interface
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_AT_HOST_LIBRARY=y

# Generic cloud API
CONFIG_CLOUD_API=y

# nRF Cloud
CONFIG_NRF_CLOUD=n

# AWS IoT
CONFIG_AWS_IOT=y

# Heap and stacks
# Extended memory heap size needed for encoding nRF Cloud messages to JSON
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

Kconfig:

#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

menu "Cloud Client Sample Settings"

config CLOUD_BACKEND
	string "String that selects the cloud backend to be used"
	default "AWS_IOT"

config AWS_IOT_BROKER_HOST_NAME
	string "AWS IoT MQTT broker hostname"
	default "xxxxxxxxxx.amazonaws.com"
	help
	  Default is set to be the nRF Cloud MQTT broker.

config AWS_IOT_CLIENT_ID_STATIC
	string "Client ID"
	default "nrf-IMEI"

config AWS_IOT_SEC_TAG
	int "Security tag for TLS credentials"
	default 168xxxxx

config MQTT_BROKER_PORT
	int "AWS IoT MQTT broker port"
	default 8883	

config CLOUD_MESSAGE
	string "Custom message published periodically to cloud"
	default "{\"state\":{\"reported\":{\"message\":\"Hello Internet of Things!\"}}}"

config CLOUD_MESSAGE_PUBLICATION_INTERVAL
	int "How often the custom message should be published to cloud, in seconds"
	default 10

choice
	prompt "Cloud Publication Trigger"
	default CLOUD_PUBLICATION_BUTTON_PRESS

config CLOUD_PUBLICATION_BUTTON_PRESS
	bool "Trigger publication to cloud upon a button press"

config CLOUD_PUBLICATION_SEQUENTIAL
	bool "Sequential publication to cloud set by the CONFIG_MESSAGE_PUBLICATION_INTERVAL option"

endchoice

config POWER_SAVING_MODE_ENABLE
	bool "Request PSM from cellular network"

endmenu

module = CLOUD_CLIENT
module-str = Cloud client
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

menu "Zephyr Kernel"
source "Kconfig.zephyr"
endmenu

However, when I try to connect to the cloud I get the following error messages:

E: mqtt_connect, error: -116
E: Failed to connect to cloud, error: -10

Is there anything I am missing here?

An interesting thing is that a few months ago, with ncs v1.1.0 or v1.2.0 I was able to connect to the AWS IoT Cloud by using the same approach (see this thread).

Thanks in advance for your time and efforts.

Sincerely,

Bojan.

Parents Reply Children
No Data
Related