To run this firmware you need the following set up in the project folder:
For the project to compile without errors you need to provide exactly this folder structure with and naming on certificates and keys.
├───main
├───credentials
│ ├───certs
│ │ ├───AmazonRootCA1.pem
│ │ ├───private.pem.key
│ │ ├───public.pem.crt
│ └───credentials.h
├───include
└───src
You need to update the following defines in credentials.h
#ifndef MQTT_CREDENTIALS_H_
#define MQTT_CREDENTIALS_H_
#define WIFI_SSID "wifi" // need to update
#define WIFI_PASS "pass" // need to update
#define MQTT_SERVER_ADDRESS "endpoint" // found in AWS
#define MQTT_MTLS_PORT 8883
#endifNote: credentials.h need to be created as shown in credentials folder!
This file is already present here! Here you can update the settings for you MQTT connection.
#define MQTT_STANDARD_QOS 1
#define MQTT_PAYLOAD_MAX_LEN 256
#define MQTT_PARSED_MAX_LEN 256
#define MQTT_TOPIC_MAX_LEN 64
#define MQTT_WAIT_FOR_MUTEX_MS 50
#define MQTT_MAX_TRIES_SAVE 3
#define MQTT_RECONNECT_TRIES 5
#define MQTT_RECONNECT_REST_MS 1000Note: I have chosen to keep the
keep-aliveas default (120 seconds), and have therefore not implemented a way to change this for now.
The current device shadow used in AWS IoT Core for this . By changing temperature, humidity and/or pressure to 0 - it will stop sending these values.
{
"state": {
"desired": {
"interval_s": 20,
"measurement_map": {
"temperature": 1,
"humidity": 1,
"pressure": 1
},
"topic": "/measurements"
}
}
}The device will work without getting any updates from AWS device_shadow, these are the initial settings:
#define DEVICE_INITIAL_INTERVAL_MS 10000
#define DEVICE_INITIAL_TEMP_SETTING 1 /**1 = take temp | 0 = do not take temp */
#define DEVICE_INITIAL_HUM_SETTING 1 /**1 = take humidity | 0 = do not take humidity */
#define DEVICE_INITIAL_PRESS_SETTING 1 /**1 = take air pressure | 0 = do not take air pressure */
#define DEVICE_INITIAL_PUBLISH_TOPIC "/measurements"If you for some reason want to change the keys they exist in the same file:
#define DEVICE_SHADOW_INTERVAL_KEY "interval_s"
#define DEVICE_SHADOW_TOPIC_KEY "topic"
#define DEVICE_SHADOW_MEAS_MAP_KEY "measurement_map"
#define DEVICE_SHADOW_TEMP_KEY "temperature"
#define DEVICE_SHADOW_HUM_KEY "humidity"
#define DEVICE_SHADOW_PRESS_KEY "pressure"BME280 Sensor Reader connected as following:
It is possible to change the pins inside components/bme280/internal/bme280_i2c.h
#define I2C_SDA_PIN GPIO_NUM_1 /**< SDA pin */
#define I2C_SCL_PIN GPIO_NUM_0 /**< SCL pin */
#define I2C_PORT I2C_NUM_0 /**< Which internal i2c module is used */
#define I2C_FREQUENCY 100000 /**< Frequency for communication */
#define I2C_MASTER_TIMEOUT_MS 1000