ESP32-AWS: Read data from different sensor and store them in Amazon Web Service IoT (Arduino Sketch)
Board Manager Libraries:
- ESP32 by Espressif Systems
Required Libraries:
- MQTT by Joel Gaehwiler
- ArduinoJson by Benoit Blanchon
- DHT sensor library by Adafruit
- Adafruit BMP280 Library by Adafruit
- BH1750 library by Christopher Laws
ESP32-AWS/ESP32/secrets.h
- FILL YOUR SSID and PASSWORD
const char WIFI_SSID[] = "[YOUR SSIS]";
const char WIFI_PASSWORD[] = "[YOUR PASSWORD]";
- FILL THE NAME of YOUR DEVICE
#define THINGNAME "[YOUR THINGNAME]"
- FILL AWS ENDPOINT
const char MQTT_HOST[] = "[YOUR AWS MQTT]";
- Download your root certificate, open it in read mode and replace the section between "BEGIN CERTIFICATE" and "END CERTIFICATE"
static const char cacert[] PROGMEM = R"EOF(
-----BEGIN CERTIFICATE-----
[PUT YOUR CERTIFICATE HERE]
-----END CERTIFICATE-----
)EOF";
- Download your device certificate, open it in read mode and replace the section between "BEGIN CERTIFICATE" and "END CERTIFICATE"
static const char client_cert[] PROGMEM = R"KEY(
-----BEGIN CERTIFICATE-----
[PUT YOUR CERTIFICATE HERE]
-----END CERTIFICATE-----
)KEY";
- Download your device private key, open it in read mode and replace the section between "BEGIN CERTIFICATE" and "END CERTIFICATE"
static const char privkey[] PROGMEM = R"KEY(
-----BEGIN RSA PRIVATE KEY-----
[PUT YOUR KEY HERE]
-----END RSA PRIVATE KEY-----
)KEY";
- Replace this section with your registred API KEY from https://openweathermap.org/
const char OPEN_WEATHER_MAP_API_KEY[] = "[YOUR API KEY]";
{"time":1675957668,"city":"Milan","latitude":45.22,"longitude":9.22,"humidity":28.89999962,"temp":24.04000092,"pressure":101844.1406,"lux":11.66666603,"weathercode":800,"weatherdescr":"clear sky"}